Beispiel #1
0
        /// <summary>
        /// Sets the title string to an appropriate default when nothing is specified in the xml configuration for the view
        /// </summary>
        protected virtual void SetInfoBarText()
        {
            if (m_informationBar == null)
            {
                return;
            }
            string className = StringTable.Table.GetString("No Record", "Misc");

            if (Clerk.CurrentObject != null)
            {
                using (var uiObj = CmObjectUi.MakeUi(Clerk.CurrentObject))
                    className = uiObj.DisplayNameOfClass;
            }
            else
            {
                string emptyTitleId = XmlUtils.GetAttributeValue(m_configurationParameters, "emptyTitleId");
                if (!String.IsNullOrEmpty(emptyTitleId))
                {
                    string titleStr;
                    XmlViewsUtils.TryFindString("EmptyTitles", emptyTitleId, out titleStr);
                    if (titleStr != "*" + emptyTitleId + "*")
                    {
                        className = titleStr;
                    }
                    Clerk.UpdateStatusBarRecordNumber(titleStr);
                }
            }
            // This code:  ((IPaneBar)m_informationBar).Text = className;
            // causes about 47 of the following exceptions when executed in Flex.
            // First-chance exception at 0x4ed9b280 in Flex.exe: 0xC0000005: Access violation writing location 0x00f90004.
            // The following code doesn't cause the exception, but neither one actually sets the Text to className,
            // so something needs to be changed somewhere. It doesn't enter "override string Text" in PaneBar.cs
            ((IPaneBar)m_informationBar).Text = className;
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fdoCache"></param>
        /// <returns></returns>
        public static ITsTextProps PartOfSpeechTextProperties(LcmCache fdoCache, bool inAnalysisLine, bool fUseStyleSheet)
        {
            int          color = (int)CmObjectUi.RGB(Color.Green);
            ITsPropsBldr bldr  = TsStringUtils.MakePropsBldr();

            if (!fUseStyleSheet)
            {
                bldr.SetIntPropValues((int)FwTextPropType.ktptFontSize,
                                      (int)FwTextPropVar.ktpvMilliPoint, (int)(s_baseFontSize * 1000 * .8));
            }
            bldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                  (int)FwTextPropVar.ktpvDefault, fdoCache.DefaultAnalWs);
            //			bldr.SetIntPropValues((int)FwTextPropType.ktptItalic,
            //				(int)FwTextPropVar.ktpvEnum,
            //				(int)FwTextToggleVal.kttvInvert);

            if (inAnalysisLine)
            {
                bldr.SetIntPropValues((int)FwTextPropType.ktptSuperscript,
                                      (int)FwTextPropVar.ktpvEnum,
                                      (int)FwSuperscriptVal.kssvSub);
            }



            bldr.SetIntPropValues((int)FwTextPropType.ktptForeColor,
                                  (int)FwTextPropVar.ktpvDefault, color);
            return(bldr.GetTextProps());
        }
Beispiel #3
0
        public void OnFwRightMouseClick(SimpleRootSite sender, FwRightMouseClickEventArgs e)
        {
            CheckDisposed();

            var browseView = sender as XmlBrowseView;

            if (browseView != null)
            {
                IVwSelection     sel = e.Selection;
                int              clev = sel.CLevels(false);    // anchor
                int              hvoRoot, tag, ihvo, cpropPrevious;
                IVwPropertyStore vps;
                sel.PropInfo(false, clev - 1, out hvoRoot, out tag, out ihvo, out cpropPrevious, out vps);
                // First make the selection so it will be highlighted before the context menu popup.
                if (browseView.SelectedIndex != ihvo)                 // No sense in waking up the beast for no reason.
                {
                    browseView.SelectedIndex = ihvo;
                }
                int hvo = browseView.HvoAt(ihvo);
                if (Cache.ServiceLocator.IsValidObjectId(hvo))                 // may be fake one from decorator.
                {
                    CmObjectUi ui = CmObjectUi.MakeUi(Cache, hvo);             // Disposes of itself when menu closes since true passed in lext line.
                    if (ui != null)
                    {
                        ui.Mediator    = m_mediator;
                        ui.PropTable   = m_propertyTable;
                        e.EventHandled = ui.HandleRightClick(m_mediator, m_propertyTable, sender, true, "mnuBrowseView");
                    }
                }
            }
        }
Beispiel #4
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);
        }
