// ----- Event Handlers ----- private void MainWindow_Load(object sender, EventArgs e) { // Load config values: File_UserConfig.Load(); this.Location = new Point(File_UserConfig.Data.LocationX, File_UserConfig.Data.LocationY); this.Size = new Size(File_UserConfig.Data.Width, File_UserConfig.Data.Height); this.WindowState = (FormWindowState)File_UserConfig.Data.WindowState; searchDirTextBox.Text = File_UserConfig.Data.SearchDir; includeSubDirsCheckBox.Checked = File_UserConfig.Data.IncludeSubDirsChecked; fileNameTextBox.Text = File_UserConfig.Data.FileName; newerThanCheckBox.Checked = File_UserConfig.Data.NewerThanChecked; newerThanDateTimePicker.Value = File_UserConfig.Data.NewerThanDateTime; olderThanCheckBox.Checked = File_UserConfig.Data.OlderThanChecked; olderThanDateTimePicker.Value = File_UserConfig.Data.OlderThanDateTime; containingCheckBox.Checked = File_UserConfig.Data.ContainingChecked; containingTextBox.Text = File_UserConfig.Data.ContainingText; asciiRadioButton.Checked = File_UserConfig.Data.AsciiChecked; unicodeRadioButton.Checked = File_UserConfig.Data.UnicodeChecked; delimeterTextBox.Text = File_UserConfig.Data.Delimeter; // Subscribe for my own delegates: this.FoundInfo += new FoundInfoSyncHandler(this_FoundInfo); this.ThreadEnded += new ThreadEndedSyncHandler(this_ThreadEnded); // Subscribe for the Searcher's events: File_Searcher.FoundInfo += new File_Searcher.FoundInfoEventHandler(Searcher_FoundInfo); File_Searcher.ThreadEnded += new File_Searcher.ThreadEndedEventHandler(Searcher_ThreadEnded); }
private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) { // Remember that the window is closing, // so that all events from the Searcher are ignored from now on: m_closing = true; // Stop the search thread if it is running: File_Searcher.Stop(); // Save config values: if (this.WindowState == FormWindowState.Normal) { File_UserConfig.Data.LocationX = this.Location.X; File_UserConfig.Data.LocationY = this.Location.Y; File_UserConfig.Data.Width = this.Size.Width; File_UserConfig.Data.Height = this.Size.Height; } if (this.WindowState != FormWindowState.Minimized) { File_UserConfig.Data.WindowState = (Int32)this.WindowState; } File_UserConfig.Data.SearchDir = searchDirTextBox.Text; File_UserConfig.Data.IncludeSubDirsChecked = includeSubDirsCheckBox.Checked; File_UserConfig.Data.FileName = fileNameTextBox.Text; File_UserConfig.Data.NewerThanChecked = newerThanCheckBox.Checked; File_UserConfig.Data.NewerThanDateTime = newerThanDateTimePicker.Value; File_UserConfig.Data.OlderThanChecked = olderThanCheckBox.Checked; File_UserConfig.Data.OlderThanDateTime = olderThanDateTimePicker.Value; File_UserConfig.Data.ContainingChecked = containingCheckBox.Checked; File_UserConfig.Data.ContainingText = containingTextBox.Text; File_UserConfig.Data.AsciiChecked = asciiRadioButton.Checked; File_UserConfig.Data.UnicodeChecked = unicodeRadioButton.Checked; File_UserConfig.Data.Delimeter = delimeterTextBox.Text; File_UserConfig.Save(); }