geboshi_V1/LeatherProject/GeBoShi/UI/Load/InitFrm.cs

123 lines
3.4 KiB
C#

using GeBoShi.SysCtrl;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GeBoShi.UI.Load
{
public partial class InitFrm : Form
{
public InitFrm()
{
InitializeComponent();
this.uiTitel1.FatherForm = this;
this.uiTitel1.ShowContrlBox(false, false, true, false);
UIStyle.SetUIStyle(this);
SysMgr.Instance.InitRuning += init_Process;
}
#region
private void init_Process(object sender, InitEventArgs e)
{
ShowInitMessage(e.Message);
if (e.IsInitialized)
{
Thread.Sleep(1000);
CloseWnd();
}
}
private delegate void dSkip_init();
private void Skip_init()
{
if (this.InvokeRequired)
{
dSkip_init d = new dSkip_init(Skip_init);
this.Invoke(d);
}
else
{
this.Cursor = Cursors.Default;
skinButton1.Visible = true;
}
}
private delegate void dCloseWnd();
private void CloseWnd()
{
if (this.InvokeRequired)
{
dCloseWnd d = new dCloseWnd(CloseWnd);
this.Invoke(d);
}
else
{
this.Cursor = Cursors.Default;
SysMgr.Instance.InitRuning -= init_Process;
this.DialogResult = DialogResult.OK;
this.Close();
}
}
private delegate void dShowInitMessage(string message);
private void ShowInitMessage(string message)
{
if (this.InvokeRequired)
{
dShowInitMessage d = new dShowInitMessage(ShowInitMessage);
this.Invoke(d, message);
}
else
{
if (!string.IsNullOrEmpty(StsTextBox.Text))
{
StsTextBox.Text = StsTextBox.Text + "\r\n" + message;
}
else
{ StsTextBox.Text = message; }
StsTextBox.SelectionStart = StsTextBox.Text.Length;
StsTextBox.ScrollToCaret();
}
}
#endregion
private void InitFrm_Load(object sender, EventArgs e)
{
StsTextBox.Text = "";
this.Cursor = Cursors.WaitCursor;
backgroundWorker1.RunWorkerAsync();
skinButton1.Visible = false;
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
Thread.Sleep(500);
try
{
if (!SysMgr.Instance.Initial())
Skip_init();
}
catch (Exception ex)
{
//CloseWnd();
}
}
private void skinButton1_Click(object sender, EventArgs e)
{
SysMgr.Instance.InitRuning -= init_Process;
this.DialogResult = DialogResult.OK;
this.Close();
}
}
}