Beispiel #5
0
        public void OnFwRightMouseClick(SimpleRootSite sender, FwRightMouseClickEventArgs e)
        {
            CheckDisposed();

            XmlBrowseView browseView = sender as XmlBrowseView;

            if (browseView != null)
            {
                IVwSelection     sel = e.Selection;
                int              clev = sel.CLevels(false);    // anchor
                int              hvoRoot, tag, ihvo, cpropPrevious;
                IVwPropertyStore vps;
                sel.PropInfo(false, clev - 1, out hvoRoot, out tag, out ihvo, out cpropPrevious, out vps);
                // First make the selection so it will be highlighted before the context menu popup.
                if (browseView.SelectedIndex != ihvo)                 // No sense in waking up the beast for no reason.
                {
                    browseView.SelectedIndex = ihvo;
                }
                int        hvo = browseView.HvoAt(ihvo);
                CmObjectUi ui  = CmObjectUi.MakeUi(Cache, hvo);
                if (ui != null)
                {
                    e.EventHandled = ui.HandleRightClick(m_mediator, sender, true, "mnuBrowseView");
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// Have the main FLEx window jump to the appropriate item
        /// </summary>
        /// <param name="hvo">item whose parent will indcate where to jump to</param>
        public void JumpToToolBasedOnHvo(int hvo)
        {
            if (hvo == 0)
            {
                return;
            }
            string    sTool         = null;
            int       parentClassId = 0;
            ICmObject obj           = CmObject.CreateFromDBObject(m_cache, hvo);

            switch (obj.ClassID)
            {
            case MoForm.kclsidMoForm:                                  // fall through
            case MoAffixAllomorph.kclsidMoAffixAllomorph:              // fall through
            case MoStemAllomorph.kclsidMoStemAllomorph:                // fall through
            case MoInflAffMsa.kclsidMoInflAffMsa:                      // fall through
            case MoDerivAffMsa.kclsidMoDerivAffMsa:                    // fall through
            case MoUnclassifiedAffixMsa.kclsidMoUnclassifiedAffixMsa:  // fall through
            case MoStemMsa.kclsidMoStemMsa:                            // fall through
            case MoMorphSynAnalysis.kclsidMoMorphSynAnalysis:
            case MoAffixProcess.kclsidMoAffixProcess:
                sTool         = "lexiconEdit";
                parentClassId = LexEntry.kclsidLexEntry;
                break;

            case MoInflAffixSlot.kclsidMoInflAffixSlot:                              // fall through
            case MoInflAffixTemplate.kclsidMoInflAffixTemplate:                      // fall through
            case PartOfSpeech.kclsidPartOfSpeech:
                sTool         = "posEdit";
                parentClassId = PartOfSpeech.kclsidPartOfSpeech;
                break;

            // still need to test compound rule ones
            case MoCoordinateCompound.kclsidMoCoordinateCompound:
            case MoEndoCompound.kclsidMoEndoCompound:
            case MoExoCompound.kclsidMoExoCompound:
                sTool         = "compoundRuleAdvancedEdit";
                parentClassId = obj.ClassID;
                break;

            case PhRegularRule.kclsidPhRegularRule:                     // fall through
            case PhMetathesisRule.kclsidPhMetathesisRule:
                sTool         = "PhonologicalRuleEdit";
                parentClassId = obj.ClassID;
                break;
            }
            if (parentClassId <= 0)
            {
                return;                 // do nothing
            }
            int parentHvo = CmObjectUi.GetParentOfClass(m_cache, hvo, parentClassId);

            if (parentHvo <= 0)
            {
                return;                 // do nothing
            }
            m_mediator.PostMessage("FollowLink",
                                   SIL.FieldWorks.FdoUi.FwLink.Create(sTool, m_cache.GetGuidFromId(parentHvo), m_cache.ServerName, m_cache.DatabaseName));
        }
Beispiel #7
0
        public void SetDlgInfo(CmObjectUi obj, FdoCache cache, Mediator mediator)
        {
            CheckDisposed();

            Debug.Assert(obj != null);
            Debug.Assert(obj.Object != null);

            SetDlgInfo(obj, cache, mediator, cache.TsStrFactory.MakeString(" ", cache.DefaultUserWs));
        }
        /// <summary>
        /// Have the main FLEx window jump to the appropriate item
        /// </summary>
        /// <param name="hvo">item whose parent will indcate where to jump to</param>
        public void JumpToToolBasedOnHvo(int hvo)
        {
            if (hvo == 0)
            {
                return;
            }
            string    sTool         = null;
            int       parentClassId = 0;
            ICmObject cmo           = m_cache.ServiceLocator.GetObject(hvo);

            switch (cmo.ClassID)
            {
            case MoFormTags.kClassId:                                           // fall through
            case MoAffixAllomorphTags.kClassId:                                 // fall through
            case MoStemAllomorphTags.kClassId:                                  // fall through
            case MoInflAffMsaTags.kClassId:                                     // fall through
            case MoDerivAffMsaTags.kClassId:                                    // fall through
            case MoUnclassifiedAffixMsaTags.kClassId:                           // fall through
            case MoStemMsaTags.kClassId:                                        // fall through
            case MoMorphSynAnalysisTags.kClassId:                               // fall through
            case MoAffixProcessTags.kClassId:
                sTool         = "lexiconEdit";
                parentClassId = LexEntryTags.kClassId;
                break;

            case MoInflAffixSlotTags.kClassId:                          // fall through
            case MoInflAffixTemplateTags.kClassId:                      // fall through
            case PartOfSpeechTags.kClassId:
                sTool         = "posEdit";
                parentClassId = PartOfSpeechTags.kClassId;
                break;

            // still need to test compound rule ones
            case MoCoordinateCompoundTags.kClassId:                     // fall through
            case MoEndoCompoundTags.kClassId:                           // fall through
            case MoExoCompoundTags.kClassId:
                sTool         = "compoundRuleAdvancedEdit";
                parentClassId = cmo.ClassID;
                break;

            case PhRegularRuleTags.kClassId:                                    // fall through
            case PhMetathesisRuleTags.kClassId:
                sTool         = "PhonologicalRuleEdit";
                parentClassId = cmo.ClassID;
                break;
            }
            if (parentClassId <= 0)
            {
                return;                 // do nothing
            }
            cmo = CmObjectUi.GetSelfOrParentOfClass(cmo, parentClassId);
            if (cmo == null)
            {
                return;                 // do nothing
            }
            m_mediator.PostMessage("FollowLink", new FwLinkArgs(sTool, cmo.Guid));
        }
Beispiel #9
0
        public void SetDlgInfo(CmObjectUi obj, FdoCache cache, XCore.Mediator mediator)
        {
            CheckDisposed();

            StringTable strings = mediator.StringTbl;

            m_cache = cache;
            IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);

            Debug.Assert(obj != null);
            Debug.Assert(obj.Object != null);

            Text = String.Format(FdoUiStrings.ksDeleteX, strings.GetString(obj.ClassName, "ClassNames"));

            // Set the s_helpTopic based on the window title and rearrange the buttons if neccesary
            switch (obj.ClassName)
            {
            case "WfiWordform":
                s_helpTopic = "khtpDeleteWordform";
                break;
            }
            if (s_helpTopic != null)
            {
                buttonHelp.Visible = true;
                buttonHelp.Enabled = true;
                this.helpProvider  = new System.Windows.Forms.HelpProvider();
                this.helpProvider.HelpNamespace = FwApp.App.HelpFile;
                this.helpProvider.SetHelpKeyword(this, FwApp.App.GetHelpString(s_helpTopic, 0));
                this.helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic);
            }
            else
            {
                m_deleteButton.Location = m_cancelButton.Location;
                m_cancelButton.Location = buttonHelp.Location;
            }

            //Use an FWTextBox so that strings of different writing systems will
            //be displayed with the correct stylesheet settings.
            m_descriptionBox3.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
            m_descriptionBox3.WritingSystemCode    = m_cache.LangProject.DefaultUserWritingSystem;
            m_descriptionBox3.StyleSheet           = stylesheet;
            ITsIncStrBldr tisb3 = TsIncStrBldrClass.Create();

            tisb3.AppendTsString(obj.Object.DeletionTextTSS);
            m_descriptionBox3.Tss = tisb3.GetString();

            m_descriptionBox4.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
            m_descriptionBox4.WritingSystemCode    = m_cache.LangProject.DefaultUserWritingSystem;
            m_descriptionBox4.StyleSheet           = stylesheet;
            ITsIncStrBldr tisb4 = TsIncStrBldrClass.Create();

            tisb4.AppendTsString(m_cache.MakeUserTss(" "));             //this is the default for m_descriptionBox4
            m_descriptionBox4.Tss = tisb4.GetString();

            m_deleteButton.Enabled = obj.Object.CanDelete;
            label2.Visible         = m_deleteButton.Enabled;
        }
Beispiel #10
0
        public void SetDlgInfo(CmObjectUi obj, LcmCache cache, Mediator mediator, PropertyTable propertyTable)
        {
            CheckDisposed();

            Debug.Assert(obj != null);
            Debug.Assert(obj.Object != null);

            SetDlgInfo(obj, cache, mediator, propertyTable, TsStringUtils.MakeString(" ", cache.DefaultUserWs));
        }
        /// <summary>
        /// This method is called when a user selects Delete Relation on a Lexical Relation slice.
        /// For: Pair relation (eg. Antonym)
        ///     tree relation (parts/whole when deleting a Parts slice)
        /// </summary>
        /// <param name="hvo"></param>
        public void DeleteReference(int hvo)
        {
            CheckDisposed();
            if (hvo <= 0)
            {
                throw new ConfigurationException("Slice:GetObjectHvoForMenusToOperateOn is either messed up or should not have been called, because it could not find the object to be deleted.", m_configurationNode);
            }
            else
            {
                Form mainWindow = (Form)Mediator.PropertyTable.GetValue("window");
                mainWindow.Cursor = Cursors.WaitCursor;
                using (ConfirmDeleteObjectDlg dlg = new ConfirmDeleteObjectDlg())
                {
                    CmObjectUi    ui = CmObjectUi.MakeUi(m_cache, hvo);
                    ILexReference lr = LexReference.CreateFromDBObject(m_cache, hvo);

                    //We need this to determine which kind of relation we are deleting
                    LexRefType lrtOwner =
                        (LexRefType)CmObject.CreateFromDBObject(m_cache, lr.OwnerHVO);

                    int           analWs = m_cache.DefaultAnalWs;
                    int           userWs = m_cache.DefaultUserWs;
                    ITsIncStrBldr tisb   = TsIncStrBldrClass.Create();
                    tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, userWs);

                    switch ((LexRefType.MappingTypes)lrtOwner.MappingType)
                    {
                    case LexRefType.MappingTypes.kmtSenseTree:
                    case LexRefType.MappingTypes.kmtEntryTree:
                    case LexRefType.MappingTypes.kmtEntryOrSenseTree:
                        tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, userWs);
                        tisb.Append(String.Format(LexEdStrings.ksDeleteLexTree, "\x2028"));
                        dlg.SetDlgInfo(ui, m_cache, Mediator, tisb.GetString());
                        break;

                    default:
                        dlg.SetDlgInfo(ui, m_cache, Mediator);
                        break;
                    }

                    if (DialogResult.Yes == dlg.ShowDialog(mainWindow))
                    {
                        lr.DeleteUnderlyingObject();
                        //Update the display because we have removed this slice from the Lexical entry.
                        UpdateForDelete(hvo);

                        mainWindow.Cursor = Cursors.Default;
                    }
                    else                     //If the user selected Cancel in the delete dialog do nothing
                    {
                        mainWindow.Cursor = Cursors.Default;
                        return;
                    }
                }
            }
        }
