Exemple #1
0
        /// <summary>
        /// Any selection that involves an IAnalysis should be expanded to complete IAnalysis objects.
        /// This method also updates a list of selected AnalysisOccurrences.
        /// </summary>
        /// <param name="prootb"></param>
        /// <param name="vwselNew"></param>
        protected override void HandleSelectionChange(IVwRootBox prootb, IVwSelection vwselNew)
        {
            if (m_fInSelChanged)
            {
                return;
            }
            m_fInSelChanged = true;
            try
            {
                m_selectedWordforms = null;
                base.HandleSelectionChange(prootb, vwselNew);
                if (vwselNew == null)
                {
                    return;
                }

                SelLevInfo[] analysisLevels;
                SelLevInfo[] endLevels;
                if (TryGetAnalysisLevelsAndEndLevels(vwselNew, out analysisLevels, out endLevels))
                {
                    m_selectedWordforms = GetSelectedOccurrences(analysisLevels, endLevels[0].ihvo);
                    RootBox.MakeTextSelInObj(0, analysisLevels.Length, analysisLevels, endLevels.Length, endLevels, false, false,
                                             false, true, true);
                }
                else
                {
                    RootBox.DestroySelection();
                }
            }
            finally
            {
                m_fInSelChanged = false;
            }
        }
        private void InitSandbox()
        {
            SetSandboxSize();

            m_vc.LeftPadding = 0;
            m_rootb.Reconstruct();
            using (new HoldGraphics(this))
            {
                Rectangle rcSrcRoot;
                Rectangle rcDstRoot;
                GetCoordRects(out rcSrcRoot, out rcDstRoot);
                var rgvsli = new SelLevInfo[1];
                //rgvsli[1].ihvo = 0; // first morpheme bundle
                //rgvsli[1].tag = (int)WfiAnalysis.WfiAnalysisTags.kflidMorphBundles;
                rgvsli[0].ihvo = 0;
                rgvsli[0].tag  = m_fdoCache.MetaDataCacheAccessor.GetFieldId2(CmObjectTags.kClassId, "Self", false);
                var sel = RootBox.MakeTextSelInObj(0, rgvsli.Length, rgvsli, 0, null, true, false, false, false, false);
                if (sel == null)
                {
                    Debug.WriteLine("Could not make selection in InitSandbox");
                    return;                     // can't position it accurately.
                }
                Rect rcSec;
                bool fSplit, fEndBeforeAnchor;
                sel.Location(m_graphicsManager.VwGraphics, rcSrcRoot, rcDstRoot, out m_rcPrimary, out rcSec,
                             out fSplit, out fEndBeforeAnchor);
            }
            SetPadding();
            SetSandboxLocation();
        }
Exemple #3
0
        /// <summary>
        /// Move to the last bundle
        /// </summary>
        /// <param name="arg"></param>
        /// <returns></returns>
        public bool OnLastBundle(object arg)
        {
            var levels = new SelLevInfo[3];

            levels[2].tag  = StTextTags.kflidParagraphs;
            levels[2].ihvo = RootStText.ParagraphsOS.Count - 1;
            var lastPara = (IStTxtPara)RootStText.ParagraphsOS.Last();

            levels[1].tag  = StTxtParaTags.kflidSegments;
            levels[1].ihvo = lastPara.SegmentsOS.Count - 1;
            ISegment lastSegment = lastPara.SegmentsOS.Last();
            int      i;

            for (i = lastSegment.AnalysesRS.Count - 1; i >= 0; i--)
            {
                if (!(lastSegment.AnalysesRS[i] is IPunctuationForm))
                {
                    break;
                }
            }
            levels[0].tag  = SegmentTags.kflidAnalyses;
            levels[0].ihvo = i;
            RootBox.MakeTextSelInObj(0, levels.Length, levels, 0, null, false, false, false, true, true);
            return(true);
        }
Exemple #4
0
        private void SelectRange(int begin1, int end1)
        {
            if (HvoRoot == 0)
            {
                return;
            }
            int end   = Math.Min(end1, Decorator.get_VecSize(HvoRoot, OccurenceListId) - 1);
            int begin = Math.Min(begin1, end);

            if (end < 0 || begin < 0)
            {
                return;
            }
            try
            {
                m_InSelectionChanged = true;
                SelLevInfo[] levelsA = new SelLevInfo[1];
                levelsA[0].ihvo = begin;
                levelsA[0].tag  = OccurenceListId;
                SelLevInfo[] levelsE = new SelLevInfo[1];
                levelsE[0].ihvo = end;
                levelsE[0].tag  = OccurenceListId;
                RootBox.MakeTextSelInObj(0, 1, levelsA, 1, levelsE, false, false, false, true, true);
            }
            finally
            {
                m_InSelectionChanged = false;
            }
        }
Exemple #5
0
        protected void SelectUpTo(int end1)
        {
            if (HvoRoot == 0 || RootBox == null)
            {
                return;
            }
            //Debug.Assert(RootBox != null, "Why is the chart ribbon's RootBox null?");
            var end = Math.Min(end1, Decorator.get_VecSize(HvoRoot, OccurenceListId) - 1);

            if (end < 0)
            {
                return;
            }
            if (EndSelLimitIndex > -1 && EndSelLimitIndex < end)
            {
                end = EndSelLimitIndex;
            }
            try
            {
                m_InSelectionChanged = true;
                var levelsA = new SelLevInfo[1];
                levelsA[0].ihvo = 0;
                levelsA[0].tag  = OccurenceListId;
                var levelsE = new SelLevInfo[1];
                levelsE[0].ihvo = end;
                levelsE[0].tag  = OccurenceListId;
                RootBox.MakeTextSelInObj(0, 1, levelsA, 1, levelsE, false, false, false, true, true);
            }
            finally
            {
                m_InSelectionChanged = false;
            }
        }
