Exemplo n.º 1
0
 public BaseLinkElement AddLink(ConnectorElement start, ConnectorElement end)
 {
     if (CanAddLink(start, end))
     {
         var linkElement = new StraightLinkElement(start, end);
         _elements.Add(linkElement);
         linkElement.AppearanceChanged += ElementAppearanceChanged;
         OnAppearancePropertyChanged(new EventArgs());
         return(linkElement);
     }
     return(null);
 }
Exemplo n.º 2
0
        public BaseLinkElement AddLink(ConnectorElement connStart, ConnectorElement connEnd)
        {
            if (CanAddLink(connStart, connEnd))
            {
                BaseLinkElement lnk;
                
                if (_linkType == LinkType.Straight)
                    lnk = new StraightLinkElement(connStart, connEnd);
                else // (linkType == LinkType.RightAngle)
                    lnk = new RightAngleLinkElement(connStart, connEnd);

                Elements.Add(lnk);
                lnk.AppearanceChanged += ElementAppearanceChanged;
                OnAppearancePropertyChanged(new EventArgs());
                return lnk;
            }
            return null;
        }
Exemplo n.º 3
0
        public void CreateDocument(DomainDocument domainDocument)
        {
            Document = new Document
            {
                Id         = domainDocument.Id,
                Name       = domainDocument.Name,
                WindowSize = Size
            };

            foreach (var node in domainDocument.Nodes)
            {
                var rectangle = new Rectangle(node.X, node.Y, node.Width, node.Height);

                switch (node.Type)
                {
                case NodeType.Concept:
                    var rectangleNode = new RectangleNode(rectangle)
                    {
                        Id = node.Id, Label = new LabelElement {
                            Text = node.Label
                        }
                    };
                    rectangleNode.Label.PositionBySite(rectangleNode);
                    Document.AddElement(rectangleNode);
                    break;

                case NodeType.Relation:
                    var ellipseNode = new EllipseNode(rectangle)
                    {
                        Id = node.Id, Label = new LabelElement {
                            Text = node.Label
                        }
                    };
                    ellipseNode.Label.PositionBySite(ellipseNode);
                    Document.AddElement(ellipseNode);
                    break;

                case NodeType.Comment:
                    var commentBoxElement = new CommentBoxElement(rectangle)
                    {
                        Id = node.Id, Label = new LabelElement {
                            Text = node.Label
                        }
                    };
                    commentBoxElement.Label.PositionBySite(commentBoxElement);
                    Document.AddElement(commentBoxElement);
                    break;
                }
            }

            foreach (var link in domainDocument.Links)
            {
                ConnectorElement startConnectorElement, endConnectorElement;
                GetConnectors(link, out startConnectorElement, out endConnectorElement);

                if (startConnectorElement != null && endConnectorElement != null)
                {
                    var linkElement = new StraightLinkElement(startConnectorElement, endConnectorElement)
                    {
                        Id    = link.Id,
                        Label = new LabelElement
                        {
                            Text = link.Label
                        }
                    };
                    linkElement.Label.Size = EditLabelAction.GetTextSize(linkElement);
                    linkElement.Label.PositionBySite(linkElement);
                    Document.Elements.Add(linkElement);
                }
            }

            Document.SetCurrentId();
            RecreateEventsHandlers();
        }