年度变更建库软件5.0版本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
4.1 KiB

using KGIS.Framework.Platform;
using KGIS.Framework.Platform.Interface;
using KGIS.Framework.Utils;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace Kingo.Plugin.Start
{
public partial class StartForm : Form, IPluginStart
{
public bool IsClosed { get; set; }
public bool IsShow { get; set; }
private string title { get; set; }
private Action<int, int, string> _setPercentAction;
public StartForm()
{
InitializeComponent();
_setPercentAction = SetPercent;
DrawButton(progressBarControl1);
this.Shown += (s, e) =>
{
IsShow = true;
};
this.Load += (sender, e) =>
{
if (string.IsNullOrWhiteSpace(title))
{
title = " 今 奥 年 度 变 更 调 查 建 库 软 件 V2.0";
}
this.Invoke(new Action(() =>
{
// 具体的方法内容 这里写show()
label2.Text = title;
this.Icon = new Icon(string.Format("{0}.ico", Platform.Instance.SystemType.ToString()));
}));
};
//label2.Text = ConfigurationManager.AppSettings.Get("APPName"); ;
}
public void DrawButton(Control sender)
{
GraphicsPath FormPath;
Rectangle rect = new Rectangle(0, 0, sender.Width - 2, sender.Height);
FormPath = GetRoundedRectPath(rect, 10);
sender.Region = new Region(FormPath);
}
/// <summary>
/// 带圆角矩形
/// </summary>
/// <param name="radius">圆角半径</param>
private GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)
{
int diameter = radius;
Rectangle arcRect = new Rectangle(rect.Location, new Size(diameter, diameter));
GraphicsPath path = new GraphicsPath();
// 左上角
path.AddArc(arcRect, 180, 90);
// 右上角
arcRect.X = rect.Right - diameter;
path.AddArc(arcRect, 270, 90);
// 右下角
arcRect.Y = rect.Bottom - diameter;
path.AddArc(arcRect, 0, 90);
// 左下角
arcRect.X = rect.Left;
path.AddArc(arcRect, 90, 90);
path.CloseFigure();//闭合曲线
return path;
}
public void SetPercent(int current, int allCount, string message)
{
try
{
if (InvokeRequired)
{
System.Threading.Thread.Sleep(300);
Invoke(_setPercentAction, current, allCount, message);
}
else
{
progressBarControl1.Properties.Maximum = allCount;
progressBarControl1.Position = current;
label1.Text = "正在初始化【" + message + "】";
//if (current == allCount)
// IsClosed = true;
}
}
catch (Exception ex)
{
LogAPI.Debug("加载 【" + message + "】插件 时异常,异常信息如下:");
LogAPI.Debug(ex);
LogAPI.Debug("加载 【" + message + "】插件 时异常信息结束");
}
}
public void CloseForm()
{
this.Invoke(new Action(() =>
{
Close();
}));
}
public void SetTitle(string _title)
{
title = _title;
}
public void SetSystemType(string pType)
{
this.BackgroundImage = (System.Drawing.Bitmap)global::Kingo.Plugin.Start.Properties.Resources.ResourceManager.GetObject(pType, global::Kingo.Plugin.Start.Properties.Resources.Culture);
//this.Icon = new Icon("TBBG.ico");
//this.Invoke(new Action(() =>
//{
// //this.Icon = new Icon("TBBG.ico");
//}));
}
}
}