private void HelpForm_Load(object sender, EventArgs e)
        {
            labelVersions.Text         = labelVersions.Text.Replace("{Version}", ProgramLauncher.Version(2));
            this.textBoxUpdateLog.Text = this.textBoxUpdateLog.Text.Replace("{Version}", ProgramLauncher.Version(2));
            this.labelCopyright.Text   = this.labelCopyright.Text.Replace("{Year}", DateTime.Now.Year.ToString());

            this.TopMost = MainForm.窗口置顶;
        }
Esempio n. 2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            if (this.需要重复开启软件检查)
            {
                // 检测后台是否运行同一程序
                Process[] processes = Process.GetProcessesByName("关机助手");
                if (processes.Length == 0)
                {
                    processes = Process.GetProcessesByName("TimeManager");
                }
                if (processes.Length > 1)
                {
                    MessageBox.Show("检测到后台已经启动本程序,建议关闭其他窗口至只剩下本窗口。", "温馨提示");
                }
            }
            // 检测数据库文件是否存在,不存在则解压缩空数据库
            if (!File.Exists(Properties.Resources.MdfFilename))
            {
                BinaryWriterUtil.WriteFileToDisk(
                    GZipUtil.DecompressBytes(Properties.Resources.EmptyDB),
                    Properties.Resources.MdfFilename);

                MessageBox.Show("检测到您第一次使用本软件,请点击数据管理进行初始化操作。", "欢迎!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ManagerForm.needInitialized = true;
            }
            comboBoxMode.SelectedIndex = 0;
            // 加载配置文件,执行相应的操作(调用已有的事件函数,以免造成与显示不同步的问题)
            if (ConfigManager.MainFormConfigLoaded)
            {
                if (ConfigManager.SafeModeBoot)
                {
                    MainForm.DatabaseOffline = true;
                }
                if (ConfigManager.MainFormAutoDarkMode)
                {
                    darkModeToolStripMenuItem_Click(null, null);
                }
                if (ConfigManager.MainFormOpacity != -1)
                {
                    this.toolStripComboBox不透明度.Text = ConfigManager.MainFormOpacity.ToString() + "%";
                }
                if (ConfigManager.MainDefaultComboBoxIndex != -1)
                {
                    this.comboBoxMode.SelectedIndex = ConfigManager.MainDefaultComboBoxIndex;
                }
                if (ConfigManager.MainFormAutoShutdownSeconds != -1)
                {
                    if (this.label设置倒计时.Text.Contains("分钟"))
                    {
                        this.comboBoxTime.Text = ((double)ConfigManager.MainFormAutoShutdownSeconds / 60).ToString();
                    }
                    else
                    {
                        this.comboBoxTime.Text = ((double)ConfigManager.MainFormAutoShutdownSeconds / 3600).ToString();
                    }
                    button确定_Click(sender, e);
                }
                if (ConfigManager.MainFormHideInTaskbar)
                {
                    任务栏隐匿ToolStripMenuItem_Click(null, null);
                }
                if (ConfigManager.MainFormHideNotifyIcon)
                {
                    隐藏右下角图标ToolStripMenuItem_Click(null, null);
                }
            }
            // 获取版本号并替换标题
            this.Text = this.Text.Replace("{Version}", ProgramLauncher.Version());
            // 给ComboBox添加选项
            AddSelectOptionsInComboBoxTime();
            // 添加鼠标滚动事件
            this.MouseWheel += new MouseEventHandler(comboBoxTime_MouseWheel);
            // 添加时间并开启自动刷新时间线程
            AddNowTimeToFormTitle();
            FlushTitleInEvery10Second();
        }