Esempio n. 1
0
        /// <summary>
        /// a  factory method for creating the correct type of object label, depending on the
        /// class of the object
        /// </summary>
        public static ObjectLabel CreateObjectLabel(FdoCache cache, ICmObject obj, string displayNameProperty, string displayWs)
        {
            if (obj == null)
            {
                return(new NullObjectLabel(cache));
            }

            var classId = obj.ClassID;

            return(cache.ClassIsOrInheritsFrom(classId, CmPossibilityTags.kClassId)
                                        ? new CmPossibilityLabel(cache, obj as ICmPossibility, displayNameProperty, displayWs)
                                        : (MoInflClassTags.kClassId == classId
                                                ? new MoInflClassLabel(cache, obj as IMoInflClass, displayNameProperty, displayWs)
                                                : new ObjectLabel(cache, obj, displayNameProperty, displayWs)));
        }
        private void m_pOSPopupTreeManager_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            // Todo: user selected a part of speech.
            // Arrange to turn all relevant items blue.
            // Remember which item was selected so we can later 'doit'.
            if (e.Node == null)
            {
                m_selectedHvo   = 0;
                m_selectedLabel = "";
            }
            else
            {
                int hvo  = (e.Node as HvoTreeNode).Hvo;
                int clid = m_cache.GetClassOfObject(hvo);
                if (m_cache.ClassIsOrInheritsFrom((uint)clid, (uint)FsFeatStruc.kclsidFsFeatStruc))
                {
                    m_selectedHvo   = hvo;
                    m_selectedLabel = e.Node.Text;
                }
                else
                {
                    m_selectedHvo   = 0;
                    m_selectedLabel = "";
                    m_tree.Text     = "";
                }
            }
            if (ControlActivated != null)
            {
                ControlActivated(this, new EventArgs());
            }

            // Tell the parent control that we may have changed the selected item so it can
            // enable or disable the Apply and Preview buttons based on the selection.
            if (ValueChanged != null)
            {
                ValueChanged(this, new FwObjectSelectionEventArgs(m_selectedHvo));
            }
        }