//public override void VerifyParagraphBatchMode(RangeWrapper par) //{ // m_batchHistory.Clear(); // var parToModify = par.GetCopy(); // string rawContent = par.Text; // if (String.IsNullOrEmpty(rawContent)) // return; // string refinedContent = StringUtil.RefineAndFilterPersianWord(rawContent); // if (String.IsNullOrEmpty(refinedContent)) // return; // string strToVerify = this.NeedRefinedStrings ? refinedContent : rawContent; // if (!InitParagraph(strToVerify)) // return; // while (!VerificationWindowBatchMode.CancelationPending) // { // if (parToModify == null || !parToModify.IsRangeValid) // break; // int len, ind; // FindPatternIteration(out ind, out len); // if (len <= 0 || ind < 0) // break; // RangeWrapper foundRange; // if (NeedRefinedStrings) // { // foundRange = parToModify.GetRangeWithCharIndex( // StringUtil.IndexInNotFilterAndRefinedString(rawContent, ind), // StringUtil.IndexInNotFilterAndRefinedString(rawContent, ind + len - 1) // ); // } // else // { // foundRange = parToModify.GetRangeWithCharIndex(ind, ind + len - 1); // } // var defsug = GetDefaultSuggestionForRecentPattern(); // if (foundRange != null && foundRange.IsRangeValid) // { // if (VerificationWindowBatchMode.ShowProgressAtDocument) // foundRange.Select(); // ApplyBatchModeAction(foundRange, defsug); // // this call is crucial // parToModify.Invalidate(); // } // var verifInstance = new VerificationInstance(parToModify, foundRange, defsug); // if(m_batchHistory.Contains(verifInstance)) // { // VerificationWindowBatchMode.CurrentStatus = "(تشخیص حلقه)"; // return; // } // m_batchHistory.Add(verifInstance); // } //} public override sealed bool HasVerification() { if (CancelationPending) { return(false); } if (!this.IsInteractiveMode && m_isLoopDetected) { return(false); } var strVerifData = FindNextPattern(); if (strVerifData == null || !strVerifData.IsValid) { return(false); } m_curVerifData = new VerificationData(strVerifData, m_mainPar, m_rawContent, NeedRefinedStrings); if (!m_curVerifData.IsValid) { return(false); } return(true); }
private VerificationData ProcessSubParagraph(RangeWrapper subPar) { string rawContent = subPar.Text; if (rawContent == null) { return(null); } string contentToVerify = rawContent; if (NeedRefinedStrings) { contentToVerify = StringUtil.RefineAndFilterPersianWord(rawContent); } var strVerifData = FindPattern(contentToVerify); if (strVerifData == null || !strVerifData.IsValid) { return(null); } var verifData = new VerificationData(strVerifData, subPar, rawContent, NeedRefinedStrings); if (!verifData.IsValid) { return(null); } return(verifData); }
private void SendParagraphForVerification(RangeWrapper par) { if (par == null || !par.IsRangeValid) { return; } if (!m_verifier.InitParagraph(par)) { return; } while (m_verifier.HasVerification()) { if (m_cancelationPending) { return; } // info about content and location of error, or even the related range VerificationData verData = m_verifier.GetNextVerificationData(); if (verData == null || !verData.IsValid) { continue; } //// SendToUi this verData and wait for user interaction //// VerificationResult contains selected suggestion user action and viwercontroller argument //VerificationResult verRes = SendVerificationToUi(verData); string defSuggestion = verData.Suggestions.DefaultSuggestion; if (defSuggestion == null) { continue; } if (ShowProgressAtDocument) { verData.RangeToHighlight.Select(); } m_verifier.ApplyBatchModeAction(verData.RangeToHighlight, defSuggestion); } }
public override bool HasVerification() { if (CancelationPending) { return(false); } //// if the text is shorter or equal than the length that is going to be cut from the paragraph; //// then we expect that no text should remain in the remainder paragraph; but in action it does, //// so hereby we prevent it. if (m_remainedParagraph == null || !m_remainedParagraph.IsRangeValid || m_progInd >= m_remainedParagraph.Text.Length) { return(false); } if (m_progInd > 0) { //m_remainedParagraph = m_remainedParagraph.GetRangeWithOffset(m_progInd - m_remainedParagraph.Start + 1); m_remainedParagraph = m_remainedParagraph.GetRangeWithCharIndex(m_progInd); if (m_remainedParagraph == null || !m_remainedParagraph.IsRangeValid) { return(false); } m_remainedParagraph = m_remainedParagraph.TrimRange(); if (m_remainedParagraph == null || !m_remainedParagraph.IsRangeValid) { return(false); } } m_curVerifData = ProcessSubParagraph(m_remainedParagraph); if (m_curVerifData == null || !m_curVerifData.IsValid) { return(false); } // m_progInd should be further changed by user actions m_progInd = m_curVerifData.ErrorEnd + 1; return(true); }
public VerificationResult SendVerificationToUi(VerificationData data) { var act = new Action(delegate { SetErrorContent( data.ErrorContext, data.ErrorIndex, data.ErrorLength, data.ErrorType); SetSuggestions(data.Suggestions); data.RangeToHighlight.Select(); FixWindowLocation(data.RangeToHighlight); } ); if (this.InvokeRequired) { Invoke(act); } else { act.Invoke(); } return(WaitForMoreUserActions()); //m_eventUserInputRequest.Set(); //m_eventUserInputAvailable.WaitOne(); //string tempSelSug = SelectedSuggestion; //return new VerificationResult //{ // SelectedSuggestion = tempSelSug, // UserAction = LastUserAction, // ViewerControlArg = m_viewerControlArg //}; }
public override bool HasVerification() { if (m_etorNGramVerifs == null) { m_etorNGramVerifs = ReadNGrams().GetEnumerator(); } while (m_etorNGramVerifs.MoveNext()) { var strVerifData = m_etorNGramVerifs.Current; if (m_curVerData == null) { m_curVerData = new VerificationData(); } m_curVerData.SetContent(strVerifData, m_curPar, m_rawContent, NeedRefinedStrings, ref m_rangeRepairOffset); if (m_curVerData.IsValid) { return(true); } } return(false); }
private void SendParagraphForVerification(RangeWrapper par) { if (par == null || !par.IsRangeValid) { return; } if (!m_verifier.InitParagraph(par)) { return; } while (m_verifier.HasVerification()) { if (m_cancelationPending || LastUserAction == UserSelectedActions.Resume) { return; } // info about content and location of error, or even the related range VerificationData verData = m_verifier.GetNextVerificationData(); if (verData == null || !verData.IsValid) { continue; } // SendToUi this verData and wait for user interaction // VerificationResult contains selected suggestion user action and viwercontroller argument VerificationResult verRes = SendVerificationToUi(verData); if (m_cancelationPending || LastUserAction == UserSelectedActions.Resume) { return; } // UI is unaware of the addToDic dialog or any other kind of dialogs it may have // UI should provide means for verifier to call its desired UI dialog shows or others ProceedTypes procType = m_verifier.GetProceedTypeForVerificationResult(verRes); while (procType == ProceedTypes.InvalidUserAction) { verRes = WaitForMoreUserActions(); if (m_cancelationPending || LastUserAction == UserSelectedActions.Resume) { return; } procType = m_verifier.GetProceedTypeForVerificationResult(verRes); } if (procType == ProceedTypes.IdleProceed) { GoIdle(); } } }