Exemple #6
0
        protected void SelectUpTo(int end1)
        {
            if (HvoRoot == 0)
            {
                return;
            }
            int end = Math.Min(end1, m_cache.GetVectorSize(HvoRoot, AnnotationListId) - 1);

            if (end < 0)
            {
                return;
            }
            if (EndSelLimitIndex > -1 && EndSelLimitIndex < end)
            {
                end = EndSelLimitIndex;
            }
            try
            {
                m_InSelectionChanged = true;
                SelLevInfo[] levelsA = new SelLevInfo[1];
                levelsA[0].ihvo = 0;
                levelsA[0].tag  = AnnotationListId;
                SelLevInfo[] levelsE = new SelLevInfo[1];
                levelsE[0].ihvo = end;
                levelsE[0].tag  = AnnotationListId;
                RootBox.MakeTextSelInObj(0, 1, levelsA, 1, levelsE, false, false, false, true, true);
            }
            finally
            {
                m_InSelectionChanged = false;
            }
        }
Exemple #7
0
        /// <summary>
        /// Move to the first bundle
        /// </summary>
        /// <param name="arg"></param>
        /// <returns></returns>
        public bool OnFirstBundle(object arg)
        {
            var levels = new SelLevInfo[3];

            levels[2].tag  = StTextTags.kflidParagraphs;
            levels[2].ihvo = 0;
            levels[1].tag  = StTxtParaTags.kflidSegments;
            levels[1].ihvo = 0;
            levels[0].tag  = SegmentTags.kflidAnalyses;
            levels[0].ihvo = 0;
            RootBox.MakeTextSelInObj(0, levels.Length, levels, 0, null, false, false, false, true, true);
            return(true);
        }
Exemple #8
0
        /// <summary>
        /// Moves the cursor to the specified position in the specified cell.
        /// </summary>
        /// <param name="ctxt">The context.</param>
        /// <param name="index">Index of the item in the cell.</param>
        /// <param name="initial">if <c>true</c> move the cursor to the beginning of the specified item, otherwise it is moved to the end</param>
        /// <param name="editable">if <c>true</c> move the cursor to the first editable position</param>
        /// <param name="install">if <c>true</c> install the selection</param>
        /// <returns>The new selection</returns>
        public IVwSelection SelectAt(object ctxt, int index, bool initial, bool editable, bool install)
        {
            SelLevInfo[] levels = m_patternControl.GetLevelInfo(ctxt, index);
            if (levels == null)
            {
                int count = m_patternControl.GetContextCount(ctxt);
                if (count == 0)
                {
                    var newSel = new SelectionHelper();
                    newSel.SetTextPropId(SelectionHelper.SelLimitType.Anchor, m_patternControl.GetFlid(ctxt));
                    return(newSel.SetSelection(this, install, false));
                }
                levels = m_patternControl.GetLevelInfo(ctxt, initial ? 0 : count - 1);
            }

            return(RootBox.MakeTextSelInObj(0, levels.Length, levels, 0, null, initial, editable, false, false, install));
        }
Exemple #9
0
        /// <summary>
        /// Get overridden for subclasses needing a Sandbox.
        /// </summary>
        /// <param name="rgvsli"></param>
        /// <returns></returns>
        protected virtual IVwSelection MakeWordformSelection(SelLevInfo[] rgvsli)
        {
            // top prop is atomic, leave index 0. Specifies displaying the contents of the Text.
            IVwSelection sel;

            try
            {
                // InterlinPrintChild and InterlinTaggingChild have no Sandbox,
                // so they need a "real" interlinear text selection.
                sel = RootBox.MakeTextSelInObj(0, rgvsli.Length, rgvsli, 0, null,
                                               false, false, false, true, true);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.StackTrace);
                return(null);
            }
            return(sel);
        }
Exemple #10
0
 private void SetSandboxLocation()
 {
     m_rootb.Reconstruct();
     using (new HoldGraphics(this))
     {
         Rectangle rcSrcRoot;
         Rectangle rcDstRoot;
         GetCoordRects(out rcSrcRoot, out rcDstRoot);
         SelLevInfo[] rgvsli = new SelLevInfo[1];
         //rgvsli[1].ihvo = 0; // first morpheme bundle
         //rgvsli[1].tag = (int)WfiAnalysis.WfiAnalysisTags.kflidMorphBundles;
         rgvsli[0].ihvo = 0;
         rgvsli[0].tag  = MeVirtualHandler.InstallMe(Cache.VwCacheDaAccessor).Tag;
         IVwSelection sel = null;
         sel = RootBox.MakeTextSelInObj(0, rgvsli.Length, rgvsli, 0, null, true, false, false, false, false);
         if (sel == null)
         {
             Debug.WriteLine("Could not make selection in SetSandboxLocation");
             m_tryAWordSandbox.Left = 150;
             return;                     // can't position it accurately.
         }
         Rect rcPrimary, rcSec;
         bool fSplit, fEndBeforeAnchor;
         sel.Location(m_graphicsManager.VwGraphics, rcSrcRoot, rcDstRoot, out rcPrimary, out rcSec,
                      out fSplit, out fEndBeforeAnchor);
         if (m_vc.RightToLeft)
         {
             m_tryAWordSandbox.Left = rcPrimary.right - m_tryAWordSandbox.Width;
             m_labelWidth           = m_rootb.Width - rcPrimary.right;
         }
         else
         {
             m_tryAWordSandbox.Left = rcPrimary.left;
             m_labelWidth           = rcPrimary.left;
         }
     }
 }