Exemplo n.º 1
0
        private void SetColor(bool IsEnabled, ref NodeDescriptor GrNode)
        {
            switch (GraphType)
            {
            case GraphTypes.Undefined:
            case GraphTypes.All:
                if (ShapeType == ShapeTypes.Picture)
                {
                    GrNode.ImageSrc = imagePath + GrNode.ActiveImageName;
                }
                else
                {
                    GrNode.FillColor = GrNode.ActiveColor;
                }

                break;

            case GraphTypes.AllAndUser:
            case GraphTypes.UserOnly:
                if (ShapeType == ShapeTypes.Picture)
                {
                    GrNode.ImageSrc = imagePath + (IsEnabled ? GrNode.ActiveImageName : GrNode.NonActiveImageName);
                }
                else
                {
                    GrNode.FillColor = (IsEnabled ? GrNode.ActiveColor : GrNode.NonActiveColor);
                }

                break;

            default:
                break;
            }
        }
Exemplo n.º 2
0
        private NodeDescriptor CreateNewNode(DBEntryDescriptor entry)
        {
            NodeDescriptor newNode = new NodeDescriptor();

            newNode.Name        = entry.Name;
            newNode.Id          = entry.Id;
            newNode.Description = (String.IsNullOrEmpty(entry.Description) ? entry.DbType : entry.Description);
            //if (!string.IsNullOrEmpty(entry.Url)) newNode.Url = @"javascript:void(window.open('" + entry.Url + "','_blank'))";

            switch (ShapeType)
            {
            case ShapeTypes.Figure:
                newNode.Shape = "rectangle";
                break;

            case ShapeTypes.Image:
                newNode.Shape = entry.Shape;
                if (String.IsNullOrEmpty(newNode.Shape))
                {
                    newNode.Shape = "ellipse";
                }
                break;

            case ShapeTypes.Picture:
                newNode.IsImage            = true;
                newNode.ActiveImageName    = "user_on.jpg";
                newNode.NonActiveImageName = "user_off.jpg";
                break;

            default:
                break;
            }
            SetColor(true, ref newNode);

            return(newNode);
        }
Exemplo n.º 3
0
        //new graphml node
        public XElement CreateNodeElement(DBEntryDescriptor entry)
        {
            XElement xmlNode = new XElement(GraphNS + "node",
                                            new XAttribute("id", "n" + entry.Id)
                                            );

            NodeDescriptor Node = CreateNewNode(entry); //.Name, entry.Id, entry.Description,

            //Node.GroupId = XmlSection.GetAttribute("id") +":"+ Node.Id;
            //XmlElement xmlNode = this.Document.CreateElement("node");
            //xmlNode.SetAttribute("id", Node.GroupId);
            if (!string.IsNullOrEmpty(entry.Url))
            {
                XElement xmlUrl = new XElement(GraphNS + "data",
                                               new XAttribute("key", "d1"), //URL_ID
                                               entry.Url
                                               );
                xmlNode.Add(xmlUrl);
            }
            if (entry.Description != null)
            {
                XElement xmlGroupDescription = new XElement(GraphNS + "data",
                                                            new XAttribute("key", "d2"), //NODE_DESC_ID
                                                            entry.Description
                                                            );
                xmlNode.Add(xmlGroupDescription);
            }
            XElement xmlImageShape;

            if (Node.IsImage)
            {
                xmlImageShape = new XElement(YedNS + "Image",
                                             new XAttribute("href", Node.ImageSrc)
                                             );
            }
            else
            {
                xmlImageShape = new XElement(YedNS + "Shape",
                                             new XAttribute("type", Node.Shape)
                                             );
            }

            XElement xmlGroupData3 = new XElement(GraphNS + "data",
                                                  new XAttribute("key", "d3"), //N_ID
                                                  new XElement(YedNS + (Node.IsImage ? "ImageNode" : "ShapeNode"),
                                                               new XElement(YedNS + "Geometry",
                                                                            new XAttribute("width", Node.Width),
                                                                            new XAttribute("height", Node.Height)
                                                                            ),
                                                               new XElement(YedNS + "Fill",
                                                                            new XAttribute("color", Node.FillColor),
                                                                            new XAttribute("transparent", Node.Transparent)
                                                                            ),
                                                               new XElement(YedNS + "BorderStyle",
                                                                            new XAttribute("type", Node.BorderType),
                                                                            new XAttribute("width", Node.BorderWidth),
                                                                            new XAttribute("color", Node.BorderColor)
                                                                            ),
                                                               new XElement(YedNS + "NodeLabel",
                                                                            new XAttribute("alignment", Node.LabelAlignment),
                                                                            new XAttribute("fontFamily", Node.LabelFontFamily),
                                                                            new XAttribute("textColor", Node.LabelTextColor),
                                                                            new XAttribute("autoSizePolicy", Node.LabelAutoSizePolicy),
                                                                            new XAttribute("modelName", Node.ModelName),
                                                                            new XAttribute("modelPosition", Node.ModelPosition),
                                                                            Node.Name
                                                                            ),
                                                               xmlImageShape
                                                               )
                                                  );

            xmlNode.Add(xmlGroupData3);
            //xmlNode.Add(new XElement(GraphNS + "data",
            //            new XAttribute("key", "d1"), //URL_ID
            //            Node.Url
            //            )
            //    );

            return(xmlNode);
        }