private void btnDiff_Click(object sender, RoutedEventArgs e) { DiffFilesSelect selector = new DiffFilesSelect(); selector.Owner = this; if ((bool)selector.ShowDialog()) { string file1 = selector.FirstFile; string file2 = selector.SecondFile; FileComparisonPerformer Comparator = null; try { Comparator = new FileComparisonPerformer(file1, file2); var TreeWnd = new CompareTreeWnd(); TreeWnd.LeftName = System.IO.Path.GetFileName(file1); TreeWnd.RightName = System.IO.Path.GetFileName(file2); TreeWnd.PrintResult(Comparator); TreeWnd.Show(); } catch (System.IO.FileNotFoundException exc) { if (Comparator != null) { Comparator.Dispose(); } MessageBox.Show(exc.ToString(), "Неверное имя файла", MessageBoxButton.OK, MessageBoxImage.Exclamation); } catch (Exception exc) { if (Comparator != null) { Comparator.Dispose(); } Utils.UIHelper.DefaultErrHandling(exc); } } }
private static void Diff(string File1, string File2, string Name1, string Name2) { if (!(CheckExistence(File1) && CheckExistence(File2))) { return; } using (FileComparisonPerformer Comparator = new FileComparisonPerformer(File1, File2)) { SafeMessageLoop(() => { App WPFApp = new App(); var TreeWnd = new CompareTreeWnd(); TreeWnd.LeftName = GenerateFileTitle(File1, Name1); TreeWnd.RightName = GenerateFileTitle(File2, Name2); TreeWnd.PrintResult(Comparator); WPFApp.MainWindow = TreeWnd; WPFApp.ShutdownMode = ShutdownMode.OnMainWindowClose; WPFApp.Run(TreeWnd); }); } }