ningshuxia
2023-02-07 d027501182b03a0c036af712a2b7f31d55144562
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using DevExpress.LookAndFeel;
using IStation.Client;
using IStation.WinFormUI;
using IStation.WinFormUI.Project;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace IStation.WinClient.Scatl
{
    internal static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            using (var mutex = new System.Threading.Mutex(true, "义维-Scada数据分析", out bool createNew))
            {
                if (!createNew)
                {
                    MessageBox.Show("程序正在运行中...");
                    Application.Exit();
                    return;
                }
 
                #region 处理未被捕获的异常
 
                //处理未捕获的异常   
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                //处理UI线程异常   
                Application.ThreadException += (sender, e) =>
                {
                    WaitFrmHelper.HideWaitForm();
                    e.Exception.ShowMessage();
 
                };
                //处理非UI线程异常   
                AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
                {
                    WaitFrmHelper.HideWaitForm();
                    (e.ExceptionObject as Exception).ShowMessage();
                };
 
                #endregion
 
 
                //DevExpress.UserSkins.BonusSkins.Register();
                DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Bezier");//Visual Studio 2013 Light
                DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(SkinSvgPalette.Bezier.OfficeColorful);
                DevExpress.Skins.SkinManager.EnableFormSkins();
                //zh-Hans界面翻译
                System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-Hans");
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("zh-Hans");
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
 
                //初始化雪花Id
                SnowflakeIdHelper.SetIdGenerator(1);
 
                var dlg = new LoadProjectOverviewDlg();
                dlg.SetBindingData();
                if (dlg.ShowDialog() != DialogResult.OK)
                    return;
                  
                var frm = new MainForm();
                frm.InitialForm();
                Application.Run(frm);
            }
        }
    }
}