Пример #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string content = String.Format("{0}\f{1}\f{2}\f{3}\f{4}\f{5}\f{6}",
                    this.checkBox1.Checked, Convert.ToInt32(this.numericUpDown1.Value),
                    this.checkBox2.Checked, Convert.ToInt32(this.numericUpDown2.Value),  Convert.ToInt32(this.numericUpDown3.Value),
                    this.checkBox3.Checked,  Convert.ToInt32(this.numericUpDown4.Value));
                DataManager.Save(Constants.SEPARATE_StartRunSet, content);

                if (checkBox3.Checked)
                {
                    frmMain.myTimer.Interval = Convert.ToInt32(this.numericUpDown2.Value) * (1000 * 60 * 60);
                }

                var modReg = new ModifyRegistry();

                if (this.chkAutoRun.Checked)
                {
                    string autoRunKeyContent = modReg.Read(Constants.Register_Key_Start);
                    if (String.IsNullOrEmpty(autoRunKeyContent))
                    {
                        modReg.Write(Constants.Register_Key_Start, "\"" + Application.ExecutablePath + "\" -autorun");
                    }
                }
                else
                {
                    modReg.DeleteKey(Constants.Register_Key_Start);
                }

                MessageBox.Show("保存成功.","成功");
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存失败." + ex.Message, "错误");
            }
        }
Пример #2
0
        private void SetUIData()
        {
            var modReg = new ModifyRegistry();
            string startKey = modReg.Read(Constants.Register_Key_Start);
            this.chkAutoRun.Checked = !String.IsNullOrEmpty(startKey);

            SettingBiz settingBiz = new SettingBiz();
            var setData = settingBiz.GetSettings();

            this.checkBox1.Checked = setData.EnableStartupRun;
            this.numericUpDown1.Value = setData.StartupRunTimes;

            this.checkBox2.Checked = setData.EnableAutoRun;
            this.numericUpDown2.Value = setData.ExecuteInterval;
            this.numericUpDown3.Value = setData.AutoRequestServerTimes;

            this.checkBox3.Checked = setData.EnableMannulRun;
            this.numericUpDown4.Value = setData.MannulRequestServerTimes;
        }