using Microsoft.VisualBasic.ApplicationServices;
using System;
using System.Windows.Forms;

namespace RGD.WCS
{
    internal static class Program
    {
        /// <summary>
        /// 单实例应用程序类
        /// </summary>
        private class SingleInstanceApplication : WindowsFormsApplicationBase
        {
            private static SingleInstanceApplication application;

            internal static SingleInstanceApplication Application
            {
                get
                {
                    if (application == null)
                    {
                        application = new SingleInstanceApplication();
                    }

                    return application;
                }
            }

            public SingleInstanceApplication()
            {
                this.IsSingleInstance = true;
            }

            protected override void OnCreateMainForm()
            {
                this.MainForm = FrmMain.FormInstance;
            }
        }

        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        private static void Main(string[] args)
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                SingleInstanceApplication.Application.Run(args);
            }
            catch (Exception e)
            {
                string s = e.Message;
            }
        }
    }
}