public override void ApplyBatchModeAction(RangeWrapper rangeToChange, string suggestion) { string wordToChange = rangeToChange.Text; if (wordToChange != suggestion) { if (!m_curVerData.RangeToHighlight.TryChangeText(suggestion)) { //this.VerificationWindowInteractive.InvokeMethod(() => //{ // //MessageBox.Show(VerificationWindowInteractive.GetWin32Window(), // // "تغییر مورد نظر قابل اعمال نیست!"); //}); } else { m_sessionLogger.AddUsage(suggestion); base.RefreshForChangeCalled(m_curVerData.RangeToHighlight, suggestion); } } }
public override ProceedTypes GetProceedTypeForVerificationResult(VerificationResult verResult) { UserSelectedActions userAction = verResult.UserAction; string selectedSug = verResult.SelectedSuggestion; var proceedType = ProceedTypes.IdleProceed; if (userAction == UserSelectedActions.Change) { if (m_curVerData.RangeToHighlight.Text != selectedSug) { m_sessionLogger.AddUsage(selectedSug); if (!m_curVerData.RangeToHighlight.TryChangeText(selectedSug)) { this.VerificationWindowInteractive.InvokeMethod(() => PersianMessageBox.Show(VerificationWindowInteractive.GetWin32Window(), "تغییر مورد نظر قابل اعمال نیست!")); return(ProceedTypes.InvalidUserAction); } else { base.RefreshForChangeCalled(m_curVerData.RangeToHighlight, selectedSug); return(ProceedTypes.IdleProceed); } } } else if (userAction == UserSelectedActions.ChangeAll) { m_sessionLogger.AddUsage(selectedSug); var par = m_curVerData.RangeToHighlight.FirstParagraph; var priorRange = par.GetRange(par.Start, m_curVerData.RangeToHighlight.Start); if (priorRange != null && !priorRange.IsRangeValid) { priorRange = null; } if (m_lastSCS == SpaceCorrectionState.SpaceInsertationLeft || m_lastSCS == SpaceCorrectionState.SpaceInsertationLeftSerrially) { if (priorRange != null) { try { priorRange.ReplaceAllTwoWordsCombination(m_curWord1, m_curWord2, selectedSug); } catch { priorRange = null; #if DEBUG throw; #endif } } DocumentUtils.ReplaceAllTwoWordsCombinationInDocument(this.Document, m_curWord1, m_curWord2, selectedSug); } else if (m_lastSCS == SpaceCorrectionState.SpaceInsertationRight || m_lastSCS == SpaceCorrectionState.SpaceInsertationRightSerrially) { if (priorRange != null) { try { priorRange.ReplaceAllTwoWordsCombination(m_curWord0, m_curWord1, selectedSug); } catch { priorRange = null; #if DEBUG throw; #endif } } DocumentUtils.ReplaceAllTwoWordsCombinationInDocument(this.Document, m_curWord0, m_curWord1, selectedSug); } else if (m_lastSCS == SpaceCorrectionState.SpaceDeletation || m_lastSCS == SpaceCorrectionState.SpaceDeletationSerrially) { if (priorRange != null) { try { priorRange.ReplaceAllWordsStandardized(m_curWord1, selectedSug); } catch { priorRange = null; #if DEBUG throw; #endif } } DocumentUtils.ReplaceAllWordsStandardizedInDocument(Document, m_curWord1, selectedSug); } else { if (priorRange != null) { try { priorRange.ReplaceAllWordsStandardized(m_curWord1, selectedSug); } catch { priorRange = null; #if DEBUG throw; #endif } } DocumentUtils.ReplaceAllWordsStandardizedInDocument(this.Document, m_curWord1, selectedSug); } int priorRangeLength = 0; if (priorRange == null || !priorRange.IsRangeValid) { priorRangeLength = 0; } else { try { priorRangeLength = priorRange.Text.Length; } catch (Exception) { priorRangeLength = 0; throw; } } base.RefreshForChangeAllCalled(priorRangeLength, m_curVerData.RangeToHighlight, selectedSug); return(ProceedTypes.IdleProceed); } else if (userAction == UserSelectedActions.IgnoreAll) { Globals.ThisAddIn.SpellCheckerWrapper.IgnoreList.AddToIgnoreList(m_curWordCombToCheck); return(ProceedTypes.IdleProceed); } else if (userAction == UserSelectedActions.AddToDictionary) { string strToAdd = m_curWord1; if (verResult.ViewerControlArg != null) { strToAdd = (string)verResult.ViewerControlArg; } if (!AddToDictionary(strToAdd)) { return(ProceedTypes.InvalidUserAction); } base.RefreshForAddToDictionaryCalled(); return(ProceedTypes.ActiveProceed); } return(proceedType); }