private void ScanBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (!scanStopped) { setupProgressSection("Scan Complete", "Processing results.", false, 0); xmlReader = new XmlTextReader(nmapXMLFile); if (xmlReader != null) { if (scanXML(xmlReader)) { (App.Current as App).deviceList = deviceScanResults; //Get the list of devices ready to pass to the next page (App.Current as App).freshScan = true; //Update scan date and time Properties.Settings.Default.lastScanRunTime = "Last Scan Ran: " + DateTime.Now.Date.ToLongDateString() + " at " + DateTime.Now.ToShortTimeString().ToString(); Properties.Settings.Default.Save(); Properties.Settings.Default.windowNotLocked = true; Properties.Settings.Default.Save(); ResultsPage scanResultsPage = new ResultsPage(); NavigationService.Navigate(scanResultsPage); } else { //Display "No devices found in this scan." setupProgressSection("No Devices Found", "Either your network is empty, or the scan failed. Try again.", false, 0); Properties.Settings.Default.windowNotLocked = true; Properties.Settings.Default.Save(); } } else { //Display error message that the file was not opened successfully. setupProgressSection("Error Processing Scan", "Something went wrong reading the scan result. Try again.", false, 0); Properties.Settings.Default.windowNotLocked = true; Properties.Settings.Default.Save(); } } scanStopped = false; }
/// <summary> /// The "Open Scan" button was clicked, a scan xml file will be opened /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_openScan_Click(object sender, RoutedEventArgs e) { if (Properties.Settings.Default.windowNotLocked) { openFile(); if (xmlReader != null) { if (scanXML(xmlReader)) { (App.Current as App).deviceList = deviceScanResults; //Get the list of devices ready to pass to the next page (App.Current as App).freshScan = false; //This is not a new scan, don't show the save button Properties.Settings.Default.windowNotLocked = true; Properties.Settings.Default.Save(); ResultsPage scanResultsPage = new ResultsPage(); NavigationService.Navigate(scanResultsPage); } else { //Display "No devices found in this scan." setupProgressSection("Error Processing Scan", "Something went wrong reading the scan file. Try again.", false, 0); scanProgressStackPanel.Visibility = Visibility.Collapsed; Properties.Settings.Default.windowNotLocked = true; Properties.Settings.Default.Save(); } } else { //Display error message that the file was not opened successfully. setupProgressSection("Error Processing Scan", "Something went wrong reading the scan file. Try again.", false, 0); scanProgressStackPanel.Visibility = Visibility.Collapsed; Properties.Settings.Default.windowNotLocked = true; Properties.Settings.Default.Save(); } } }