private Schedule CreateScheduleObject() { int screenCaptureInterval = _dataConvert.ConvertIntoMilliseconds((int)numericUpDownHoursInterval.Value, (int)numericUpDownMinutesInterval.Value, (int)numericUpDownSecondsInterval.Value); Schedule schedule = new Schedule() { Name = textBoxName.Text, Enable = checkBoxEnable.Checked, ModeOneTime = radioButtonOneTime.Checked, ModePeriod = radioButtonPeriod.Checked, CaptureAt = dateTimePickerCaptureAt.Value, StartAt = dateTimePickerStartAt.Value, StopAt = dateTimePickerStopAt.Value, ScreenCaptureInterval = screenCaptureInterval, Monday = checkBoxMonday.Checked, Tuesday = checkBoxTuesday.Checked, Wednesday = checkBoxWednesday.Checked, Thursday = checkBoxThursday.Checked, Friday = checkBoxFriday.Checked, Saturday = checkBoxSaturday.Checked, Sunday = checkBoxSunday.Checked, Notes = textBoxNotes.Text, Scope = comboBoxScope.Text, Logic = comboBoxLogic.SelectedIndex }; // Set the schedule's timer interval and make sure to not enable the timer until we're ready for it. schedule.Timer.Interval = screenCaptureInterval; schedule.Timer.Enabled = false; return(schedule); }
private void AddTrigger() { if (InputValid()) { TrimInput(); if (TriggerCollection.GetByName(textBoxTriggerName.Text) == null) { int screenCaptureInterval = _dataConvert.ConvertIntoMilliseconds((int)numericUpDownHoursInterval.Value, (int)numericUpDownMinutesInterval.Value, (int)numericUpDownSecondsInterval.Value, (int)numericUpDownMillisecondsInterval.Value); Trigger trigger = new Trigger() { Name = textBoxTriggerName.Text, ConditionType = (TriggerConditionType)listBoxCondition.SelectedIndex, ActionType = (TriggerActionType)listBoxAction.SelectedIndex, Active = checkBoxActive.Checked, Date = dateTimePickerDate.Value, Time = dateTimePickerTime.Value, Day = comboBoxDay.Text, Days = (int)numericUpDownDays.Value, ScreenCaptureInterval = screenCaptureInterval }; if (textBoxTriggerValue.Visible) { trigger.Value = textBoxTriggerValue.Text.Trim(); } else { trigger.Value = listBoxModuleItemList.SelectedItem != null?listBoxModuleItemList.SelectedItem.ToString() : string.Empty; } TriggerCollection.Add(trigger); Okay(); } else { MessageBox.Show("A trigger with this name already exists.", "Duplicate Name Conflict", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Please enter valid input for each field.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AddSchedule() { if (InputValid()) { TrimInput(); if (ScheduleCollection.GetByName(textBoxName.Text) == null) { int screenCaptureInterval = _dataConvert.ConvertIntoMilliseconds((int)numericUpDownHoursInterval.Value, (int)numericUpDownMinutesInterval.Value, (int)numericUpDownSecondsInterval.Value, (int)numericUpDownMillisecondsInterval.Value); Schedule schedule = new Schedule() { Name = textBoxName.Text, Active = checkBoxActive.Checked, ModeOneTime = radioButtonOneTime.Checked, ModePeriod = radioButtonPeriod.Checked, CaptureAt = dateTimePickerCaptureAt.Value, StartAt = dateTimePickerStartAt.Value, StopAt = dateTimePickerStopAt.Value, ScreenCaptureInterval = screenCaptureInterval, Monday = checkBoxMonday.Checked, Tuesday = checkBoxTuesday.Checked, Wednesday = checkBoxWednesday.Checked, Thursday = checkBoxThursday.Checked, Friday = checkBoxFriday.Checked, Saturday = checkBoxSaturday.Checked, Sunday = checkBoxSunday.Checked, Notes = textBoxNotes.Text }; ScheduleCollection.Add(schedule); Okay(); } else { MessageBox.Show("A schedule with this name already exists.", "Duplicate Name Conflict", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Please enter valid input for each field.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private bool InputChanged() { int screenCaptureInterval = DataConvert.ConvertIntoMilliseconds((int)numericUpDownHoursInterval.Value, (int)numericUpDownMinutesInterval.Value, (int)numericUpDownSecondsInterval.Value, (int)numericUpDownMillisecondsInterval.Value); if (ScheduleObject != null && (!ScheduleObject.Active.Equals(checkBoxActive.Checked) || !ScheduleObject.CaptureAt.Equals(dateTimePickerCaptureAt.Value) || !ScheduleObject.StartAt.Equals(dateTimePickerStartAt.Value) || !ScheduleObject.StopAt.Equals(dateTimePickerStopAt.Value) || !ScheduleObject.ScreenCaptureInterval.Equals(screenCaptureInterval) || !ScheduleObject.Monday.Equals(checkBoxMonday.Checked) || !ScheduleObject.Tuesday.Equals(checkBoxTuesday.Checked) || !ScheduleObject.Wednesday.Equals(checkBoxWednesday.Checked) || !ScheduleObject.Thursday.Equals(checkBoxThursday.Checked) || !ScheduleObject.Friday.Equals(checkBoxFriday.Checked) || !ScheduleObject.Saturday.Equals(checkBoxSaturday.Checked) || !ScheduleObject.Sunday.Equals(checkBoxSunday.Checked) || !ScheduleObject.Notes.Equals(textBoxNotes.Text))) { return(true); } return(false); }
private void addSchedule_Click(object sender, EventArgs e) { ShowInterface(); _formSchedule.ScheduleObject = null; int screenCaptureInterval = DataConvert.ConvertIntoMilliseconds((int)numericUpDownHoursInterval.Value, (int)numericUpDownMinutesInterval.Value, (int)numericUpDownSecondsInterval.Value, (int)numericUpDownMillisecondsInterval.Value); _formSchedule.ScreenCaptureInterval = screenCaptureInterval; if (!_formSchedule.Visible) { _formSchedule.ShowDialog(this); } else { _formSchedule.Focus(); _formSchedule.BringToFront(); } if (_formSchedule.DialogResult == DialogResult.OK) { BuildSchedulesModule(); if (!_formSchedule.ScheduleCollection.SaveToXmlFile()) { _screenCapture.ApplicationError = true; } } }
private void ChangeSchedule() { if (InputValid()) { if (NameChanged() || InputChanged()) { TrimInput(); if (ScheduleCollection.GetByName(textBoxName.Text) != null && NameChanged()) { MessageBox.Show("A schedule with this name already exists.", "Duplicate Name Conflict", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { ScheduleCollection.Get(ScheduleObject).Name = textBoxName.Text; ScheduleCollection.Get(ScheduleObject).Active = checkBoxActive.Checked; ScheduleCollection.Get(ScheduleObject).ModeOneTime = radioButtonOneTime.Checked; ScheduleCollection.Get(ScheduleObject).ModePeriod = radioButtonPeriod.Checked; ScheduleCollection.Get(ScheduleObject).CaptureAt = dateTimePickerCaptureAt.Value; ScheduleCollection.Get(ScheduleObject).StartAt = dateTimePickerStartAt.Value; ScheduleCollection.Get(ScheduleObject).StopAt = dateTimePickerStopAt.Value; int screenCaptureInterval = DataConvert.ConvertIntoMilliseconds((int)numericUpDownHoursInterval.Value, (int)numericUpDownMinutesInterval.Value, (int)numericUpDownSecondsInterval.Value, (int)numericUpDownMillisecondsInterval.Value); ScheduleCollection.Get(ScheduleObject).ScreenCaptureInterval = screenCaptureInterval; ScheduleCollection.Get(ScheduleObject).Monday = checkBoxMonday.Checked; ScheduleCollection.Get(ScheduleObject).Tuesday = checkBoxTuesday.Checked; ScheduleCollection.Get(ScheduleObject).Wednesday = checkBoxWednesday.Checked; ScheduleCollection.Get(ScheduleObject).Thursday = checkBoxThursday.Checked; ScheduleCollection.Get(ScheduleObject).Friday = checkBoxFriday.Checked; ScheduleCollection.Get(ScheduleObject).Saturday = checkBoxSaturday.Checked; ScheduleCollection.Get(ScheduleObject).Sunday = checkBoxSunday.Checked; ScheduleCollection.Get(ScheduleObject).Notes = textBoxNotes.Text; Okay(); } } else { Close(); } } else { MessageBox.Show("Please enter valid input for each field.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ChangeTrigger() { if (InputValid()) { if (NameChanged() || InputChanged()) { TrimInput(); if (TriggerCollection.GetByName(textBoxTriggerName.Text) != null && NameChanged()) { MessageBox.Show("A trigger with this name already exists.", "Duplicate Name Conflict", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { TriggerCollection.Get(TriggerObject).Name = textBoxTriggerName.Text; TriggerCollection.Get(TriggerObject).ConditionType = (TriggerConditionType)listBoxCondition.SelectedIndex; TriggerCollection.Get(TriggerObject).ActionType = (TriggerActionType)listBoxAction.SelectedIndex; TriggerCollection.Get(TriggerObject).Active = checkBoxActive.Checked; TriggerCollection.Get(TriggerObject).Date = dateTimePickerDate.Value; TriggerCollection.Get(TriggerObject).Time = dateTimePickerTime.Value; TriggerCollection.Get(TriggerObject).Day = comboBoxDay.Text; if (listBoxModuleItemList.SelectedItem != null) { TriggerCollection.Get(TriggerObject).ModuleItem = listBoxModuleItemList.SelectedItem.ToString(); } else { TriggerCollection.Get(TriggerObject).ModuleItem = string.Empty; } int screenCaptureInterval = DataConvert.ConvertIntoMilliseconds((int)numericUpDownHoursInterval.Value, (int)numericUpDownMinutesInterval.Value, (int)numericUpDownSecondsInterval.Value, (int)numericUpDownMillisecondsInterval.Value); TriggerCollection.Get(TriggerObject).ScreenCaptureInterval = screenCaptureInterval; Okay(); } } else { Close(); } } else { MessageBox.Show("Please enter valid input for each field.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private bool InputChanged() { int screenCaptureInterval = DataConvert.ConvertIntoMilliseconds((int)numericUpDownHoursInterval.Value, (int)numericUpDownMinutesInterval.Value, (int)numericUpDownSecondsInterval.Value, (int)numericUpDownMillisecondsInterval.Value); if (TriggerObject != null && ((int)TriggerObject.ConditionType != listBoxCondition.SelectedIndex || (int)TriggerObject.ActionType != listBoxAction.SelectedIndex || (listBoxModuleItemList.Items.Count > 0 && TriggerObject.ModuleItem != null && listBoxModuleItemList.SelectedItem != null && !TriggerObject.ModuleItem.Equals(listBoxModuleItemList.SelectedItem.ToString())) || TriggerObject.Active != checkBoxActive.Checked || TriggerObject.Date != dateTimePickerDate.Value || TriggerObject.Time != dateTimePickerTime.Value || !TriggerObject.ScreenCaptureInterval.Equals(screenCaptureInterval))) { return(true); } else { return(false); } }
/// <summary> /// Converts the given hours, minutes, seconds, and milliseconds into an aggregate milliseconds value. /// </summary> /// <param name="hours">The number of hours to be converted.</param> /// <param name="minutes">The number of minutes to be converted.</param> /// <param name="seconds">The number of seconds to be converted.</param> /// <param name="milliseconds">The number of milliseconds to be converted.</param> /// <returns></returns> private int ConvertIntoMilliseconds(int hours, int minutes, int seconds, int milliseconds) { return(DataConvert.ConvertIntoMilliseconds(hours, minutes, seconds, milliseconds)); }