Beispiel #1
0
        private void AddOrUpdateElements(EAAPI.Package parentPackage, EAAPI.Element parentElement, EAAPI.Diagram lifeCycleDiagram, ref Dictionary <String, EAAPI.Element> elements)
        {
            // Get the Tagged Values from the parent diagram.
            EAAPI.Collection taggedValues = parentElement.TaggedValues;

            foreach (Utility.Element element in diagramConfig.Elements.Element.AsQueryable())
            {
                String elementName = element.Name;
                String elementType = element.Type;
                String elementText = element.Text;

                if (!String.IsNullOrEmpty(elementText) && true == elementText.Contains("@TAGVALUE"))
                {
                    // Get the value from the TaggedValues
                    String[]          keyValuePair = elementText.Split(':');
                    EAAPI.TaggedValue taggedValue  = (EAAPI.TaggedValue)taggedValues.GetByName(keyValuePair[1]);

                    elementText = taggedValue.Value;

                    // If there is an associated Map then use that.
                    if (!String.IsNullOrEmpty(element.TextMap))
                    {
                        // Get the text map to use from the Configuration
                        Utility.Map mapValues = (from t in diagramConfig.Configuration.Map
                                                 where t.Name.Contains(element.TextMap)
                                                 select t).First();

                        // Map the key to the value and that is the string to add on the diagram.
                        elementText = (from t in mapValues.MapValue
                                       where t.Key.Contains(elementText)
                                       select t.Value).First();
                    }
                }

                // Add the elements to the Repository.
                // Update only the text if it is already in the Repository.
                AddOrUpdateElement(
                    parentPackage,
                    ref elements,
                    FormatDiagramElementAlias(lifeCycleDiagram.DiagramID, elementName),
                    elementType,
                    elementText,
                    element.BackColor);
            }

            parentPackage.Elements.Refresh();
        }
Beispiel #2
0
        private void AddOrUpdateElementsOnDiagram(EAAPI.Element parentElement, EAAPI.Diagram lifeCycleDiagram, ref Dictionary <String, EAAPI.Element> elements)
        {
            String alias;
            int    elementID;

            // Get all of the diagram elements on the existing diagram into a list that is easier to search.
            Dictionary <String, int> preExistingObjects = new Dictionary <String, int>();

            foreach (EAAPI.DiagramObject digObject in lifeCycleDiagram.DiagramObjects)
            {
                EAAPI.Element packageElement = eaRepo.GetElementByID(digObject.ElementID);

                alias     = packageElement.Alias;
                elementID = packageElement.ElementID;

                if (!String.IsNullOrEmpty(alias))
                {
                    preExistingObjects.Add(packageElement.Alias, packageElement.ElementID);
                }
            }

            int    topDef;
            int    leftDef;
            int    heightDef;
            int    widthDef;
            String elementName;
            int    top;
            int    left;
            int    right;
            int    bottom;

            int row;
            int column;

            topDef    = SafeToInt(diagramConfig.Configuration.Position.DefaultTop, 0);
            leftDef   = SafeToInt(diagramConfig.Configuration.Position.DefalutLeft, 0);
            heightDef = SafeToInt(diagramConfig.Configuration.Position.DefaultHeight, 0);
            widthDef  = SafeToInt(diagramConfig.Configuration.Position.DefaultWidth, 0);

            String backColor;

            // Get the parent diagram. This contains the Tagged Values.
            EAAPI.Collection taggedValues = parentElement.TaggedValues;

            // Ad or update the diagram elements.
            foreach (Utility.Element element in diagramConfig.Elements.Element.AsQueryable())
            {
                elementName = FormatDiagramElementAlias(lifeCycleDiagram.DiagramID, element.Name);
                elementID   = elements[elementName].ElementID;

                row    = SafeToInt(element.Cell.Row, 0);
                column = SafeToInt(element.Cell.Column, 0);

                top    = topDef + ((row - 1) * heightDef) + SafeToInt(element.PositionOffset.Top, 0);
                left   = leftDef + ((column - 1) * widthDef) + SafeToInt(element.PositionOffset.Left, 0);
                right  = widthDef + left + SafeToInt(element.PositionOffset.Width, 0);
                bottom = heightDef + top + SafeToInt(element.PositionOffset.Height, 0);

                backColor = element.BackColor;

                if (!String.IsNullOrEmpty(backColor) && true == backColor.Contains("@TAGVALUE"))
                {
                    // Get the value from the TaggedValues
                    String[]          keyValuePair = backColor.Split(':');
                    EAAPI.TaggedValue taggedValue  = (EAAPI.TaggedValue)taggedValues.GetByName(keyValuePair[1]);

                    // Get the color map to use
                    Utility.TaggedValueColorMap mapValues = (from t in diagramConfig.Configuration.TaggedValueColorMap
                                                             where t.Name.Contains(element.ColorMap)
                                                             select t).First();

                    backColor = MapColor(mapValues.Color, taggedValue.Value);
                }

                if (!preExistingObjects.ContainsKey(elements[elementName].Alias))
                {
                    AddElementToDiagram(
                        lifeCycleDiagram, elementID, element.Type, left, right, top, bottom,
                        MapFont(diagramConfig.Configuration.FontMap.Font, element.Font),
                        MapColor(diagramConfig.Configuration.ColorMap.Color, backColor));
                }
                else
                {
                    UpdateElementOnDiagram(
                        lifeCycleDiagram, preExistingObjects[elementName], MapColor(diagramConfig.Configuration.ColorMap.Color, backColor));
                }
            }
        }