Beispiel #12
0
        /// <summary>
        /// This method is called when a user selects Delete Relation on a Lexical Relation slice.
        /// For: Pair relation (eg. Antonym)
        ///     tree relation (parts/whole when deleting a Parts slice)
        /// </summary>
        /// <param name="hvo"></param>
        public void DeleteReference(ILexReference lr)
        {
            CheckDisposed();
            if (lr == null)
            {
                throw new ConfigurationException("Slice:GetObjectHvoForMenusToOperateOn is either messed up or should not have been called, because it could not find the object to be deleted.", m_configurationNode);
            }
            else
            {
                var mainWindow = m_propertyTable.GetValue <Form>("window");
                using (new WaitCursor(mainWindow))
                {
                    using (var dlg = new ConfirmDeleteObjectDlg(m_propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider")))
                    {
                        var ui = CmObjectUi.MakeUi(m_cache, lr.Hvo);
                        ui.Mediator  = Mediator;
                        ui.PropTable = m_propertyTable;

                        //We need this to determine which kind of relation we are deleting
                        var lrtOwner = lr.Owner as ILexRefType;

                        var userWs = m_cache.WritingSystemFactory.UserWs;
                        var tisb   = TsStringUtils.MakeIncStrBldr();
                        tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, userWs);

                        switch ((LexRefTypeTags.MappingTypes)lrtOwner.MappingType)
                        {
                        case LexRefTypeTags.MappingTypes.kmtSenseTree:
                        case LexRefTypeTags.MappingTypes.kmtEntryTree:
                        case LexRefTypeTags.MappingTypes.kmtEntryOrSenseTree:
                        case LexRefTypeTags.MappingTypes.kmtSenseUnidirectional:
                        case LexRefTypeTags.MappingTypes.kmtEntryUnidirectional:
                        case LexRefTypeTags.MappingTypes.kmtEntryOrSenseUnidirectional:
                            tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, userWs);
                            tisb.Append(String.Format(LexEdStrings.ksDeleteLexTree, StringUtils.kChHardLB));
                            dlg.SetDlgInfo(ui, m_cache, Mediator, m_propertyTable, tisb.GetString());
                            break;

                        default:
                            dlg.SetDlgInfo(ui, m_cache, Mediator, m_propertyTable);
                            break;
                        }

                        if (DialogResult.Yes == dlg.ShowDialog(mainWindow))
                        {
                            UndoableUnitOfWorkHelper.Do(LexEdStrings.ksUndoDeleteRelation, LexEdStrings.ksRedoDeleteRelation, m_obj, () =>
                            {
                                m_cache.DomainDataByFlid.DeleteObj(lr.Hvo);
                            });
                            //Update the display because we have removed this slice from the Lexical entry.
                            UpdateForDelete(lr);
                        }
                    }
                }
            }
        }
