/// <summary>
        /// Using the current focus box content, approve it and apply it to all unanalyzed matching
        /// wordforms in the text.  See LT-8833.
        /// </summary>
        /// <returns></returns>
        public void ApproveGuessOrChangesForWholeTextAndMoveNext(Command cmd)
        {
            // Go through the entire text looking for matching analyses that can be set to the new
            // value.
            if (SelectedOccurrence == null)
            {
                return;
            }
            var oldWf  = SelectedOccurrence.Analysis.Wordform;
            var stText = SelectedOccurrence.Paragraph.Owner as IStText;

            if (stText == null || stText.ParagraphsOS.Count == 0)
            {
                return;                 // paranoia, we should be in one of its paragraphs.
            }
            // We don't need to discard existing guesses, even though we will modify Segment.Analyses,
            // since guesses for other wordforms will not be affected, and there will be no remaining
            // guesses for the word we're confirming everywhere. (This needs to be outside the block
            // for the UOW, since what we are suppressing happens at the completion of the UOW.)
            InterlinDoc.SuppressResettingGuesses(
                () =>
            {
                // Needs to include GetRealAnalysis, since it might create a new one.
                UndoableUnitOfWorkHelper.Do(cmd.UndoText, cmd.RedoText, Cache.ActionHandlerAccessor,
                                            () =>
                {
                    IWfiAnalysis obsoleteAna;
                    AnalysisTree newAnalysisTree = InterlinWordControl.GetRealAnalysis(true, out obsoleteAna);
                    var wf = newAnalysisTree.Wordform;
                    if (newAnalysisTree.Analysis == wf)
                    {
                        // nothing significant to confirm, so move on
                        // (return means get out of this lambda expression, not out of the method).
                        return;
                    }
                    SaveAnalysisForAnnotation(SelectedOccurrence, newAnalysisTree);
                    // determine if we confirmed on a sentence initial wordform to its lowercased form
                    bool fIsSentenceInitialCaseChange = oldWf != wf;
                    if (wf != null)
                    {
                        ApplyAnalysisToInstancesOfWordform(newAnalysisTree.Analysis, oldWf, wf);
                    }
                    // don't try to clean up the old analysis until we've finished walking through
                    // the text and applied all our changes, otherwise we could delete a wordform
                    // that is referenced by dummy annotations in the text, and thus cause the display
                    // to treat them like pronunciations, and just show an unanalyzable text (LT-9953)
                    FinishSettingAnalysis(newAnalysisTree, InitialAnalysis);
                    if (obsoleteAna != null)
                    {
                        obsoleteAna.Delete();
                    }
                });
            });
            // This should not make any data changes, since we're telling it not to save and anyway
            // we already saved the current annotation. And it can't correctly place the focus box
            // until the change we just did are completed and PropChanged sent. So keep this outside the UOW.
            OnNextBundle(cmd, false, false, false, true);
        }
 protected virtual bool ShouldCreateAnalysisFromSandbox(bool fSaveGuess)
 {
     if (SelectedOccurrence == null)
     {
         return(false);
     }
     if (InterlinWordControl == null || !InterlinWordControl.ShouldSave(fSaveGuess))
     {
         return(false);
     }
     return(true);
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="fSaveGuess"></param>
        protected virtual void ApproveAnalysis(bool fSaveGuess)
        {
            IWfiAnalysis obsoleteAna;
            AnalysisTree newAnalysisTree = InterlinWordControl.GetRealAnalysis(fSaveGuess, out obsoleteAna);

            // if we've made it this far, might as well try to go the whole way through the UOW.
            SaveAnalysisForAnnotation(SelectedOccurrence, newAnalysisTree);
            FinishSettingAnalysis(newAnalysisTree, InitialAnalysis);
            if (obsoleteAna != null)
            {
                obsoleteAna.Delete();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// split the current occurrence into occurrences for each word in the phrase-wordform.
        /// (if it IsPhrase)
        /// </summary>
        public void OnBreakPhrase(object arg)
        {
            // (LT-8069) in some odd circumstances, the break phrase icon lingers on the tool bar menu when it should
            // have disappeared. If we're in that state, just return.
            if (!ShowBreakPhraseIcon)
            {
                return;
            }
            var cmd = (ICommandUndoRedoText)arg;

            UndoableUnitOfWorkHelper.Do(cmd.UndoText, cmd.RedoText, Cache.ActionHandlerAccessor,
                                        () => SelectedOccurrence.BreakPhrase());
            InterlinWordControl.SwitchWord(SelectedOccurrence);
            UpdateButtonState();
        }
        /// <summary>
        /// Move to the next bundle in the direction indicated by fForward. If fSaveGuess is true, save guesses in the current position,
        /// using Undo  text from the command. If skipFullyAnalyzedWords is true, move to the next item needing analysis, otherwise, the immediate next.
        /// If fMakeDefaultSelection is true, make the default selection within the moved focus box.
        /// </summary>
        public void OnNextBundle(ICommandUndoRedoText undoRedoText, bool fSaveGuess, bool skipFullyAnalyzedWords,
                                 bool fMakeDefaultSelection, bool fForward)
        {
            int currentLineIndex = -1;

            if (InterlinWordControl != null)
            {
                currentLineIndex = InterlinWordControl.GetLineOfCurrentSelection();
            }
            var nextOccurrence = GetNextOccurrenceToAnalyze(fForward, skipFullyAnalyzedWords);

            InterlinDoc.TriggerAnalysisSelected(nextOccurrence, fSaveGuess, fMakeDefaultSelection);
            if (!fMakeDefaultSelection && currentLineIndex >= 0 && InterlinWordControl != null)
            {
                InterlinWordControl.SelectOnOrBeyondLine(currentLineIndex, 1);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Note: Assume we are in the OnDisplayShowLinkWords is true context.
        /// </summary>
        public bool OnJoinWords(object arg)
        {
            var cmd = (ICommandUndoRedoText)arg;

            UndoableUnitOfWorkHelper.Do(cmd.UndoText, cmd.RedoText, Cache.ActionHandlerAccessor,
                                        () =>
            {
                SelectedOccurrence.MakePhraseWithNextWord();
                if (InterlinDoc != null)
                {
                    InterlinDoc.RecordGuessIfNotKnown(SelectedOccurrence);
                }
            });
            InterlinWordControl.SwitchWord(SelectedOccurrence);
            UpdateButtonState();
            return(true);
        }
Exemplo n.º 7
0
        private void btnUndoChanges_Click(object sender, EventArgs e)
        {
            // LT-14001 the only time we don't want the sandbox changed event to fire
            // and update the undo button state is when we're actually processing
            // the undo! Other changes to the sandbox need to update the undo button state.
            var sandbox = m_sandbox as SandboxBase;

            if (sandbox != null)
            {
                sandbox.SandboxChangedEvent -= m_sandbox_SandboxChangedEvent;
            }
            InterlinWordControl.Undo();
            if (sandbox != null)
            {
                sandbox.SandboxChangedEvent += m_sandbox_SandboxChangedEvent;
            }
            UpdateButtonState();
        }
Exemplo n.º 8
0
 private void btnUndoChanges_Click(object sender, EventArgs e)
 {
     InterlinWordControl.OnUndo(null);
     UpdateButtonState();
 }