// ----- Event Handlers ----- private void MainWindow_Load(object sender, EventArgs e) { // Load config values: UserConfig.Load(); this.Location = new Point(UserConfig.Data.LocationX, UserConfig.Data.LocationY); this.Size = new Size(UserConfig.Data.Width, UserConfig.Data.Height); this.WindowState = (FormWindowState)UserConfig.Data.WindowState; searchDirTextBox.Text = UserConfig.Data.SearchDir; includeSubDirsCheckBox.Checked = UserConfig.Data.IncludeSubDirsChecked; fileNameTextBox.Text = UserConfig.Data.FileName; newerThanCheckBox.Checked = UserConfig.Data.NewerThanChecked; newerThanDateTimePicker.Value = UserConfig.Data.NewerThanDateTime; olderThanCheckBox.Checked = UserConfig.Data.OlderThanChecked; olderThanDateTimePicker.Value = UserConfig.Data.OlderThanDateTime; containingCheckBox.Checked = UserConfig.Data.ContainingChecked; containingTextBox.Text = UserConfig.Data.ContainingText; asciiRadioButton.Checked = UserConfig.Data.AsciiChecked; unicodeRadioButton.Checked = UserConfig.Data.UnicodeChecked; delimeterTextBox.Text = 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: Searcher.FoundInfo += new Searcher.FoundInfoEventHandler(Searcher_FoundInfo); Searcher.ThreadEnded += new Searcher.ThreadEndedEventHandler(Searcher_ThreadEnded); }
// ----- Event Handlers ----- private void MainWindow_Load(object sender, EventArgs e) { // Load config values: UserConfig.Load(); this.Location = new Point(UserConfig.Data.LocationX, UserConfig.Data.LocationY); this.Size = new Size(UserConfig.Data.Width, UserConfig.Data.Height); this.WindowState = (FormWindowState)UserConfig.Data.WindowState; searchDirTextBox.Text = UserConfig.Data.SearchDir; includeSubDirsCheckBox.Checked = UserConfig.Data.IncludeSubDirsChecked; fileNameTextBox.Text = UserConfig.Data.FileName; newerThanCheckBox.Checked = UserConfig.Data.NewerThanChecked; newerThanDateTimePicker.Value = UserConfig.Data.NewerThanDateTime; olderThanCheckBox.Checked = UserConfig.Data.OlderThanChecked; olderThanDateTimePicker.Value = UserConfig.Data.OlderThanDateTime; delimeterTextBox.Text = 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: Searcher.FoundInfo += new Searcher.FoundInfoEventHandler(Searcher_FoundInfo); Searcher.ThreadEnded += new Searcher.ThreadEndedEventHandler(Searcher_ThreadEnded); }
//Event Handlers private void MainWindow_Load(object sender, EventArgs e) { searchDirTextBox.Text = UserConfig.Data.SearchDir; fileNameTextBox.Text = UserConfig.Data.FileName; containingTextBox.Text = UserConfig.Data.ContainingText; // Subscribe for my own delegates this.FoundInfo += new FoundInfoSyncHandler(this_FoundInfo); this.ThreadEnded += new ThreadEndedSyncHandler(this_ThreadEnded); // Subscribe for the Searcher's events Searcher.FoundInfo += new Searcher.FoundInfoEventHandler(Searcher_FoundInfo); Searcher.ThreadEnded += new Searcher.ThreadEndedEventHandler(Searcher_ThreadEnded); searchDirTextBox.Text = ""; containingTextBox.Text = ""; }
private void FormMain_Load(object sender, EventArgs e) { _stopWatch = new Stopwatch(); // подписываемся на собственные события (с помощью анонимных методов и лямбда-выражений) _foundInfo = eventArgs => { sfsToolStripStatusLabel.Text = T._("Found matching in the file:") + $" {eventArgs.Info.FullName}"; var initialDirectorySplit = eventArgs.Info.FullName.Split('\\'); AddFileInfoIntoTreeView(initialDirectorySplit.ToList(), sfsSearchResultsTreeView.Nodes, eventArgs.Info.FullName); }; _searchInfo = eventArgs => sfsToolStripStatusLabel.Text = T._("Viewed Files") + $" - {eventArgs.Count}. " + T._("Search in:") + $" {eventArgs.Info.FullName}"; _taskEnded = eventArgs => { // делаем активными отключенные Controls EnableControls(); // выводим затраченное время поиска if (_stopWatch.IsRunning) { _stopWatch.Stop(); sfsToolStripStatusLabel.Text = T._("Total matches found") + $" - {eventArgs.Count}. " + T._("Elapsed time:") + $" {_stopWatch.ElapsedMilliseconds.MillisecondsToTimeString()}"; _stopWatch.Reset(); } // показать текст ошибки, если необходимо if (!eventArgs.Success) { MessageBox.Show(T._("An error occurred during the search:") + $" {eventArgs.ErrorMsg}", T._("Searching error"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }; // подписываемся на события Searcher'а (с помощью анонимных методов и лямбда-выражений) Searcher.FoundInfo += eventArgs => { if (!_formClosing) { Invoke(_foundInfo, eventArgs); } }; Searcher.SearchInfo += eventArgs => { if (!_formClosing) { Invoke(_searchInfo, eventArgs); } }; Searcher.ThreadEnded += eventArgs => { if (!_formClosing) { Invoke(_taskEnded, eventArgs); } }; }
// ----- 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); }