/// <summary>
        /// Handles the xWorks message to insert a new PartOfSpeech.
        /// Invoked by the RecordClerk via a main menu.
        /// </summary>
        /// <param name="argument">The xCore Command object.</param>
        /// <returns>true, if we handled the message, otherwise false, if there was an unsupported 'classname' parameter</returns>
        public override bool OnDialogInsertItemInVector(object argument)
        {
            CheckDisposed();

            Debug.Assert(argument != null && argument is XCore.Command);
            string className = XmlUtils.GetOptionalAttributeValue(
                (argument as XCore.Command).Parameters[0], "className");

            if (className == null || className != "PartOfSpeech")
            {
                return(false);
            }

            using (var dlg = new MasterCategoryListDlg())
            {
                FdoCache cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
                Debug.Assert(cache != null);
                var owningObj = m_mediator.PropertyTable.GetValue("ActiveClerkOwningObject") as ICmObject;
                dlg.SetDlginfo((owningObj is ICmPossibilityList) ? owningObj as ICmPossibilityList : cache.LangProject.PartsOfSpeechOA, m_mediator, true, null);
                switch (dlg.ShowDialog((Form)m_mediator.PropertyTable.GetValue("window")))
                {
                case DialogResult.OK:                         // Fall through.
                case DialogResult.Yes:
                    // This is the equivalent functionality, but is deferred processing.
                    // This is done so that the JumpToRecord can be processed last.
                    m_mediator.BroadcastMessageUntilHandled("JumpToRecord", dlg.SelectedPOS.Hvo);
                    break;
                }
            }
            return(true);            // We "handled" the message, regardless of what happened.
        }
Example #2
0
        /// <summary>
        /// Handle the context menu for inserting a POS.
        /// </summary>
        /// <param name="mediator"></param>
        /// <param name="classId"></param>
        /// <param name="hvoOwner"></param>
        /// <param name="flid"></param>
        /// <param name="insertionPosition"></param>
        /// <returns></returns>
        public new static PartOfSpeechUi CreateNewUiObject(Mediator mediator, uint classId, int hvoOwner, int flid, int insertionPosition)
        {
            PartOfSpeechUi posUi = null;

            using (MasterCategoryListDlg dlg = new MasterCategoryListDlg())
            {
                FdoCache cache = (FdoCache)mediator.PropertyTable.GetValue("cache");
                Debug.Assert(cache != null);
                IPartOfSpeech newOwner = PartOfSpeech.CreateFromDBObject(cache, hvoOwner);
                dlg.SetDlginfo(newOwner.OwningList, mediator, true, newOwner);
                switch (dlg.ShowDialog((Form)mediator.PropertyTable.GetValue("window")))
                {
                case DialogResult.OK:                         // Fall through.
                case DialogResult.Yes:
                    posUi = new PartOfSpeechUi(dlg.SelectedPOS);
                    mediator.SendMessage("JumpToRecord", dlg.SelectedPOS.Hvo);
                    break;
                }
            }
            return(posUi);
        }
Example #3
0
        /// <summary>
        /// Handle the context menu for inserting a POS.
        /// </summary>
        /// <param name="mediator"></param>
        /// <param name="propertyTable"></param>
        /// <param name="classId"></param>
        /// <param name="hvoOwner"></param>
        /// <param name="flid"></param>
        /// <param name="insertionPosition"></param>
        /// <returns></returns>
        public new static PartOfSpeechUi CreateNewUiObject(Mediator mediator, PropertyTable propertyTable, int classId, int hvoOwner, int flid, int insertionPosition)
        {
            PartOfSpeechUi posUi = null;

            using (MasterCategoryListDlg dlg = new MasterCategoryListDlg())
            {
                LcmCache cache = propertyTable.GetValue <LcmCache>("cache");
                Debug.Assert(cache != null);
                var newOwner = cache.ServiceLocator.GetInstance <IPartOfSpeechRepository>().GetObject(hvoOwner);
                dlg.SetDlginfo(newOwner.OwningList, mediator, propertyTable, true, newOwner);
                switch (dlg.ShowDialog(propertyTable.GetValue <Form>("window")))
                {
                case DialogResult.OK:                         // Fall through.
                case DialogResult.Yes:
                    posUi = new PartOfSpeechUi(dlg.SelectedPOS);
                    mediator.SendMessage("JumpToRecord", dlg.SelectedPOS.Hvo);
                    break;
                }
            }
            return(posUi);
        }