コード例 #1
0
ファイル: TimerForm.cs プロジェクト: iovigi/Timer
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            this.settings = this.ReadSetting();
            this.CheckSetting();
        }
コード例 #2
0
        public SettingForm(SettingFormModel settings)
        {
            this.InitializeComponent();

            Color backgroundColor = Color.FromKnownColor(KnownColor.ControlText);

            KnownColor color;

            if (settings != null && !string.IsNullOrEmpty(settings.BackgroundColor) && Enum.TryParse(settings.BackgroundColor, out color))
            {
                backgroundColor = Color.FromName(settings.BackgroundColor);
            }
            else
            {
                settings.BackgroundColor = backgroundColor.ToKnownColor().ToString();
            }

            this.FillComboBox(settings.BackgroundColor);

            this.panelColorExample.BackColor = backgroundColor;
            this.comboBoxColor.SelectedItem  = backgroundColor;

            this.Settings                 = settings ?? new SettingFormModel();
            this.Settings.ToDate          = settings.ToDate;
            this.dateTimePicker.Value     = settings.ToDate > DateTime.MinValue ? settings.ToDate : DateTime.Now;
            this.Settings.BackgroundColor = settings.BackgroundColor;
            this.Settings.IsSuccess       = false;

            this.dateTimePicker.Format       = DateTimePickerFormat.Custom;
            this.dateTimePicker.CustomFormat = "yyyy.MM.dd HH:mm";
        }
コード例 #3
0
ファイル: TimerForm.cs プロジェクト: iovigi/Timer
        private void SaveSetting(SettingFormModel settings)
        {
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            config.AppSettings.Settings.Remove(BACKGROUND_COLOR);
            config.AppSettings.Settings.Add(BACKGROUND_COLOR, settings.BackgroundColor);

            config.AppSettings.Settings.Remove(TO_DATE);
            config.AppSettings.Settings.Add(TO_DATE, settings.ToDate.ToString());

            config.Save(ConfigurationSaveMode.Modified);
        }
コード例 #4
0
ファイル: TimerForm.cs プロジェクト: iovigi/Timer
        private bool ChangeSettings()
        {
            var settingForm = new SettingForm(this.settings);

            if (settingForm.ShowDialog() == DialogResult.OK)
            {
                this.settings = settingForm.Settings;

                this.BackColor            = Color.FromName(this.settings.BackgroundColor);
                this.labelTimer.ForeColor = this.InvertColor(this.BackColor);

                this.SaveSetting(this.settings);
            }

            return(this.settings.IsSuccess);
        }
コード例 #5
0
ファイル: TimerForm.cs プロジェクト: iovigi/Timer
        private SettingFormModel ReadSetting()
        {
            var settings = new SettingFormModel();

            settings.BackgroundColor = ConfigurationManager.AppSettings[BACKGROUND_COLOR];
            var dateString = ConfigurationManager.AppSettings[TO_DATE];

            DateTime toDate;

            if (DateTime.TryParse(dateString, out toDate))
            {
                settings.ToDate    = toDate;
                settings.IsSuccess = toDate > DateTime.Now;
            }

            return(settings);
        }