/// <summary> /// Event handler for analyzeButton_Click. /// </summary> /// <param name="sender">The object that triggered the event.</param> /// <param name="e">The event arguments.</param> private void analyzeButton_Click(object sender, RoutedEventArgs e) { Environment.CurrentDirectory = currentDirectory; outputListBox.Items.Clear(); try { List<Error> errorList = new ForPragmaScanner(browseTextBox.Text).ScanFile().ToList(); errorList.AddRange(new WhilePragmaScanner(browseTextBox.Text).ScanFile()); errorList.AddRange(new TasksPragmaScanner(browseTextBox.Text).ScanFile()); errorList.AddRange(new LockPragmaScanner(browseTextBox.Text).ScanFile()); errorList.AddRange(new AtomicPragmaScanner(browseTextBox.Text).ScanFile()); errorList.AddRange(new BarrierPragmaScanner(browseTextBox.Text).ScanFile()); errorList.Sort(); if (errorList.Count == 0) { Error noError = new Error(0, "No problems found.", WarningLevels.NonFatal); noError.IconPath = "Images\\ok_sign.png"; outputListBox.Items.Add(noError); } else { foreach (Error error in errorList) { outputListBox.Items.Add(error); } } if (detailsCheckbox.IsChecked == true) { string[] initialContent = ReadFile(browseTextBox.Text); new WarningsWindow(errorList, initialContent).ShowDialog(); } } catch(Exception ex) { Logging.Log(ex.ToString()); MessageBox.Show("Unable to open the specified file.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// Event handler for convertButton_Click. /// </summary> /// <param name="sender">The object that triggered the event.</param> /// <param name="e">The event arguments.</param> private void convertButton_Click(object sender, RoutedEventArgs e) { string initialFile = browseTextBox.Text; string finalFile = convertTextBox.Text; Environment.CurrentDirectory = currentDirectory; outputListBox.Items.Clear(); Main.Application.PragmaLines.Clear(); Main.Application.Intervals.Clear(); try { List<Error> errorList = new ForPragmaScanner(initialFile).ScanFile().ToList(); errorList.AddRange(new WhilePragmaScanner(initialFile).ScanFile()); errorList.AddRange(new TasksPragmaScanner(initialFile).ScanFile()); errorList.AddRange(new LockPragmaScanner(initialFile).ScanFile()); errorList.AddRange(new AtomicPragmaScanner(initialFile).ScanFile()); errorList.AddRange(new BarrierPragmaScanner(browseTextBox.Text).ScanFile()); errorList.Sort(); if (errorList.Count == 0) { Error noError = new Error(0, "No problems found.", WarningLevels.NonFatal); noError.IconPath = "Images\\ok_sign.png"; outputListBox.Items.Add(noError); try { ApplyConversions(initialFile, finalFile); } catch (Exception ex) { Logging.Log(ex.ToString()); MessageBox.Show("Unable to create the specified output file.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { foreach (Error error in errorList) { outputListBox.Items.Add(error); } MessageBoxResult result = MessageBox.Show("The scan of the specified file yielded warnings. " + "Your parallel code may not perform as expected. Are you sure you want to continue?", "Warning", MessageBoxButton.OKCancel, MessageBoxImage.Warning); if (result == MessageBoxResult.OK) { try { ApplyConversions(initialFile, finalFile); } catch (Exception ex) { Logging.Log(ex.ToString()); MessageBox.Show("Unable to create the specified output file.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } } } catch (Exception ex) { Logging.Log(ex.ToString()); MessageBox.Show("Unable to open the specified file.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }