public void OpenFile(string fileName, FileExtensionType type) { var document = FileManager.Open(fileName, type); CreateDocument(document); RestartInitValues(); Document.SetCurrentId(); RecreateEventsHandlers(); Invalidate(); }
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(); }