public MainSettingsDialog() { InitializeComponent(); // create dictionary of application process names processNameDictionary = new Dictionary<string, string>(); processNameDictionary.Add("Task Manager", "taskmgr"); processNameDictionary.Add("AIM", "aim6"); processNameDictionary.Add("Firefox", "firefox"); processNameDictionary.Add("Google Chrome", "chrome"); processNameDictionary.Add("Google Talk", "googletalk"); processNameDictionary.Add("Internet Explorer", "iexplore"); processNameDictionary.Add("Microsoft Outlook", "OUTLOOK"); processNameDictionary.Add("MSN Messenger", "msmsgs"); processNameDictionary.Add("Safari", "Safari"); processNameDictionary.Add("Thunderbird", "thunderbird"); // initialize PressedOkay to be false _pressedOkay = false; // instantiate settings variables _restrictLevel = new RestrictionLevel(); _timeLimit = new TimeLimit(); _unblockEvent = new UnblockEvent(); // initialize timeLimMins, password, and the hacker settings to default values _timeLimMins = 0; _password = string.Empty; // instantiate a blockedApps List blockedApps = new List<string>(); }
private void btnOkay_Click(object sender, EventArgs e) { // event handler for Okay button // proceed only if there are no input errors // if inputted time is zero and want to set time limit, display error if (limitTimeRadioButton.Checked == true && limitTimeHrsNumericUpDown.Value == 0 && limitTimeMinsNumericUpDown.Value == 0) { ErrorZeroTime errTime = new ErrorZeroTime(); errTime.ShowDialog(); } // if passwords do not match, display error else if (unblockPswdRadioButton.Checked == true && string.Compare(pswd1TextBox.Text.ToString(), pswd2TextBox.Text.ToString()) != 0) { ErrorPswdMismatch errPswd = new ErrorPswdMismatch(); errPswd.ShowDialog(); } // if want to limit applications but none are selected, display error else if (levelAppsRadioButton.Checked == true && aimCheckBox.Checked == false && chromeCheckBox.Checked == false && firefoxCheckBox.Checked == false && iexplorerCheckBox.Checked == false && msnCheckBox.Checked == false && gtalkCheckBox.Checked == false && outlookCheckBox.Checked == false && safariCheckBox.Checked == false && thunderbirdCheckBox.Checked == false) { ErrorZeroApplications errNoApps = new ErrorZeroApplications(); errNoApps.ShowDialog(); } else { // indicate that options were submitted _pressedOkay = true; // instantiate variables in which to store options _restrictLevel = new RestrictionLevel(); _timeLimit = new TimeLimit(); _unblockEvent = new UnblockEvent(); // initialize timeLim and password to default values _timeLimMins = 0; _password = string.Empty; // get restriction level option from radio buttons, and add to blockedApps if relevant if (levelAppsRadioButton.Checked == true) { _restrictLevel = RestrictionLevel.Applications; // add applications one by one to blockedApps, according to check boxes if (aimCheckBox.Checked == true) blockedApps.Add(processNameDictionary["AIM"]); if (firefoxCheckBox.Checked == true) blockedApps.Add(processNameDictionary["Firefox"]); if (chromeCheckBox.Checked == true) blockedApps.Add(processNameDictionary["Google Chrome"]); if (gtalkCheckBox.Checked == true) blockedApps.Add(processNameDictionary["Google Talk"]); if (outlookCheckBox.Checked == true) blockedApps.Add(processNameDictionary["Microsoft Outlook"]); if (msnCheckBox.Checked == true) blockedApps.Add(processNameDictionary["MSN Messenger"]); if (safariCheckBox.Checked == true) blockedApps.Add(processNameDictionary["Safari"]); if (thunderbirdCheckBox.Checked == true) blockedApps.Add(processNameDictionary["Thunderbird"]); } // get time limit option from radio buttons, and set timeLim if relevant if (limitTimeRadioButton.Checked == true) { _timeLimit = TimeLimit.Time; _timeLimMins = (uint) (limitTimeHrsNumericUpDown.Value * 60 + limitTimeMinsNumericUpDown.Value); } else if (limitEventRadioButton.Checked == true) { _timeLimit = TimeLimit.Event; } // get unblock event option from radio buttons, and set password if relevant if (unblockBtnRadioButton.Checked == true) { _unblockEvent = UnblockEvent.Button; } else if (unblockMathRadioButton.Checked == true) { _unblockEvent = UnblockEvent.Math; } else if (unblockPswdRadioButton.Checked == true) { _unblockEvent = UnblockEvent.Password; _password = pswd1TextBox.Text.ToString(); } else if (unblockNeverRadioButton.Checked == true) { _unblockEvent = UnblockEvent.Never; } // copy blockedApps List to an AppArrayIndexer localAppsArray = new string[blockedApps.Count]; blockedApps.CopyTo(localAppsArray); _blockedAppsIndexer = new AppArrayIndexer(this); Hide(); } }