/// ------------------------------------------------------------------------------------ /// <summary> /// Creates an instance of a CheckingError object if the hvo is for an annotation /// that really is a CheckingError. /// </summary> /// ------------------------------------------------------------------------------------ internal static CheckingError Create(FdoCache cache, int hvo, bool fCheckValidity, bool fLoadIntoCache) { CheckingError error = new CheckingError(cache, hvo, fCheckValidity, fLoadIntoCache); return(error.AnnotationType != NoteType.CheckingError ? null : error); }
/// ------------------------------------------------------------------------------------- /// <summary> /// This method gets called whenever the focused reference in the error pane changes. /// We respond by telling the draft view to scroll to and select the text of the new /// verse. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------- private void OnRefInGridChanged(object sender, CheckingError e) { // TE-6691 -- Not fully initialized yet so return if (EditingHelper == null) { return; } if (e != CheckingError.Empty) { EditingHelper.EditedRootBox.DestroySelection(); StTxtPara para = e.BeginObjectRA as StTxtPara; if (para != null && para.Owner is StFootnote) { // Checking error is for text in a footnote. Make sure the footnote pane is open. StFootnote footnote = para.Owner as StFootnote; ((IViewFootnotes)DraftView).ShowFootnoteView(footnote); } else { ((IViewFootnotes)DraftView).FootnoteViewFocused = false; } // Note: EditingHelper is actually the active editing helper, so the above // code can change its value. EditingHelper.GoToScrScriptureNoteRef(e); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ public CheckingErrorCommentDlg(CheckingError error, IVwStylesheet stylesheet) : this() { System.Diagnostics.Debug.Assert(error != null); m_text = new FwMultiParaTextBox(error.ResolutionOA, stylesheet); m_text.Dock = DockStyle.Fill; pnlTextBox.Controls.Add(m_text); m_error = error; }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ public CheckingErrorCommentDlg(CheckingError error, IVwStylesheet stylesheet) : this() { System.Diagnostics.Debug.Assert(error != null); m_text = new FwMultiParaTextBox(error.ResolutionOA, stylesheet); m_text.Dock = DockStyle.Fill; pnlTextBox.Controls.Add(m_text); m_error = error; }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ public CheckingErrorCommentDlg(CheckingError error, IVwStylesheet stylesheet, IHelpTopicProvider helpTopicHandler) : this() { System.Diagnostics.Debug.Assert(error != null); m_helpTopicProvider = helpTopicHandler; m_text = new FwMultiParaTextBox(error.MyNote.ResolutionOA, stylesheet); m_text.Dock = DockStyle.Fill; pnlTextBox.Controls.Add(m_text); m_error = error; }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ public CheckingErrorCommentDlg(CheckingError error, IVwStylesheet stylesheet, IHelpTopicProvider helpTopicHandler) : this() { System.Diagnostics.Debug.Assert(error != null); m_helpTopicProvider = helpTopicHandler; m_text = new FwMultiParaTextBox(error.MyNote.ResolutionOA, stylesheet); m_text.Dock = DockStyle.Fill; pnlTextBox.Controls.Add(m_text); m_error = error; }
private void EditCheckingErrorComment(CheckingError error, string undoRedoLabel, bool fResolve) { if (StyleSheet == null) return; string undo; string redo; TeResourceHelper.MakeUndoRedoLabels(undoRedoLabel, out undo, out redo); using (UndoTaskHelper undoHelper = new UndoTaskHelper(m_cache.ActionHandlerAccessor, null, undo, redo)) { if (fResolve) error.MyNote.ResolutionStatus = NoteStatus.Closed; using (CheckingErrorCommentDlg dlg = new CheckingErrorCommentDlg(error, StyleSheet, m_helpTopicProvider)) { if (dlg.ShowDialog(FindForm()) == DialogResult.OK) { // Force the cell to repaint so the red corner glyph gets painted. int iRow = m_dataGridView.CurrentCellAddress.Y; m_dataGridView.InvalidateCell(kStatusCol, iRow); undoHelper.RollBack = false; } } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the "invalid" character as a valid character. /// </summary> /// <param name="addedCharError">The checking error containing the character that will /// be added to the valid character inventory.</param> /// ------------------------------------------------------------------------------------ private void AddAsValidCharacter(CheckingError addedCharError) { Debug.Assert(addedCharError.CheckId == StandardCheckIds.kguidCharacters, "Checking error should be from the valid characters check"); IWritingSystem ws = m_cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem; if (TsStringUtils.IsCharacterDefined(addedCharError.MyNote.CitedText)) { using (new WaitCursor(Parent)) { // Get the valid characters from the database ValidCharacters validChars = ValidCharacters.Load(ws, ValidCharsLoadException, FwDirectoryFinder.LegacyWordformingCharOverridesFile); if (validChars != null) { validChars.AddCharacter(addedCharError.MyNote.CitedText); ws.ValidChars = validChars.XmlString; m_cache.ServiceLocator.WritingSystemManager.Save(); } // Mark all data grid view rows containing the newly-defined valid character to irrelevant. for (int iRow = 0; iRow < m_list.Count; iRow++) { CheckingError checkError = GetCheckingError(iRow); if (((IStTxtPara)checkError.MyNote.QuoteOA.ParagraphsOS[0]).Contents.Text == addedCharError.MyNote.CitedText) { // We don't want to create an undoable action, so we suppress subtasks. using (var unitOfWork = new NonUndoableUnitOfWorkHelper(m_cache.ServiceLocator.GetInstance<IActionHandler>())) { checkError.Status = CheckingStatus.StatusEnum.Irrelevant; unitOfWork.RollBack = false; } } } IsStale = true; m_dataGridView.Invalidate(); } } else { string msg = ResourceHelper.GetResourceString("kstidUndefinedCharacterMsg"); MessageBox.Show(this, msg, m_mainWnd.App.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Determines wheter or not the contents of the details cell (specified by /// e.ColumnIndex) represents the cited text for a characters checking error. If so /// and the character does not have a glyph in the cited text's font, then just /// show image indicating that fact. /// </summary> /// ------------------------------------------------------------------------------------ private bool DrawMissingGlyphImage(CheckingError error, DataGridViewCellPaintingEventArgs e) { // Don't do anything if we're not in the detials column or if we're not on a row for // a characters check result or the cell's content is for a non printable character. if (e.ColumnIndex != EditorialChecksRenderingsControl.kDetailsCol || error.CheckId != StandardCheckIds.kguidCharacters || m_detailCellIsForNonPrintableChar) { return false; } // Check if the character has a glyph in its font. // the writing system font. if (!Win32.AreCharGlyphsInFont(error.MyNote.CitedText, e.CellStyle.Font)) { Image img = CharacterGrid.MissingGlyphImage; if (img != null) { // Paint the image that was found in the tag property. int dy = (int)((e.CellBounds.Height - img.Height) / 2); e.Graphics.DrawImageUnscaled(img, e.CellBounds.X + 4, e.CellBounds.Y + dy); return true; } } return false; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the "invalid" character as a valid character. /// </summary> /// <param name="addedCharError">The checking error containing the character that will /// be added to the valid character inventory.</param> /// ------------------------------------------------------------------------------------ private void AddAsValidCharacter(CheckingError addedCharError) { Debug.Assert(addedCharError.CheckId == StandardCheckIds.kguidCharacters, "Checking error should be from the valid characters check"); ILgWritingSystemFactory lgwsf = m_cache.LanguageWritingSystemFactoryAccessor; int hvoWs = m_cache.DefaultVernWs; IWritingSystem ws = lgwsf.get_EngineOrNull(hvoWs); LanguageDefinition langDef = new LanguageDefinition(ws); LgWritingSystem lgWs = new LgWritingSystem(m_cache, hvoWs); langDef.ValidChars = ws.ValidChars; if (StringUtils.IsCharacterDefined(addedCharError.CitedText)) { using (new WaitCursor(Parent)) { // Get the valid characters from the database ValidCharacters validChars = ValidCharacters.Load(langDef); if (validChars != null) { validChars.AddCharacter(addedCharError.CitedText); ws.ValidChars = langDef.ValidChars = validChars.XmlString; StringUtils.UpdatePUACollection(langDef, validChars.AllCharacters); ws.SaveIfDirty(m_cache.DatabaseAccessor); langDef.Serialize(); } // Mark all data grid view rows containing the newly-defined valid character to irrelevant. for (int iRow = 0; iRow < m_list.Count; iRow++) { CheckingError checkError = GetCheckingError(iRow); if (((StTxtPara)checkError.QuoteOA.ParagraphsOS[0]).Contents.Text == addedCharError.CitedText) { // We don't want to create an undoable action, so we suppress subtasks. using (SuppressSubTasks supressActionHandler = new SuppressSubTasks(m_cache, true)) checkError.Status = CheckingStatus.StatusEnum.Irrelevant; } } IsStale = true; m_dataGridView.Invalidate(); } } else { string msg = ResourceHelper.GetResourceString("kstidUndefinedCharacterMsg"); MessageBox.Show(this, msg, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ void OnCheckErrorsListReferenceChanged(object sender, CheckingError error) { if (error == null) return; m_tbbIgnore.Enabled = m_tbbIgnoreWAnnotation.Enabled = (error != CheckingError.Empty && error.ResolutionStatus == NoteStatus.Open); m_tbbInconsistencies.Enabled = (error != CheckingError.Empty && error.ResolutionStatus == NoteStatus.Closed); m_tbbEditAnnotations.Enabled = (error != CheckingError.Empty && error.ResolutionStatus == NoteStatus.Closed); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ void OnCheckErrorsListErrorListContentChanged(object sender, CheckingError error) { OnCheckErrorsListReferenceChanged(sender, error); }
/// ------------------------------------------------------------------------------------- /// <summary> /// This method gets called whenever the focused reference in the error pane changes. /// We respond by telling the draft view to scroll to and select the text of the new /// verse. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------- private void OnRefInGridChanged(object sender, CheckingError e) { // TE-6691 -- Not fully initialized yet so return if (EditingHelper == null || EditingHelper.EditedRootBox == null) return; if (e != null && e != CheckingError.Empty) { EditingHelper.EditedRootBox.DestroySelection(); IStTxtPara para = e.MyNote.BeginObjectRA as IStTxtPara; if (para != null && para.Owner is IStFootnote) { // Checking error is for text in a footnote. Make sure the footnote pane is open. IStFootnote footnote = para.Owner as IStFootnote; ((IViewFootnotes)DraftView).ShowFootnoteView(footnote); } else { ((IViewFootnotes)DraftView).FootnoteViewFocused = false; } // Note: EditingHelper is actually the active editing helper, so the above // code can change its value. EditingHelper.GoToScrScriptureNoteRef(e.MyNote); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates an instance of a CheckingError object if the hvo is for an annotation /// that really is a CheckingError. /// </summary> /// ------------------------------------------------------------------------------------ internal static CheckingError Create(FdoCache cache, int hvo) { CheckingError error = new CheckingError(cache, hvo); return(error.AnnotationType != NoteType.CheckingError ? null : error); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates an instance of a CheckingError object if the hvo is for an annotation /// that really is a CheckingError. /// </summary> /// ------------------------------------------------------------------------------------ internal static CheckingError Create(FdoCache cache, int hvo, bool fCheckValidity, bool fLoadIntoCache) { CheckingError error = new CheckingError(cache, hvo, fCheckValidity, fLoadIntoCache); return (error.AnnotationType != NoteType.CheckingError ? null : error); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates an instance of a CheckingError object if the hvo is for an annotation /// that really is a CheckingError. /// </summary> /// ------------------------------------------------------------------------------------ internal static CheckingError Create(FdoCache cache, int hvo) { CheckingError error = new CheckingError(cache, hvo); return (error.AnnotationType != NoteType.CheckingError ? null : error); }