private static void ProcessDiagramsLinkShapes(Diagram diagram, List<NodeShape> allShapes, LayoutInfo info) { foreach (LinkShape shape in diagram.LinkShapes) { if (allShapes.Contains(shape.FromShape) && allShapes.Contains(shape.ToShape)) { LinkShapeInfo lInfo = new LinkShapeInfo(info.Store); lInfo.ElementId = shape.Element.Id; lInfo.SourceElementId = shape.FromShape.Element.Id; lInfo.TargetElementId = shape.ToShape.Element.Id; lInfo.LinkDomainClassId = shape.Element.GetDomainClass().Id; lInfo.SourceLocation = shape.SourceAnchor.GetRelativeLocation(); lInfo.TargetLocation = shape.TargetAnchor.GetRelativeLocation(); lInfo.RoutingMode = shape.RoutingMode; lInfo.EdgePoints = ConvertToRelativeEdgePoints(shape.EdgePoints, shape.SourceAnchor.AbsoluteLocation); info.LinkShapeInfos.Add(lInfo); } } foreach (Diagram d in diagram.IncludedDiagrams) ProcessDiagramsLinkShapes(d, allShapes, info); }
private static void ProcessDiagramsLinkShapes(Diagram diagram, List <NodeShape> allShapes, LayoutInfo info) { foreach (LinkShape shape in diagram.LinkShapes) { if (allShapes.Contains(shape.FromShape) && allShapes.Contains(shape.ToShape)) { LinkShapeInfo lInfo = new LinkShapeInfo(info.Store); lInfo.ElementId = shape.Element.Id; lInfo.SourceElementId = shape.FromShape.Element.Id; lInfo.TargetElementId = shape.ToShape.Element.Id; lInfo.LinkDomainClassId = shape.Element.GetDomainClass().Id; lInfo.SourceLocation = shape.SourceAnchor.GetRelativeLocation(); lInfo.TargetLocation = shape.TargetAnchor.GetRelativeLocation(); lInfo.RoutingMode = shape.RoutingMode; lInfo.EdgePoints = ConvertToRelativeEdgePoints(shape.EdgePoints, shape.SourceAnchor.AbsoluteLocation); info.LinkShapeInfos.Add(lInfo); } } foreach (Diagram d in diagram.IncludedDiagrams) { ProcessDiagramsLinkShapes(d, allShapes, info); } }
private static bool ProcessLinkShape(LinkShape shapeElement, LinkedElementCollection <LinkShapeInfo> infos) { // try to find NodeShapeInfo for shape element LinkShapeInfo info = null; LinkShapeInfo infoAdv = null; foreach (LinkShapeInfo i in infos) { if (i.ElementId == shapeElement.Element.Id) { info = i; break; } else if (shapeElement.Element.GetDomainClass().Id == i.LinkDomainClassId && shapeElement.FromShape.Element.Id == i.SourceElementId && shapeElement.ToShape.Element.Id == i.TargetElementId) { infoAdv = i; } } if (info == null && infoAdv != null) { info = infoAdv; } if (info == null) { shapeElement.SourceAnchor.DiscardLocationChange = false; shapeElement.TargetAnchor.DiscardLocationChange = false; return(false); } shapeElement.SourceAnchor.SetRelativeLocation(info.SourceLocation); shapeElement.TargetAnchor.SetRelativeLocation(info.TargetLocation); shapeElement.RoutingMode = info.RoutingMode; if (info.EdgePoints != null) { shapeElement.EdgePoints = ConvertFromRelativeEdgePoints(info.EdgePoints, shapeElement.SourceAnchor.AbsoluteLocation); } else { shapeElement.EdgePoints.Add(new EdgePoint(shapeElement.SourceAnchor.AbsoluteLocation)); shapeElement.EdgePoints.Add(new EdgePoint(shapeElement.TargetAnchor.AbsoluteLocation)); } return(true); }
public static void SetLayoutInfo(LinkShapeInfo element, LayoutInfo newLayoutInfo) { DslModeling::DomainRoleInfo.SetLinkedElement(element, LinkShapeInfoDomainRoleId, newLayoutInfo); }
public static LayoutInfo GetLayoutInfo(LinkShapeInfo element) { return DslModeling::DomainRoleInfo.GetLinkedElement(element, LinkShapeInfoDomainRoleId) as LayoutInfo; }
/// <summary> /// Constructor /// Creates a LayoutInfoHasLinkShapeInfos link in the same Partition as the given LayoutInfo /// </summary> /// <param name="source">LayoutInfo to use as the source of the relationship.</param> /// <param name="target">LinkShapeInfo to use as the target of the relationship.</param> public LayoutInfoHasLinkShapeInfos(LayoutInfo source, LinkShapeInfo target) : base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(LayoutInfoHasLinkShapeInfos.LayoutInfoDomainRoleId, source), new DslModeling::RoleAssignment(LayoutInfoHasLinkShapeInfos.LinkShapeInfoDomainRoleId, target)}, null) { }
private static void WritePropertiesAsElements(DslModeling::SerializationContext serializationContext, LinkShapeInfo element, global::System.Xml.XmlWriter writer) { // EdgePoints if (!serializationContext.Result.Failed) { EdgePointCollection propValue = element.EdgePoints; string serializedPropValue = DslModeling::SerializationUtilities.GetString<EdgePointCollection>(serializationContext, propValue); if (!serializationContext.Result.Failed) { DiagramsDSLSerializationHelper.Instance.WriteElementString(serializationContext, element, writer, "edgePoints", serializedPropValue); } } }
private static void ReadPropertiesFromElements(DslModeling::SerializationContext serializationContext, LinkShapeInfo element, global::System.Xml.XmlReader reader) { while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element) { switch (reader.LocalName) { case "edgePoints": // EdgePoints if (reader.IsEmptyElement) { // No serialized value, must be default one. DslModeling::SerializationUtilities.Skip(reader); // Skip this tag. } else { string strEdgePoints = DiagramsDSLSerializationHelper.Instance.ReadElementContentAsString(serializationContext, element, reader); EdgePointCollection valueOfEdgePoints; if (DslModeling::SerializationUtilities.TryGetValue<EdgePointCollection>(serializationContext, strEdgePoints, out valueOfEdgePoints)) { element.EdgePoints = valueOfEdgePoints; } else { // Invalid property value, ignored. TestDslDefinitionSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "edgePoints", typeof(EdgePointCollection), strEdgePoints); } DslModeling::SerializationUtilities.SkipToNextElement(reader); } break; default: return; // Don't know this element. } } }