Beispiel #13
0
 public void HandleDeleteMenuItem(Object src, System.EventArgs ea)
 {
     m_cache.DomainDataByFlid.BeginUndoTask(DetailControlsStrings.ksUndoDelete,
                                            DetailControlsStrings.ksRedoDelete);
     using (CmObjectUi ui = CmObjectUi.MakeUi(m_cache, m_hvoDeleteTarget))
     {
         ui.Mediator = m_sliceTreeNode.Slice.ContainingDataTree.Mediator;
         ui.DeleteUnderlyingObject();
     }
     m_cache.DomainDataByFlid.EndUndoTask();
 }
		private void ContextMenuRequested(object sender, ContextMenuRequestedEventArgs e)
		{
			e.Selection.Install();
			ICmObject obj = CurrentObject;

			if (obj != null)
			{
				// we only bother to display the context menu if an item is selected
				using (var ui = new CmObjectUi(obj))
				{
					e.Handled = ui.HandleRightClick(Mediator, this, true, ContextMenuID);
				}
			}
		}
Beispiel #15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strings"></param>
        /// <param name="obj"></param>
        /// <param name="cache"></param>
        /// <param name="mediator"></param>
        /// <param name="tssNote">a second message, in addition to what's in obj.Object.DeletionTextTss</param>
        public void SetDlgInfo(CmObjectUi obj, FdoCache cache, XCore.Mediator mediator, ITsString tssNote)
        {
            CheckDisposed();

            Debug.Assert(obj != null);
            Debug.Assert(obj.Object != null);

            //do not change the order of the following two lines of code
            //because m_descritiptionBox4.Tss is given a default value first.
            SetDlgInfo(obj, cache, mediator);
            ITsIncStrBldr tisb = TsIncStrBldrClass.Create();

            tisb.AppendTsString(tssNote);
            m_descriptionBox4.Tss = tisb.GetString();
        }
