private global::CJBasic.Threading.Timers.RichTimer.TimerConfiguration GetTimerConfiguration() { global::CJBasic.Threading.Timers.RichTimer.TimerConfiguration configuration = null; switch (((RichTimerType)this.enumComboBox_timerType.SelectedValue)) { case RichTimerType.None: return(null); case RichTimerType.PerHour: configuration = new global::CJBasic.Threading.Timers.RichTimer.TimerConfiguration(); configuration.RichTimerType = RichTimerType.PerHour; configuration.Hour = (int)this.numericUpDown_hours.Value; configuration.Minute = (int)this.numericUpDown_mins.Value; return(configuration); case RichTimerType.PerDay: configuration = new global::CJBasic.Threading.Timers.RichTimer.TimerConfiguration(); configuration.RichTimerType = RichTimerType.PerDay; configuration.Hour = (int)this.numericUpDown_hours.Value; configuration.Minute = (int)this.numericUpDown_mins.Value; return(configuration); case RichTimerType.PerWeek: configuration = new global::CJBasic.Threading.Timers.RichTimer.TimerConfiguration(); configuration.RichTimerType = RichTimerType.PerWeek; configuration.DayOfWeek = this.comboBox_week.SelectedIndex; configuration.Hour = (int)this.numericUpDown_hours.Value; configuration.Minute = (int)this.numericUpDown_mins.Value; return(configuration); case RichTimerType.PerMonth: configuration = new global::CJBasic.Threading.Timers.RichTimer.TimerConfiguration(); configuration.RichTimerType = RichTimerType.PerMonth; configuration.Day = (int)this.numericUpDown_day.Value; configuration.Hour = (int)this.numericUpDown_hours.Value; configuration.Minute = (int)this.numericUpDown_mins.Value; return(configuration); case RichTimerType.EverySpan: configuration = new global::CJBasic.Threading.Timers.RichTimer.TimerConfiguration(); configuration.RichTimerType = RichTimerType.EverySpan; configuration.Hour = (int)this.numericUpDown_spanhour.Value; configuration.Minute = (int)this.numericUpDown_spanmins.Value; return(configuration); } return(null); }
private void LoadConfig(global::CJBasic.Threading.Timers.RichTimer.TimerConfiguration config) { if (config == null) { this.enumComboBox_timerType.SelectedValue = RichTimerType.None; this.numericUpDown_day.Value = 1M; this.comboBox_week.Text = "天"; this.numericUpDown_hours.Value = 0M; this.numericUpDown_mins.Value = 0M; this.numericUpDown_spanhour.Value = 0M; this.numericUpDown_spanmins.Value = 0M; this.numericUpDown_day.Enabled = false; this.comboBox_week.Enabled = false; this.numericUpDown_hours.Enabled = false; this.numericUpDown_mins.Enabled = false; this.numericUpDown_spanhour.Enabled = false; this.numericUpDown_spanmins.Enabled = false; } else { this.enumComboBox_timerType.SelectedValue = config.RichTimerType; switch (config.RichTimerType) { case RichTimerType.PerHour: this.numericUpDown_day.Enabled = false; this.comboBox_week.Enabled = false; this.numericUpDown_hours.Enabled = false; this.numericUpDown_mins.Enabled = true; this.numericUpDown_spanhour.Enabled = false; this.numericUpDown_spanmins.Enabled = false; this.numericUpDown_day.Value = 1M; this.comboBox_week.Text = "天"; this.numericUpDown_hours.Value = 0M; this.numericUpDown_mins.Value = config.Minute; this.numericUpDown_spanhour.Value = 0M; this.numericUpDown_spanmins.Value = 0M; break; case RichTimerType.PerDay: this.numericUpDown_day.Enabled = false; this.comboBox_week.Enabled = false; this.numericUpDown_hours.Enabled = true; this.numericUpDown_mins.Enabled = true; this.numericUpDown_spanhour.Enabled = false; this.numericUpDown_spanmins.Enabled = false; this.numericUpDown_day.Value = 1M; this.comboBox_week.Text = "天"; this.numericUpDown_hours.Value = config.Hour; this.numericUpDown_mins.Value = config.Minute; this.numericUpDown_spanhour.Value = 0M; this.numericUpDown_spanmins.Value = 0M; break; case RichTimerType.PerWeek: this.numericUpDown_day.Enabled = false; this.comboBox_week.Enabled = true; this.numericUpDown_hours.Enabled = true; this.numericUpDown_mins.Enabled = true; this.numericUpDown_spanhour.Enabled = false; this.numericUpDown_spanmins.Enabled = false; this.numericUpDown_day.Value = 1M; this.comboBox_week.SelectedItem = config.DayOfWeek; this.numericUpDown_hours.Value = config.Hour; this.numericUpDown_mins.Value = config.Minute; this.numericUpDown_spanhour.Value = 0M; this.numericUpDown_spanmins.Value = 0M; break; case RichTimerType.PerMonth: this.numericUpDown_day.Enabled = true; this.comboBox_week.Enabled = false; this.numericUpDown_hours.Enabled = true; this.numericUpDown_mins.Enabled = true; this.numericUpDown_spanhour.Enabled = false; this.numericUpDown_spanmins.Enabled = false; this.numericUpDown_day.Value = config.Day; this.comboBox_week.Text = "天"; this.numericUpDown_hours.Value = config.Hour; this.numericUpDown_mins.Value = config.Minute; this.numericUpDown_spanhour.Value = 0M; this.numericUpDown_spanmins.Value = 0M; break; case RichTimerType.EverySpan: this.numericUpDown_day.Value = 1M; this.comboBox_week.Text = "天"; this.numericUpDown_hours.Value = 0M; this.numericUpDown_mins.Value = 0M; this.numericUpDown_spanhour.Value = config.Hour; this.numericUpDown_spanmins.Value = config.Minute; this.numericUpDown_day.Enabled = false; this.comboBox_week.Enabled = false; this.numericUpDown_hours.Enabled = false; this.numericUpDown_mins.Enabled = false; this.numericUpDown_spanhour.Enabled = true; this.numericUpDown_spanmins.Enabled = true; break; } } }