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

Revision 139, 3.7 KB checked in by lowjoel, 6 years ago (diff)

Added half the dialog close event handler. The remaining bit is dependant on the scheduler class implementation in the Manager library.

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                   
39                    item.SubItems.Add(entry.Method.Name);
40                    task.Entries.Add(entry);
41                    errorProvider.Clear();
42                }
43            }
44        }
45
46        private void taskType_CheckedChanged(object sender, EventArgs e)
47        {
48            scheduleTimeLbl.Enabled = scheduleTime.Enabled = schedulePattern.Enabled =
49                scheduleDaily.Enabled = scheduleWeekly.Enabled =
50                scheduleMonthly.Enabled = typeRecurring.Checked;
51            oneTimePanel.Visible = !typeRecurring.Checked;
52           
53            scheduleSpan_CheckedChanged(sender, e);
54        }
55
56        private void scheduleSpan_CheckedChanged(object sender, EventArgs e)
57        {
58            scheduleDailyByDay.Enabled = scheduleDailyByDayLbl.Enabled =
59                scheduleDailyByWeekday.Enabled = scheduleDaily.Checked &&
60                typeRecurring.Checked;
61            scheduleWeeklyLbl.Enabled = scheduleWeeklyFreq.Enabled =
62                scheduleWeeklyFreqLbl.Enabled = scheduleWeeklyMonday.Enabled =
63                scheduleWeeklyTuesday.Enabled = scheduleWeeklyWednesday.Enabled =
64                scheduleWeeklyThursday.Enabled = scheduleWeeklyFriday.Enabled =
65                scheduleWeeklySaturday.Enabled = scheduleWeeklySunday.Enabled =
66                scheduleWeekly.Checked && typeRecurring.Checked;
67            scheduleMonthlyByDay.Enabled = scheduleMonthlyByDayEveryLbl.Enabled =
68                scheduleMonthlyByDayMonthLbl.Enabled = scheduleMonthlyRelative.Enabled =
69                scheduleMonthlyRelativeEveryLbl.Enabled =
70                scheduleMonthlyRelativeFreqLbl.Enabled = scheduleMonthly.Checked &&
71                typeRecurring.Checked;
72
73            scheduleDailySpan_CheckedChanged(sender, e);
74            scheduleMonthlySpan_CheckedChanged(sender, e);
75        }
76
77        private void scheduleDailySpan_CheckedChanged(object sender, EventArgs e)
78        {
79            scheduleDailyByDayFreq.Enabled = scheduleDailyByDay.Checked &&
80                scheduleDaily.Checked && typeRecurring.Checked;
81        }
82
83        private void scheduleMonthlySpan_CheckedChanged(object sender, EventArgs e)
84        {
85            scheduleMonthlyByDayNumber.Enabled = scheduleMonthlyByDayFreq.Enabled =
86                scheduleMonthlyByDay.Checked && scheduleMonthly.Checked &&
87                typeRecurring.Checked;
88            scheduleMonthlyRelativeWeek.Enabled = scheduleMonthlyRelativeWeekDay.Enabled =
89                scheduleMonthlyRelativeFreq.Enabled = scheduleMonthlyRelative.Checked &&
90                scheduleMonthly.Checked && typeRecurring.Checked;
91        }
92
93        private void ok_Click(object sender, EventArgs e)
94        {
95            if (data.Items.Count == 0)
96            {
97                errorProvider.SetIconPadding(data, -16);
98                errorProvider.SetError(data, "The task has no data to erase.");
99                return;
100            }
101
102            errorProvider.Clear();
103
104            //Set the name of the task
105            task.Name = name.Text;
106
107            //And the schedule, if selected.
108            if (typeRecurring.Checked)
109            {
110
111            }
112
113            //Close the dialog
114            DialogResult = DialogResult.OK;
115            Close();
116        }
117
118        private Task task = new Task();
119    }
120}
Note: See TracBrowser for help on using the repository browser.