public TimerTask(string timerName, CbRichTimer handler, TimerConfiguration config, object theTag) { this.callBackHandler = handler; this.timerConfiguration = config; this.name = timerName; this.tag = theTag; }
public TimerTask(string timerName, CbRichTimer handler ,TimerConfiguration config, object theTag) { this.callBackHandler = handler; this.timerConfiguration = config; this.name = timerName; this.tag = theTag; }
public override bool Equals(object obj) { TimerConfiguration target = obj as TimerConfiguration; if (target == null) { return(false); } return(this == target); }
private TimerConfiguration GetTimerConfiguration() { TimerConfiguration ConfigTrans = null; switch ((RichTimerType)this.enumComboBox_timerType.SelectedValue) { case RichTimerType.None: { return(null); } case RichTimerType.EverySpan: { ConfigTrans = new TimerConfiguration(); ConfigTrans.RichTimerType = RichTimerType.EverySpan; ConfigTrans.Hour = (int)this.numericUpDown_spanhour.Value; ConfigTrans.Minute = (int)this.numericUpDown_spanmins.Value; return(ConfigTrans); } case RichTimerType.PerMonth: { ConfigTrans = new TimerConfiguration(); ConfigTrans.RichTimerType = RichTimerType.PerMonth; ConfigTrans.Day = (int)this.numericUpDown_day.Value; ConfigTrans.Hour = (int)this.numericUpDown_hours.Value; ConfigTrans.Minute = (int)this.numericUpDown_mins.Value; //ConfigTrans.Second =(int)this. return(ConfigTrans); } case RichTimerType.PerWeek: { ConfigTrans = new TimerConfiguration(); ConfigTrans.RichTimerType = RichTimerType.PerWeek; ConfigTrans.DayOfWeek = (int)this.comboBox_week.SelectedIndex; ConfigTrans.Hour = (int)this.numericUpDown_hours.Value; ConfigTrans.Minute = (int)this.numericUpDown_mins.Value; return(ConfigTrans); } case RichTimerType.PerDay: { ConfigTrans = new TimerConfiguration(); ConfigTrans.RichTimerType = RichTimerType.PerDay; ConfigTrans.Hour = (int)this.numericUpDown_hours.Value; ConfigTrans.Minute = (int)this.numericUpDown_mins.Value; return(ConfigTrans); } case RichTimerType.PerHour: { ConfigTrans = new TimerConfiguration(); ConfigTrans.RichTimerType = RichTimerType.PerHour; ConfigTrans.Hour = (int)this.numericUpDown_hours.Value; ConfigTrans.Minute = (int)this.numericUpDown_mins.Value; return(ConfigTrans); } default: { return(null); } } }
private void LoadConfig(TimerConfiguration config) { if (config == null) { this.enumComboBox_timerType.SelectedValue = RichTimerType.None; this.numericUpDown_day.Value = 1; this.comboBox_week.Text = "天"; this.numericUpDown_hours.Value = 0; this.numericUpDown_mins.Value = 0; this.numericUpDown_spanhour.Value = 0; this.numericUpDown_spanmins.Value = 0; 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; return; } this.enumComboBox_timerType.SelectedValue = config.RichTimerType; switch (config.RichTimerType) { case RichTimerType.EverySpan: { this.numericUpDown_day.Value = 1; this.comboBox_week.Text = "天"; this.numericUpDown_hours.Value = 0; this.numericUpDown_mins.Value = 0; 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; } 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 = 1; this.comboBox_week.Text = "天"; this.numericUpDown_hours.Value = config.Hour; this.numericUpDown_mins.Value = config.Minute; this.numericUpDown_spanhour.Value = 0; this.numericUpDown_spanmins.Value = 0; break; } 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 = 1; this.comboBox_week.Text = "天"; this.numericUpDown_hours.Value = 0; this.numericUpDown_mins.Value = config.Minute; this.numericUpDown_spanhour.Value = 0; this.numericUpDown_spanmins.Value = 0; 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 = 0; this.numericUpDown_spanmins.Value = 0; 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 = 1; this.comboBox_week.SelectedItem = config.DayOfWeek; this.numericUpDown_hours.Value = config.Hour; this.numericUpDown_mins.Value = config.Minute; this.numericUpDown_spanhour.Value = 0; this.numericUpDown_spanmins.Value = 0; break; } } }
private TimerConfiguration GetTimerConfiguration() { TimerConfiguration ConfigTrans = null; switch ((RichTimerType)this.enumComboBox_timerType.SelectedValue) { case RichTimerType.None: { return null; } case RichTimerType.EverySpan: { ConfigTrans = new TimerConfiguration(); ConfigTrans.RichTimerType = RichTimerType.EverySpan; ConfigTrans.Hour = (int)this.numericUpDown_spanhour.Value; ConfigTrans.Minute = (int)this.numericUpDown_spanmins.Value; return ConfigTrans; } case RichTimerType.PerMonth: { ConfigTrans = new TimerConfiguration(); ConfigTrans.RichTimerType = RichTimerType.PerMonth; ConfigTrans.Day = (int)this.numericUpDown_day.Value; ConfigTrans.Hour = (int)this.numericUpDown_hours.Value; ConfigTrans.Minute = (int)this.numericUpDown_mins.Value; //ConfigTrans.Second =(int)this. return ConfigTrans; } case RichTimerType.PerWeek: { ConfigTrans = new TimerConfiguration(); ConfigTrans.RichTimerType = RichTimerType.PerWeek; ConfigTrans.DayOfWeek = (int)this.comboBox_week.SelectedIndex; ConfigTrans.Hour = (int)this.numericUpDown_hours.Value; ConfigTrans.Minute = (int)this.numericUpDown_mins.Value; return ConfigTrans; } case RichTimerType.PerDay: { ConfigTrans = new TimerConfiguration(); ConfigTrans.RichTimerType = RichTimerType.PerDay; ConfigTrans.Hour = (int)this.numericUpDown_hours.Value; ConfigTrans.Minute = (int)this.numericUpDown_mins.Value; return ConfigTrans; } case RichTimerType.PerHour: { ConfigTrans = new TimerConfiguration(); ConfigTrans.RichTimerType = RichTimerType.PerHour; ConfigTrans.Hour = (int)this.numericUpDown_hours.Value; ConfigTrans.Minute = (int)this.numericUpDown_mins.Value; return ConfigTrans; } default: { return null; } } }