splasher.cs

来自「煤矿信息管理系统是基于SuperMap Object」· CS 代码 · 共 78 行

CS
78
字号
using System;
using System.Threading;
using System.Windows.Forms;

namespace MKIms3
{
	public class Splasher
	{
		static SplashForm MySplashForm = null;
		static Thread MySplashThread = null;
		static void ShowThread() 
		{
			MySplashForm = new SplashForm();
			Application.Run(MySplashForm);
		}


		/// <summary>
		/// 开启一个新的线程来现实splshform
		/// </summary>
		static public void Show() 
		{
			if (MySplashThread != null)
				return;
			
			
				MySplashThread = new Thread(new ThreadStart(Splasher.ShowThread));
				MySplashThread.IsBackground = true;
				MySplashThread.ApartmentState = ApartmentState.MTA;
				MySplashThread.Start();
			
		}

		/// <summary>
		/// 提供关闭splshform窗体的接口
		/// </summary>
		static public void Close() 
		{
			if (MySplashThread == null) return;
			if (MySplashForm == null) return;

			try 
			{
				MySplashForm.Invoke(new MethodInvoker(MySplashForm.Close));
			}
			catch (Exception) 
			{
			}
			MySplashThread = null;
			MySplashForm = null;
		}
        
		/// <summary>
		/// 设置提示信息
		/// </summary>
		static public string Status 
		{
			set 
			{
				if (MySplashForm == null) 
				{
					return;
				}

				MySplashForm.StatusInfo = value;
			}
			get 
			{
				if (MySplashForm == null) 
				{
					throw new InvalidOperationException("Splash Form 没有启动");
				}
				return MySplashForm.StatusInfo;
			}
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?