Beispiel #16
0
        public void DeleteReversalIndex(IReversalIndex ri)
        {
            CheckDisposed();

            var mainWindow = (Form)m_mediator.PropertyTable.GetValue("window");

            using (new WaitCursor(mainWindow))
            {
                using (var dlg = new ConfirmDeleteObjectDlg(m_mediator.HelpTopicProvider))
                {
                    var ui = new CmObjectUi(ri);
                    dlg.SetDlgInfo(ui, Cache, m_mediator);
                    dlg.TopMessage     = LexEdStrings.ksDeletingThisRevIndex;
                    dlg.BottomQuestion = LexEdStrings.ksReallyWantToDeleteRevIndex;
                    if (DialogResult.Yes == dlg.ShowDialog(mainWindow))
                    {
                        ReallyDeleteReversalIndex(ri);
                    }
                }
            }
        }
Beispiel #17
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();
                }
            }
        }
Beispiel #18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fdoCache"></param>
        /// <returns></returns>
        public static ITsTextProps FormTextProperties(LcmCache fdoCache, bool fUseStyleSheet, int wsVern)
        {
            int          color = (int)CmObjectUi.RGB(Color.DarkBlue);
            ITsPropsBldr bldr  = TsStringUtils.MakePropsBldr();

            if (!fUseStyleSheet)
            {
                bldr.SetIntPropValues((int)FwTextPropType.ktptFontSize,
                                      (int)FwTextPropVar.ktpvMilliPoint, s_baseFontSize * 1000);
            }
            bldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                  (int)FwTextPropVar.ktpvDefault, wsVern);
            //			bldr.SetIntPropValues((int)FwTextPropType.ktptBold,
            //				(int)FwTextPropVar.ktpvEnum,
            //				(int)FwTextToggleVal.kttvInvert);
            //			bldr.SetIntPropValues((int)FwTextPropType.ktptItalic,
            //				(int)FwTextPropVar.ktpvEnum,
            //				(int)FwTextToggleVal.kttvInvert);
            bldr.SetIntPropValues((int)FwTextPropType.ktptForeColor,
                                  (int)FwTextPropVar.ktpvDefault, color);
            return(bldr.GetTextProps());
        }
