コード例 #1
0
        public static void SynchronizeTaggedValues(EA.Repository rep)
        {
            // over all selected elements
            EaDiagram curDiagram = new EaDiagram(rep);

            if (curDiagram.Dia == null)
            {
                return;
            }
            int indexLast = curDiagram.SelElements.Count - 1;

            if (indexLast < 0)
            {
                return;
            }

            EA.Element elLast   = curDiagram.SelElements[0];
            string     stereoEx = "";



            // over all elements, skip first element because that is the property template
            for (int i = 1; i <= indexLast; i++)
            {
                // synchronize all stereotypes
                if (stereoEx != curDiagram.SelElements[i].StereotypeEx)
                {
                    stereoEx = curDiagram.SelElements[i].StereotypeEx;
                    TaggedValue.ElTagValue elTagValues = new TaggedValue.ElTagValue(elLast, stereoEx);
                    elTagValues.SyncTaggedValues(rep, curDiagram.SelElements[i]);
                }
            }
        }
コード例 #2
0
        public static void CopyTaggedValues(EA.Repository rep)
        {
            // over all selected elements
            EaDiagram curDiagram = new EaDiagram(rep);

            if (curDiagram.Dia == null)
            {
                return;
            }
            int indexLast = curDiagram.SelElements.Count - 1;

            // only synchronize TaggedValues
            if (indexLast == 0)
            {
                SynchronizeTaggedValues(rep);
            }
            if (indexLast < 1)
            {
                return;
            }

            EA.Element elLast   = curDiagram.SelElements[0];
            string     stereoEx = elLast.StereotypeEx;


            TaggedValue.ElTagValue elTagValues = new TaggedValue.ElTagValue(elLast, stereoEx);
            // over all elements, skip first element because that is the property template
            for (int i = 1; i <= indexLast; i++)
            {
                // Set stereotypes if changed
                if (curDiagram.SelElements[i].StereotypeEx != stereoEx)
                {
                    curDiagram.SelElements[i].StereotypeEx = stereoEx;
                }
                var error = rep.GetLastError();
                curDiagram.SelElements[i].Update();
                elTagValues.Copy(curDiagram.SelElements[i]);
                curDiagram.SelElements[i].Update();
            }
            // synchronize all stereotypes
            elTagValues.SyncTaggedValues(rep, elLast);
        }