public SearchFile() { InitializeComponent(); if (!(Application.Current is App)) { return; } SingletonContentFactory.LoadContent(); PublicFoundItems = FoundItems; // Setup running mode events ModeManager.RunningEvent += (s, args) => { PauseBtn.Content = "Pause"; PauseBtn.Visibility = Visibility.Visible; SearchBtn.Content = "Stop"; }; ModeManager.PausingEvent += (s, args) => { PauseBtn.Content = "Resume"; }; ModeManager.StoppingEvent += (s, args) => { PauseBtn.Visibility = Visibility.Hidden; SearchBtn.Content = "Search"; }; _fileGatheringAlgorithms = UltimateFactory <FileGatheringAlgorithm> .Compute(AppDomain.CurrentDomain); _fileSearchingAlgorithms = UltimateFactory <ContentSearchAlgorithm> .Compute(AppDomain.CurrentDomain); // Get all file-searching algorithms and put them into a combobox. _fileGatheringAlgorithms.GetKeys().ForEach(x => FileGatheringCmbbx.Items.Add(x)); // Get all "string in File"-searching algorithms and put them into another combobox. _fileSearchingAlgorithms.GetKeys().ForEach(x => AlgorithmCmbbx.Items.Add(x)); //Loads custom plugins(if there are any) Loadplugin(); // If one of those dictionary is empty, than we have a problem... if (AlgorithmCmbbx.Items.Count == 0 || FileGatheringCmbbx.Items.Count == 0) { MessageBox.Show( $"Someone's being lazy here!\n{(AlgorithmCmbbx.Items.Count == 0 ? "There are NO algorithms, to search for content, loaded!" : "")}\n{(FileGatheringCmbbx.Items.Count == 0 ? "There are NO file gathering methods loaded!" : "")}", "Ehm", new MessageBoxButton(), MessageBoxImage.Error); Application.Current.Shutdown(); // Rage quit return; } FileGatheringCmbbx.SelectedIndex = 0; AlgorithmCmbbx.SelectedIndex = 0; }
/// <summary> /// For good practice: /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MetroWindow_Closed(object sender, EventArgs e) { SingletonContentFactory.Dispose(); }