Beispiel #19
0
        private bool HandleRightClickOnObject(int hvoDummy)
        {
            if (hvoDummy == 0)
            {
                return(false);
            }

            if (m_realEnvs.ContainsKey(hvoDummy))
            {
                // This displays the "Show in Environments list" item in the popup menu, in
                // addition to all the Insert X" items.
                int hvo = m_realEnvs[hvoDummy].Hvo;
                ReferenceCollectionUi ui = new ReferenceCollectionUi(Cache, m_rootObj, m_rootFlid, hvo);
                return(ui.HandleRightClick(Mediator, this, true));
            }
            else
            {
                // We need a CmObjectUi in order to call HandleRightClick().  This won't
                // display the "Show in Environments list" item in the popup menu.
                CmObjectUi ui = new CmObjectUi(m_rootObj);
                return(ui.HandleRightClick(Mediator, this, true, "mnuEnvReferenceChoices"));
            }
        }
Beispiel #20
0
        public static ITsTextProps GlossTextProperties(LcmCache fdoCache, bool inAnalysisLine, bool fUseStyleSheet)
        {
            int          color = (int)CmObjectUi.RGB(Color.DarkRed);
            ITsPropsBldr bldr  = TsStringUtils.MakePropsBldr();

            if (!fUseStyleSheet)
            {
                bldr.SetIntPropValues((int)FwTextPropType.ktptFontSize,
                                      (int)FwTextPropVar.ktpvMilliPoint, s_baseFontSize * 1000);
            }
            bldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                  (int)FwTextPropVar.ktpvDefault, fdoCache.DefaultAnalWs);

            if (inAnalysisLine)
            {
                bldr.SetIntPropValues((int)FwTextPropType.ktptSuperscript,
                                      (int)FwTextPropVar.ktpvEnum,
                                      (int)FwSuperscriptVal.kssvSuper);
            }

            bldr.SetIntPropValues((int)FwTextPropType.ktptForeColor,
                                  (int)FwTextPropVar.ktpvDefault, color);
            return(bldr.GetTextProps());
        }
Beispiel #21
0
        /// <summary>
        /// Change root of Sandbox or create it; Lay it out and figure its size;
        /// tell m_vc the size.
        /// </summary>
        /// <returns></returns>
        private void ChangeOrCreateSandbox(AnalysisOccurrence selected)
        {
            this.SuspendLayout();
            panelSandbox.SuspendLayout();
            if (InterlinDoc != null)
            {
                InterlinDoc.RecordGuessIfNotKnown(selected);
            }
            int color = (int)CmObjectUi.RGB(DefaultBackColor);

            //if this sandbox is presenting a wordform with multiple possible analyses then set the
            //bg color indicator
            if (selected.Analysis.Analysis == null && selected.Analysis.Wordform != null &&
                SandboxBase.GetHasMultipleRelevantAnalyses(selected.Analysis.Wordform))
            {
                color = InterlinVc.MultipleApprovedGuessColor;
            }

            if (m_sandbox == null)
            {
                m_sandbox = CreateNewSandbox(selected);
                m_sandbox.MultipleAnalysisColor = color;
            }
            else
            {
                //set the color before switching so that the color is correct when DisplayWordForm is called
                m_sandbox.MultipleAnalysisColor = color;
                m_sandbox.SwitchWord(selected);
            }
            UpdateButtonState();
            // add the sandbox plus some padding.
            panelSandbox.ResumeLayout();
            this.ResumeLayout();

            SetSandboxSize();
        }
		public void SetDlgInfo(CmObjectUi obj, FdoCache cache, Mediator mediator)
		{
			CheckDisposed();

			Debug.Assert(obj != null);
			Debug.Assert(obj.Object != null);

			SetDlgInfo(obj, cache, mediator, cache.TsStrFactory.MakeString(" ", cache.DefaultUserWs));
		}
