Esempio n. 1
0
        public static EAAPI.Element AddEmbeddedElement(this EAAPI.Element parent, EAAPI.Repository repository,
                                                       string name, string type)
        {
            EAAPI.Element result = null;

            if (string.IsNullOrEmpty(name))
            {
                name = "empty";
            }

            if (parent.Type == "Package")
            {
                EAAPI.Package package = repository.GetPackageByGuid(parent.ElementGUID) as EAAPI.Package;
                result = package.AddElement(name, type);
            }
            else
            {
                EAAPI.Element newElement = (EAAPI.Element)parent.Elements.AddNew(name, type);
                if (!newElement.Update())
                {
                    Debug.WriteLine(newElement.GetLastError());
                }
                parent.Elements.Refresh();

                result = newElement;
            }

            return(result);
        }
Esempio n. 2
0
        public static void SetRunStateValue(this EAAPI.Element element, string variableName, string value, string operation)
        {
            if (variableName != null && variableName != "")
            {
                Dictionary <string, ObjectRunState> runStates = ParseRunStateString(element.RunState);

                if (value != null && value != "")
                {
                    if (runStates.ContainsKey(variableName))
                    {
                        runStates[variableName].Value    = value;
                        runStates[variableName].Operator = operation;
                    }
                    else
                    {
                        ObjectRunState runState = new ObjectRunState();
                        runState.Name     = variableName;
                        runState.Value    = value;
                        runState.Operator = operation;
                        runStates.Add(variableName, runState);
                    }
                }
                else
                {
                    if (runStates.ContainsKey(variableName))
                    {
                        runStates.Remove(variableName);
                    }
                }
                element.RunState = CreateRunStateString(runStates);
                element.Update();
            }
        }
        public static EAAPI.Element AddElement(this EAAPI.Package parentPackage, string name, string type)
        {
            EAAPI.Element newElement = (EAAPI.Element)parentPackage.Elements.AddNew(name, type);

            newElement.Update();
            parentPackage.Elements.Refresh();
            parentPackage.Element.Refresh();

            return(newElement);
        }
        public static EAAPI.Element AddEndNode(this EAAPI.Package parent)
        {
            EAAPI.Element result = (EAAPI.Element)parent.Elements.AddNew("End", "StateNode");

            result.Subtype = 101;

            result.Update();

            parent.Elements.Refresh();
            parent.Element.Refresh();
            return(result);
        }
Esempio n. 5
0
        public static EAAPI.Element Copy(this EAAPI.Element source, EAAPI.Package targetPackage)
        {
            EAAPI.Element targetElement = (EAAPI.Element)targetPackage.Elements.AddNew(source.Name, source.Type);

            targetElement.ClassifierID = source.ClassifierID;
            targetElement.Stereotype   = source.Stereotype;

            if (source.Type == "Part")
            {
                targetElement.PropertyType = source.PropertyType;
            }

            /*
             * if (source.Type == "Action")
             * {
             *  for (int i = 0; i < source.Elements.Count; i++)
             *  {
             *      EA.Element sourceEmbeddedEl = (EA.Element) source.Elements.GetAt((short)i);
             *      EA.Element embeddedEl = (EA.Element) el.Elements.AddNew(sourceEmbeddedEl.Name, sourceEmbeddedEl.Type);
             *      embeddedEl.ClassfierID = sourceEmbeddedEl.ClassfierID;
             *      embeddedEl.Stereotype = sourceEmbeddedEl.Stereotype;
             *
             *      embeddedEl.Update();
             *      el.Elements.Refresh();
             *  }
             * }
             */

            // copy tagged values
            for (short i = 0; i < source.TaggedValues.Count; i++)
            {
                EAAPI.TaggedValue sourceTag = (EAAPI.TaggedValue)source.TaggedValues.GetAt(i);
                EAAPI.TaggedValue targetTag = (EAAPI.TaggedValue)targetElement.TaggedValues.AddNew(sourceTag.Name, sourceTag.Value);
                targetTag.Update();
            }

            targetElement.TaggedValues.Refresh();

            targetElement.Update();


            targetPackage.Elements.Refresh();
            targetPackage.Element.Refresh();

            return(targetElement);
        }
Esempio n. 6
0
 public static void SetBorderColor(this EAAPI.Element element, int color)
 {
     element.SetAppearance(1, 2, color);
     element.Update();
 }
Esempio n. 7
0
 public static void SetBackgroundColor(this EAAPI.Element element, int color)
 {
     element.SetAppearance(1, 0, color);
     element.Update();
 }