示例#1
0
        /// <summary>
        /// Handle a right mouse up, invoking an appropriate context menu.
        /// </summary>
        /// <param name="pt"></param>
        /// <param name="rcSrcRoot"></param>
        /// <param name="rcDstRoot"></param>
        /// <returns></returns>
        protected override bool DoContextMenu(IVwSelection sel, Point pt, Rectangle rcSrcRoot, Rectangle rcDstRoot)
        {
            // Allow base method to handle spell check problems, if any.
            if (base.DoContextMenu(sel, pt, rcSrcRoot, rcDstRoot))
            {
                return(true);
            }

            XWindow mainWind = this.ParentForm as XWindow;

            if (mainWind == null || sel == null)
            {
                return(false);
            }
            ITsString tssWord;

            sel.GrowToWord().GetSelectionString(out tssWord, " ");
            TemporaryColleagueParameter tempColleague = null;

            if (tssWord != null && !string.IsNullOrEmpty(tssWord.Text))
            {
                // We can have a WfiWordformUi as an additional colleague to handle more menu items.
                // The temporaray colleague handles adding and removing it.
                int form = WfiWordform.FindOrCreateWordform(Cache, tssWord, true);

                CmObjectUi ui = CmObjectUi.MakeUi(Cache, form);
                ui.Mediator   = m_mediator;
                tempColleague = new TemporaryColleagueParameter(m_mediator, ui, false);
            }

            mainWind.ShowContextMenu("mnuIText-RawText", new Point(Cursor.Position.X, Cursor.Position.Y),
                                     tempColleague, null);
            return(true);
        }
示例#2
0
        /// <summary>
        /// Handle a right mouse up, invoking an appropriate context menu.
        /// </summary>
        /// <param name="sel"></param>
        /// <param name="pt"></param>
        /// <param name="rcSrcRoot"></param>
        /// <param name="rcDstRoot"></param>
        /// <returns></returns>
        protected override bool DoContextMenu(IVwSelection sel, Point pt, Rectangle rcSrcRoot, Rectangle rcDstRoot)
        {
            // Allow base method to handle spell check problems, if any.
            if (base.DoContextMenu(sel, pt, rcSrcRoot, rcDstRoot))
            {
                return(true);
            }

            var mainWind = ParentForm as XWindow;

            if (mainWind == null || sel == null)
            {
                return(false);
            }
            CmObjectUi ui = null;

            try
            {
                TemporaryColleagueParameter tempColleague = null;
                IWfiWordform wordform;
                if (GetSelectedWordform(m_rootb.Selection, out wordform))
                {
                    ui            = CmObjectUi.MakeUi(Cache, wordform.Hvo);
                    ui.Mediator   = m_mediator;
                    ui.PropTable  = m_propertyTable;
                    tempColleague = new TemporaryColleagueParameter(m_mediator, ui, false);
                }
                mainWind.ShowContextMenu("mnuIText-RawText", new Point(Cursor.Position.X, Cursor.Position.Y),
                                         tempColleague, null);

                return(true);
            }
            finally
            {
                if (ui != null)
                {
                    ui.Dispose();
                }
            }
        }