/// ------------------------------------------------------------------------------------ /// <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); } } }