source: branches/eraser6/Eraser/TaskPropertiesForm.cs @ 133

Revision 133, 3.2 KB checked in by lowjoel, 6 years ago (diff)

Added the scheduler editor tab of the task properties dialog.

Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Text;
7using System.Windows.Forms;
8
9using Eraser.Manager;
10
11namespace Eraser
12{
13    public partial class TaskPropertiesForm : Form
14    {
15        public TaskPropertiesForm()
16        {
17            InitializeComponent();
18
19            //Set a default task type
20            typeOneTime.Checked = true;
21            scheduleDaily.Checked = true;
22        }
23
24        private void dataAdd_Click(object sender, EventArgs e)
25        {
26            using (TaskDataSelectionForm form = new TaskDataSelectionForm())
27            {
28                if (form.ShowDialog() == DialogResult.OK)
29                {
30                    Task.EraseTarget entry = form.GetTaskEntry();
31                    ListViewItem item = null;
32                    if (entry is Task.FilesystemObject)
33                        item = data.Items.Add((entry as Task.FilesystemObject).Path);
34                    else if (entry is Task.FreeSpace)
35                        item = data.Items.Add("Unused space on " + (entry as Task.FreeSpace).Drive);
36                    else
37                        throw new NotImplementedException("Unimplemented data erasure type.");
38                    item.SubItems.Add(entry.Method.Name);
39                    task.Entries.Add(entry);
40                }
41            }
42        }
43
44        private void taskType_CheckedChanged(object sender, EventArgs e)
45        {
46            scheduleTimeLbl.Enabled = scheduleTime.Enabled = schedulePattern.Enabled =
47                scheduleDaily.Enabled = scheduleWeekly.Enabled =
48                scheduleMonthly.Enabled = typeRecurring.Checked;
49            oneTimePanel.Visible = !typeRecurring.Checked;
50           
51            scheduleSpan_CheckedChanged(sender, e);
52        }
53
54        private void scheduleSpan_CheckedChanged(object sender, EventArgs e)
55        {
56            scheduleDailyByDay.Enabled = scheduleDailyByDayLbl.Enabled =
57                scheduleDailyByWeekday.Enabled = scheduleDaily.Checked &&
58                typeRecurring.Checked;
59            scheduleWeeklyLbl.Enabled = scheduleWeeklyFreq.Enabled =
60                scheduleWeeklyFreqLbl.Enabled = scheduleWeeklyMonday.Enabled =
61                scheduleWeeklyTuesday.Enabled = scheduleWeeklyWednesday.Enabled =
62                scheduleWeeklyThursday.Enabled = scheduleWeeklyFriday.Enabled =
63                scheduleWeeklySaturday.Enabled = scheduleWeeklySunday.Enabled =
64                scheduleWeekly.Checked && typeRecurring.Checked;
65            scheduleMonthlyByDay.Enabled = scheduleMonthlyByDayEveryLbl.Enabled =
66                scheduleMonthlyByDayMonthLbl.Enabled = scheduleMonthlyRelative.Enabled =
67                scheduleMonthlyRelativeEveryLbl.Enabled =
68                scheduleMonthlyRelativeFreqLbl.Enabled = scheduleMonthly.Checked &&
69                typeRecurring.Checked;
70
71            scheduleDailySpan_CheckedChanged(sender, e);
72            scheduleMonthlySpan_CheckedChanged(sender, e);
73        }
74
75        private void scheduleDailySpan_CheckedChanged(object sender, EventArgs e)
76        {
77            scheduleDailyByDayFreq.Enabled = scheduleDailyByDay.Checked &&
78                scheduleDaily.Checked && typeRecurring.Checked;
79        }
80
81        private void scheduleMonthlySpan_CheckedChanged(object sender, EventArgs e)
82        {
83            scheduleMonthlyByDayNumber.Enabled = scheduleMonthlyByDayFreq.Enabled =
84                scheduleMonthlyByDay.Checked && scheduleMonthly.Checked &&
85                typeRecurring.Checked;
86            scheduleMonthlyRelativeWeek.Enabled = scheduleMonthlyRelativeWeekDay.Enabled =
87                scheduleMonthlyRelativeFreq.Enabled = scheduleMonthlyRelative.Checked &&
88                scheduleMonthly.Checked && typeRecurring.Checked;
89        }
90
91        private Task task = new Task();
92    }
93}
Note: See TracBrowser for help on using the repository browser.