Beispiel #23
0
        public void SetDlgInfo(CmObjectUi obj, FdoCache cache, Mediator mediator, ITsString tssNote)
        {
            CheckDisposed();

            if (obj.Mediator == null)
            {
                obj.Mediator = mediator;
            }
            StringTable strings = mediator.StringTbl;

            m_cache = cache;
            IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);

            Debug.Assert(obj != null);
            Debug.Assert(obj.Object != null);

            Text = String.Format(FdoUiStrings.ksDeleteX, obj.DisplayNameOfClass);

            // Set the s_helpTopic based on the window title and rearrange the buttons if neccesary
            switch (obj.ClassName)
            {
            case "WfiWordform":
                s_helpTopic = "khtpDeleteWordform";
                break;
            }
            if (s_helpTopic != null)
            {
                buttonHelp.Visible = true;
                buttonHelp.Enabled = true;
                this.helpProvider  = new HelpProvider();
                this.helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile;
                this.helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(s_helpTopic));
                this.helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
            }
            else
            {
                m_deleteButton.Location = m_cancelButton.Location;
                m_cancelButton.Location = buttonHelp.Location;
            }

            //Use an FWTextBox so that strings of different writing systems will
            //be displayed with the correct stylesheet settings.
            int defUserWs = m_cache.ServiceLocator.WritingSystemManager.UserWs;

            m_descriptionBox3.WritingSystemFactory = m_cache.WritingSystemFactory;
            m_descriptionBox3.WritingSystemCode    = defUserWs;
            m_descriptionBox3.StyleSheet           = stylesheet;
            ITsIncStrBldr tisb3 = TsIncStrBldrClass.Create();

            tisb3.AppendTsString(obj.Object.DeletionTextTSS);
            m_descriptionBox3.Tss = tisb3.GetString();
            // Adjust the dialog size if needed to display the message (FWNX-857).
            int deltaY = GrowTextBox(panel1, m_descriptionBox3);

            panel2.Top += deltaY;

            m_descriptionBox4.WritingSystemFactory = m_cache.WritingSystemFactory;
            m_descriptionBox4.WritingSystemCode    = defUserWs;
            m_descriptionBox4.StyleSheet           = stylesheet;
            ITsIncStrBldr tisb4 = TsIncStrBldrClass.Create();

            tisb4.AppendTsString(tssNote);             //this is the default for m_descriptionBox4
            m_descriptionBox4.Tss = tisb4.GetString();
            GrowTextBox(panel2, m_descriptionBox4);

            m_deleteButton.Enabled = obj.Object.CanDelete;
            label2.Visible         = m_deleteButton.Enabled;
        }
		public void SetDlgInfo(CmObjectUi obj, FdoCache cache, Mediator mediator, ITsString tssNote)
		{

			CheckDisposed();

			if (obj.Mediator == null)
				obj.Mediator = mediator;
			StringTable strings = mediator.StringTbl;
			m_cache = cache;
			IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);

			Debug.Assert(obj != null);
			Debug.Assert(obj.Object != null);

			Text = String.Format(FdoUiStrings.ksDeleteX, obj.DisplayNameOfClass);

			// Set the s_helpTopic based on the window title and rearrange the buttons if neccesary
			switch (obj.ClassName)
			{
				case "WfiWordform":
					s_helpTopic = "khtpDeleteWordform";
					break;
			}
			if (s_helpTopic != null)
			{
				buttonHelp.Visible = true;
				buttonHelp.Enabled = true;
				this.helpProvider = new HelpProvider();
				this.helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile;
				this.helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(s_helpTopic));
				this.helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
			}
			else
			{
				m_deleteButton.Location = m_cancelButton.Location;
				m_cancelButton.Location = buttonHelp.Location;
			}

			//Use an FWTextBox so that strings of different writing systems will
			//be displayed with the correct stylesheet settings.
			int defUserWs = m_cache.ServiceLocator.WritingSystemManager.UserWs;
			m_descriptionBox3.WritingSystemFactory = m_cache.WritingSystemFactory;
			m_descriptionBox3.WritingSystemCode = defUserWs;
			m_descriptionBox3.StyleSheet = stylesheet;
			ITsIncStrBldr tisb3 = TsIncStrBldrClass.Create();
			tisb3.AppendTsString(obj.Object.DeletionTextTSS);
			m_descriptionBox3.Tss = tisb3.GetString();
			// Adjust the dialog size if needed to display the message (FWNX-857).
			int deltaY = GrowTextBox(panel1, m_descriptionBox3);
			panel2.Top += deltaY;

			m_descriptionBox4.WritingSystemFactory = m_cache.WritingSystemFactory;
			m_descriptionBox4.WritingSystemCode = defUserWs;
			m_descriptionBox4.StyleSheet = stylesheet;
			ITsIncStrBldr tisb4 = TsIncStrBldrClass.Create();
			tisb4.AppendTsString(tssNote); //this is the default for m_descriptionBox4
			m_descriptionBox4.Tss = tisb4.GetString();
			GrowTextBox(panel2, m_descriptionBox4);

			m_deleteButton.Enabled = obj.Object.CanDelete;
			label2.Visible = m_deleteButton.Enabled;
		}
        /// <summary>
        /// This method is called when a user selects Delete Relation on a Lexical Relation slice.
        /// For: sequence relations (eg. Calendar)
        ///     collection relations (eg. Synonym)
        ///     tree relation (parts/whole when deleting a Whole slice)
        /// </summary>
        /// <param name="hvo"></param>
        public void DeleteFromReference(ILexReference lr)
        {
            CheckDisposed();
            if (lr == null)
            {
                throw new ConfigurationException("Slice:GetObjectHvoForMenusToOperateOn is either messed up or should not have been called, because it could not find the object to be deleted.", m_configurationNode);
            }
            else
            {
                var mainWindow = (Form)Mediator.PropertyTable.GetValue("window");
                using (new WaitCursor(mainWindow))
                {
                    using (var dlg = new ConfirmDeleteObjectDlg(m_mediator.HelpTopicProvider))
                    {
                        var ui = CmObjectUi.MakeUi(m_cache, lr.Hvo);

                        //We need this to determine which kind of relation we are deleting
                        var lrtOwner = (ILexRefType)lr.Owner;

                        var analWs = lrtOwner.Services.WritingSystems.DefaultAnalysisWritingSystem.Handle;
                        var userWs = m_cache.WritingSystemFactory.UserWs;
                        var tisb   = TsIncStrBldrClass.Create();
                        tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, userWs);

                        switch ((LexRefTypeTags.MappingTypes)lrtOwner.MappingType)
                        {
                        case LexRefTypeTags.MappingTypes.kmtSenseSequence:
                        case LexRefTypeTags.MappingTypes.kmtEntrySequence:
                        case LexRefTypeTags.MappingTypes.kmtEntryOrSenseSequence:
                        case LexRefTypeTags.MappingTypes.kmtEntryOrSenseCollection:
                        case LexRefTypeTags.MappingTypes.kmtEntryCollection:
                        case LexRefTypeTags.MappingTypes.kmtSenseCollection:
                            if (lr.TargetsRS.Count > 2)
                            {
                                tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, userWs);
                                tisb.Append(String.Format(LexEdStrings.ksDeleteSequenceCollectionA,
                                                          StringUtils.kChHardLB.ToString()));
                                tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, analWs);
                                tisb.Append(lrtOwner.ShortName);
                                tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, userWs);
                                tisb.Append(LexEdStrings.ksDeleteSequenceCollectionB);

                                dlg.SetDlgInfo(ui, m_cache, Mediator, tisb.GetString());
                            }
                            else
                            {
                                dlg.SetDlgInfo(ui, m_cache, Mediator);
                            }
                            break;

                        default:
                            dlg.SetDlgInfo(ui, m_cache, Mediator);
                            break;
                        }

                        if (DialogResult.Yes == dlg.ShowDialog(mainWindow))
                        {
                            UndoableUnitOfWorkHelper.Do(LexEdStrings.ksUndoDeleteRelation, LexEdStrings.ksRedoDeleteRelation, m_obj, () =>
                            {
                                //If the user selected Yes, then we need to delete 'this' sense or entry
                                lr.TargetsRS.Remove(m_obj);
                            });
                            //Update the display because we have removed this slice from the Lexical entry.
                            UpdateForDelete(lr);
                        }
                    }
                }
            }
        }
Beispiel #26
0
 internal int LabelRGBFor(InterlinLineSpec spec)
 {
     return((int)CmObjectUi.RGB(LabelColorFor(spec)));
 }