Esempio n. 1
0
        static void Main()
        {
            try
            {
                BaseVariable.InitXmlVar();//初始化基础变量
                if (!File.Exists(BaseVariable.XmlFilePath))
                {
                    throw new Exception("Config.xml配置文件不存在,请检查");
                }
                XmlHelper xml = new XmlHelper();
                BaseVariable.RequestURL = xml.SelectValue("/Root/Server/APIURL");
                string modelVaild = xml.SelectValue("/Root/Sys/ModelVaild");
                if (modelVaild.Trim().Equals("1"))
                {
                    string c = BaseVariable.APPRootPath + "config.dat";
                    if (!File.Exists(BaseVariable.XmlFilePath))
                    {
                        throw new Exception("config.dat系统文件不存在,请检查");
                    }

                    SystemIdentity info = SystemIdentity.GetFromFile(c);

                    if (info.GetDeviceModel() != "CK3X")
                    {
                        throw new Exception("设备版本不兼容!!!");
                    }
                }

                string appName = Assembly.GetExecutingAssembly().GetName().Name;
                if (!MutexHelper.IsApplicationOnRun(appName))
                {
                    #region 创建快捷方式
                    Shortcut sc = new Shortcut(Assembly.GetExecutingAssembly(), "鸿泰集成防错系统");
                    if (!sc.IsExist())
                    {
                        sc.Create();
                    }
                    #endregion

                    TaskBarHelper.ShowTaskBar(false);
                    Application.Run(new FrmLogin());
                    Application.Exit();
                }
                else
                {
                    MessageBox.Show("系统正在运行!");//如果该程序已经运行则返回,避免程序重复运行
                    Application.Exit();
                    return;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
            }
            finally
            {
                TaskBarHelper.ShowTaskBar(true);
            }
        }
Esempio n. 2
0
        private void ConfigureStyle()
        {
            Thread styleThread = new Thread(delegate()
            {
                this.BeginInvoke(new MethodInvoker(delegate()
                {
                    this.BackColor     = ColorTranslator.FromHtml("#000");
                    styleConfiguration = registryManager.GetStyleConfiguration();

                    LblUpload.ForeColor   = ColorTranslator.FromHtml(styleConfiguration.TextColor);
                    LblDownload.ForeColor = LblUpload.ForeColor;

                    LblUpload.Font   = new Font(styleConfiguration.FontFamily, LblUpload.Font.Size);
                    LblDownload.Font = LblUpload.Font;

                    bool IsDark = false;

                    try
                    {
                        var taskBar        = new TaskBarHelper();
                        Color taskBarColor = taskBar.GetColourAt(taskBar.GetTaskbarPosition().Location);
                        IsDark             = taskBar.IsDarkColor((int)taskBarColor.R, (int)taskBarColor.G, (int)taskBarColor.B);
                    }
                    catch
                    {
                        goto setIcon;
                    }

                    setIcon:

                    if (styleConfiguration.Icon == IconStyle.Arrow && IsDark == false)
                    {
                        pictUpload.Image   = Properties.Resources.up_black_16px;
                        pictDownload.Image = Properties.Resources.down_black_16px;

                        pictDownload.Location = new Point(11, 17);
                    }
                    else if (styleConfiguration.Icon == IconStyle.Arrow && IsDark)
                    {
                        pictUpload.Image   = Properties.Resources.up_white_16px;
                        pictDownload.Image = Properties.Resources.down_white_16px;

                        pictDownload.Location = new Point(11, 17);
                    }
                    else if (styleConfiguration.Icon == IconStyle.TriangleArrow && IsDark == false)
                    {
                        pictUpload.Image   = Properties.Resources.Triangle_up_arrow_black_16px;
                        pictDownload.Image = Properties.Resources.Triangle_down_arrow_black_16px;
                    }
                    else if (styleConfiguration.Icon == IconStyle.TriangleArrow && IsDark)
                    {
                        pictUpload.Image   = Properties.Resources.Triangle_up_arrow_16px;
                        pictDownload.Image = Properties.Resources.Triangle_down_arrow_16px;
                    }
                    else if (styleConfiguration.Icon == IconStyle.Outline_Arrow && IsDark == false)
                    {
                        pictUpload.Image   = Properties.Resources.outline_arrow_up_black_16px;
                        pictDownload.Image = Properties.Resources.outline_arrow_down_black_16px;
                    }
                    else if (styleConfiguration.Icon == IconStyle.Outline_Arrow && IsDark)
                    {
                        pictUpload.Image   = Properties.Resources.outline_arrow_up_white_16px;
                        pictDownload.Image = Properties.Resources.outline_arrow_down_white_16px;
                    }
                }));
            });

            styleThread.Start();
        }