当前位置: 首页>>代码示例>>C#>>正文


C# EA.GetTreeSelectedItem方法代码示例

本文整理汇总了C#中EA.GetTreeSelectedItem方法的典型用法代码示例。如果您正苦于以下问题:C# EA.GetTreeSelectedItem方法的具体用法?C# EA.GetTreeSelectedItem怎么用?C# EA.GetTreeSelectedItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EA的用法示例。


在下文中一共展示了EA.GetTreeSelectedItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: annotateWithCDE

        public static void annotateWithCDE(EA.Repository m_Repository, QueryServiceControl.QueryServiceManager.dataelement de)
        {
            object item;
            const string CDEREF = "CDERef";
            const string PREFNAME = "preferred name";

            try
            {
                string id = de.names.id;
                string name = de.names.preferred;

                EA.ObjectType type = m_Repository.GetTreeSelectedItem(out item);
                if (type != EA.ObjectType.otAttribute)
                {
                    MessageBox.Show("No class attribute has been selected in the Project Browser", "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                EA.Attribute attr = (EA.Attribute)item;

                //string txt = "Container["+attr.Container;
                //txt += "]\nContainment["+attr.Containment;
                //txt += "]\nDefault["+attr.Default;
                //txt += "]\nParentID["+attr.ParentID;
                //txt += "]\nPos["+attr.Pos;
                //txt += "]\nStereotype["+attr.Stereotype;
                //txt += "]\nStereotypeEx["+attr.StereotypeEx;
                //txt += "]\nStyle["+attr.Style;
                //txt += "]\nStyleEx["+attr.StyleEx;
                //txt += "]\n";
                //MessageBox.Show(txt);

                EA.Collection tvs = attr.TaggedValues;

                if (tagExists(attr.TaggedValues, CDEREF))
                {
                    //DialogResult dg = MessageBox.Show(
                    //    el.Name + " already has a " + CDEREF + " annotation. Replace?",
                    //    "Confirm", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    //if (dg == DialogResult.Cancel)
                    //    return;
                    MessageBox.Show(attr.Name + " already has a " + CDEREF + " annotation. Please remove and try again.");
                    return;
                }

                if (tagExists(attr.TaggedValues, PREFNAME))
                {
                    MessageBox.Show(attr.Name + " already has a " + PREFNAME + " annotation. Please remove and try again.");
                    return;
                }

                EAUtil.addTaggedValue(CDEREF, id, attr);
                EAUtil.addTaggedValue(PREFNAME, name, attr);

                //
                // All done, just display a successful message window
                //
                string attrName = "";
                EA.Element pel = m_Repository.GetElementByID(attr.ParentID);
                if (pel != null && pel.Name != null && pel.Name.Length > 0)
                    attrName = pel.Name + ".";
                attrName += attr.Name;

                MessageBox.Show("Attribute [" + attrName + "] successfully annotated with:\n\n"
                    + CDEREF + " =>   " + id + "\n"
                    + PREFNAME + " =>   " + name + "\n",
                    "Success",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
            }
            catch(Exception exp)
            {
                MessageBox.Show("Error annotating with CDE. " + exp.Message);
            }
        }
开发者ID:NCIP,项目名称:cagrid-grid-incubation,代码行数:76,代码来源:EAUtil.cs

示例2: ShowElementDetails

        /*
        private void ShowElementDetails(EA.Repository repository)
        {
            if (!SelectedElement(repository))
            {
                MessageBox.Show("No element selected");
            }

            object item;
            EA.ObjectType t = repository.GetTreeSelectedItem(out item);
            EA.Diagram r = (EA.Diagram)item;
            string s = "Author: " + r.Author + "\n";
            s += "CreatedDate: " + r.CreatedDate + "\n";
            s += "DiagramGUID: " + r.DiagramGUID + "\n";
            s += "ExtendedStyle: " + r.ExtendedStyle + "\n";
            s += "MetaType: " + r.MetaType + "\n";
            s += "Name: " + r.Name + "\n";
            s += "Notes: " + r.Notes + "\n";
            s += "ObjectType: " + r.ObjectType.ToString() + "\n";
            s += "Orientation: " + r.Orientation + "\n";
            s += "Stereotype: " + r.Stereotype + "\n";
            s += "StereotypeEx: " + r.StereotypeEx + "\n";
            s += "StyleEx: " + r.StyleEx + "\n";
            s += "Swimlanes: " + r.Swimlanes + "\n";
            s += "Type: " + r.Type + "\n";
            s += "Version: " + r.Version + "\n";
            MessageBox.Show(s);

            EA.DiagramObject dObj = (EA.DiagramObject)r.SelectedObjects.GetAt(0);
            EA.Element el = repository.GetElementByID(dObj.ElementID);

            s = "Abstract: " + el.Abstract + "\n";
            s += "ActionFlags: " + el.ActionFlags + "\n";
            s += "Alias: " + el.Alias + "\n";
            s += "Author: " + el.Author + "\n";
            s += "ClassifierName: " + el.ClassifierName + "\n";
            s += "ClassifierType: " + el.ClassifierType + "\n";
            s += "Complexity: " + el.Complexity + "\n";
            s += "Difficulty: " + el.Difficulty + "\n";
            s += "ElementGUID: " + el.ElementGUID + "\n";
            s += "EventFlags: " + el.EventFlags + "\n";
            s += "ExtensionPoints: " + el.ExtensionPoints + "\n";
            s += "Genfile: " + el.Genfile + "\n";
            s += "Genlinks: " + el.Genlinks + "\n";
            s += "Gentype: " + el.Gentype + "\n";
            s += "MetaType: " + el.MetaType + "\n";
            s += "Multiplicity: " + el.Multiplicity + "\n";
            s += "Name: " + el.Name + "\n";
            s += "Notes: " + el.Notes + "\n";
            s += "Phase: " + el.Phase + "\n";
            s += "Priority: " + el.Priority + "\n";
            s += "Status: " + el.Status + "\n";
            s += "Stereotype: " + el.Stereotype + "\n";
            s += "StereotypeEx: " + el.StereotypeEx + "\n";
            s += "StyleEx: " + el.StyleEx + "\n";
            s += "Tag: " + el.Tag + "\n";
            s += "Type: " + el.Type + "\n";
            s += "Version: " + el.Version + "\n";
            s += "Visibility: " + el.Visibility + "\n";
            MessageBox.Show(s);
        }
        */
        private bool SelectedElement(EA.Repository repository)
        {
            try
            {
                object item;
                EA.ObjectType t = repository.GetTreeSelectedItem(out item);
                EA.Diagram r = (EA.Diagram)item;
                if (r.SelectedObjects.Count != 1)
                {
                    return false;
                }
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
开发者ID:NCIP,项目名称:cagrid-grid-incubation,代码行数:80,代码来源:Main.cs

示例3: insertConceptRef

        public static void insertConceptRef(EA.Repository m_Repository, QueryServiceControl.QueryServiceManager.concept concept)
        {
            try
            {
                string id = concept.names.id;
                if (id.StartsWith("http:"))
                {
                    id = id.Substring(id.IndexOf("#") + 1);
                }
                else
                {
                    id = id.Substring(id.LastIndexOf("-") + 1);
                }

                object item;
                EA.ObjectType t = m_Repository.GetTreeSelectedItem(out item);

                if (t.ToString() == "otDiagram")
                {
                    MessageBox.Show("Please select an package or element in the Project Browser.");
                }
                else if (t.ToString() == "otElement")
                {
                    EA.Element el = (EA.Element)item;
                    string note = el.Notes;
                    if (note.Contains("ConceptRefs: ["))
                    {
                        if (!note.Substring(note.IndexOf("ConceptRefs: [") + 14).Replace("])", "").Contains(id))
                        {
                            el.Notes = note.Substring(0, note.IndexOf("ConceptRefs: [") + 14) + note.Substring(note.IndexOf("ConceptRefs: [") + 14).Replace("])", ", " + id + "])");
                        }
                    }
                    else
                    {
                        el.Notes += " (ConceptRefs: [" + id + "])";
                    }
                    el.Update();
                    el.Refresh();
                    MessageBox.Show("Concept reference, " + id + ", inserted to selected element.");
                }
                else if (t.ToString() == "otPackage")
                {
                    EA.Package pkg = (EA.Package)item;
                    string note = pkg.Notes;
                    if (note.Contains("ConceptRefs: ["))
                    {
                        if (!note.Substring(note.IndexOf("ConceptRefs: [") + 14).Replace("])", "").Contains(id))
                        {
                            pkg.Notes = note.Substring(0, note.IndexOf("ConceptRefs: [") + 14) + note.Substring(note.IndexOf("ConceptRefs: [") + 14).Replace("])", ", " + id + "])");
                        }
                    }
                    else
                    {
                        pkg.Notes += " (ConceptRefs: [" + id + "])";
                    }
                    pkg.Update();
                    MessageBox.Show("Concept reference, " + id + ", inserted to selected package.");
                }
                else
                {
                    MessageBox.Show("Please select a valid element (class, package) for the concept reference to be inserted into.");
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show("Error inserting concept reference. " + exp.Message);
            }
        }
开发者ID:NCIP,项目名称:cagrid-grid-incubation,代码行数:68,代码来源:EAUtil.cs

示例4: IsModelOrPackageSelected

 private static bool IsModelOrPackageSelected(EA.Repository repository)
 {
     if (IsProjectOpen(repository))
     {
         object item;
         EA.ObjectType objectType = repository.GetTreeSelectedItem(out item);
         return (objectType == EA.ObjectType.otModel ||
                 objectType == EA.ObjectType.otPackage);
     } else {
         return false;
     }
 }
开发者ID:johnulist,项目名称:EnterpriseArchitect_ReqIF_AddIn,代码行数:12,代码来源:AddIn.cs


注:本文中的EA.GetTreeSelectedItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。