private void ExecuteDiff(bool isStartup = false) { if (!File.Exists(SrcPathTextBox.Text) || !File.Exists(DstPathTextBox.Text)) { return; } SrcDataGrid.ScrollIntoView(FastGridCellAddress.Empty); DstDataGrid.ScrollIntoView(FastGridCellAddress.Empty); SrcDataGrid.FirstVisibleColumnScrollIndex = 0; SrcDataGrid.FirstVisibleRowScrollIndex = 0; DstDataGrid.FirstVisibleColumnScrollIndex = 0; DstDataGrid.FirstVisibleRowScrollIndex = 0; SrcDataGrid.InitializeComponent(); DstDataGrid.InitializeComponent(); SrcDataGrid.SetMaxColumnSize(App.Instance.Setting.CellWidth); DstDataGrid.SetMaxColumnSize(App.Instance.Setting.CellWidth); SrcDataGrid.SetMinColumnSize(App.Instance.Setting.CellWidth); DstDataGrid.SetMinColumnSize(App.Instance.Setting.CellWidth); var srcPath = SrcPathTextBox.Text; var dstPath = DstPathTextBox.Text; ExcelWorkbook wb1 = null; ExcelWorkbook wb2 = null; ProgressWindow.DoWorkWithModal(progress => { progress.Report(Properties.Resources.Msg_ReadingFiles); var config = CreateReadConfig(); wb1 = ExcelWorkbook.Create(srcPath, config); wb2 = ExcelWorkbook.Create(dstPath, config); }); FileSetting srcSetting = null; FileSetting dstSetting = null; if (!IgnoreFileSettingCheckbox.IsChecked.Value) { srcSetting = FindFilseSetting(Path.GetFileName(SrcPathTextBox.Text), SrcSheetCombobox.SelectedIndex, SrcSheetCombobox.SelectedItem.ToString(), isStartup); dstSetting = FindFilseSetting(Path.GetFileName(DstPathTextBox.Text), DstSheetCombobox.SelectedIndex, DstSheetCombobox.SelectedItem.ToString(), isStartup); diffConfig = CreateDiffConfig(srcSetting, dstSetting, isStartup); } else { diffConfig = new ExcelSheetDiffConfig(); diffConfig.SrcSheetIndex = Math.Max(SrcSheetCombobox.SelectedIndex, 0); diffConfig.DstSheetIndex = Math.Max(DstSheetCombobox.SelectedIndex, 0); } SrcSheetCombobox.SelectedIndex = diffConfig.SrcSheetIndex; DstSheetCombobox.SelectedIndex = diffConfig.DstSheetIndex; var sheet1 = wb1.Sheets[SrcSheetCombobox.SelectedItem.ToString()]; var sheet2 = wb2.Sheets[DstSheetCombobox.SelectedItem.ToString()]; if (sheet1.Rows.Count > 10000 || sheet2.Rows.Count > 10000) { MessageBox.Show(Properties.Resources.Msg_WarnSize); } ExcelSheetDiff diff = null; ProgressWindow.DoWorkWithModal(progress => { progress.Report(Properties.Resources.Msg_ExtractingDiff); diff = ExcelSheet.Diff(sheet1, sheet2, diffConfig); }); var modelConfig = new DiffGridModelConfig(); var srcModel = new DiffGridModel(DiffType.Source, diff, modelConfig); var dstModel = new DiffGridModel(DiffType.Dest, diff, modelConfig); (DataContext as ViewModels.DiffViewModel).UpdateDiffSummary(diff.CreateSummary()); SrcDataGrid.AlternatingColors = App.Instance.Setting.AlternatingColors; DstDataGrid.AlternatingColors = App.Instance.Setting.AlternatingColors; SrcDataGrid.CellFontName = App.Instance.Setting.FontName; DstDataGrid.CellFontName = App.Instance.Setting.FontName; SrcDataGrid.Model = srcModel; DstDataGrid.Model = dstModel; if (ShowOnlyDiffRadioButton.IsChecked.Value) { srcModel.HideEqualRows(); srcModel.HideEqualRows(); } if (srcSetting != null) { srcModel.SetColumnHeader(srcSetting.ColumnHeaderIndex); if (string.IsNullOrEmpty(srcSetting.RowHeaderName)) { srcModel.SetRowHeader(srcSetting.RowHeaderIndex); } else { srcModel.SetRowHeader(srcSetting.RowHeaderName); } SrcDataGrid.MaxRowHeaderWidth = srcSetting.MaxRowHeaderWidth; } if (dstSetting != null) { dstModel.SetColumnHeader(dstSetting.ColumnHeaderIndex); if (string.IsNullOrEmpty(dstSetting.RowHeaderName)) { dstModel.SetRowHeader(dstSetting.RowHeaderIndex); } else { dstModel.SetRowHeader(dstSetting.RowHeaderName); } DstDataGrid.MaxRowHeaderWidth = dstSetting.MaxRowHeaderWidth; } DataGridEventDispatcher.DispatchModelUpdateEvent(SrcDataGrid, container); DataGridEventDispatcher.DispatchModelUpdateEvent(DstDataGrid, container); if (!App.Instance.KeepFileHistory) { App.Instance.UpdateRecentFiles(SrcPathTextBox.Text, DstPathTextBox.Text); } }