/// ------------------------------------------------------------------------------------ /// <summary> /// Handle the View Differences button. Display the Review Differences window to /// view/merge differences between the current scripture and selected book in the tree. /// </summary> /// ------------------------------------------------------------------------------------ private void m_btnDiff_Click(object sender, System.EventArgs e) { // If the selected item is not a book, then don't do a diff. TreeNode node = m_treeArchives.SelectedNode; if (node == null) { return; } ScrBook bookRev = node.Tag as ScrBook; if (bookRev == null) { return; } //ScrDraft archive = node.Parent.Tag as ScrDraft; using (BookMerger merger = new BookMerger(m_cache, m_styleSheet, bookRev)) { using (ProgressDialogWithTask progress = new ProgressDialogWithTask(this)) { progress.Title = DlgResources.ResourceString("kstidCompareCaption"); progress.Message = string.Format( DlgResources.ResourceString("kstidMergeProgress"), bookRev.BestUIName); progress.RunTask(true, new BackgroundTaskInvoker(merger.DetectDifferences)); } // always hide diffs that could cause deletion of current sections, if reverted merger.UseFilteredDiffList(); // If there were differences detected then show the diff dialog if (merger.NumberOfDifferences != 0) { using (DiffDialog dlg = new DiffDialog(merger, m_cache, m_styleSheet, m_zoomDraft, m_zoomFootnote)) { // We have to pass the owner (this), so that the dialog shows when the // user clicks on the TE icon in the taskbar. Otherwise only the Archive // dialog would pop up and beeps; diff dialog could only be regained by Alt-Tab. dlg.ShowDialog(this); } } else { // Tell users that no differences were found in the merge MessageBox.Show(this, string.Format(DlgResources.ResourceString("kstidNoDifferencesDetected"), bookRev.BestUIName), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handle the View Differences button. Display the Review Differences window to /// view/merge differences between the current scripture and selected book in the tree. /// </summary> /// ------------------------------------------------------------------------------------ private void m_btnDiff_Click(object sender, System.EventArgs e) { // If the selected item is not a book, then don't do a diff. TreeNode node = m_treeArchives.SelectedNode; if (node == null) { return; } IScrBook bookRev = (IScrBook)node.Tag; if (bookRev == null) { return; } using (BookMerger merger = new BookMerger(m_cache, m_styleSheet, bookRev)) { using (ProgressDialogWithTask progress = new ProgressDialogWithTask(this, m_cache.ThreadHelper)) { progress.Title = DlgResources.ResourceString("kstidCompareCaption"); progress.Message = string.Format( DlgResources.ResourceString("kstidMergeProgress"), bookRev.BestUIName); progress.RunTask(merger.DetectDifferences); } int cUnfilteredDifferences = merger.NumberOfDifferences; // always hide diffs that could cause deletion of current sections, if reverted merger.UseFilteredDiffList = true; bool fShowCompareAndMergeDlg = (merger.NumberOfDifferences != 0); if (!fShowCompareAndMergeDlg && cUnfilteredDifferences > 0) { // Tell users that no differences were found in the merge if (MessageBox.Show(this, string.Format(DlgResources.ResourceString("kstidOnlyAdditionsDetected"), bookRev.BestUIName), m_app.ApplicationName, MessageBoxButtons.YesNo) == DialogResult.Yes) { fShowCompareAndMergeDlg = true; merger.UseFilteredDiffList = false; } } // If there were differences detected then show the diff dialog if (fShowCompareAndMergeDlg) { using (DiffDialog dlg = new DiffDialog(merger, m_cache, m_styleSheet, m_zoomDraft, m_zoomFootnote, m_app, m_helpTopicProvider)) { // We have to pass the owner (this), so that the dialog shows when the // user clicks on the TE icon in the taskbar. Otherwise only the Archive // dialog would pop up and beeps; diff dialog could only be regained by Alt-Tab. dlg.ShowDialog(this); } } else if (cUnfilteredDifferences == 0) { // Tell users that no differences were found in the merge MessageBoxUtils.Show(this, string.Format(DlgResources.ResourceString("kstidNoDifferencesDetected"), bookRev.BestUIName), m_app.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }