private void UpdateShapeLayout(GraphicalDependencyShape shape, double maxShapeWidth) { double x = ChildMarginLeft; double y = ChildMarginTopStart; shape.SetLocation(new PointD(MarginMainElementLeft, MarginTopStart)); double maxWidth = 0; for (int i = 0; i < shape.Children.Count; i++) { double temp = shape.Children[i].Size.Height; shape.Children[i].SetLocation(new PointD(x, y), false); y += temp + VerticalSpaceBetweenElements; if (shape.Children[i].Size.Width > maxWidth) { maxWidth = shape.Children[i].Size.Width; } } //double desiredWidth = GetDesiredWidth(shape.RelationshipName); //if (maxWidth < desiredWidth) // maxWidth = desiredWidth; shape.SetSize(new SizeD(maxWidth + MarginRight, y - VerticalSpaceBetweenElements + MarginTopEnd + RelationshipNameSpace)); }
/// <summary> /// Updates the position of a link shape. /// </summary> /// <param name="linkShape">Link shape.</param> /// <param name="shape">Graphical dependency shape.</param> /// <param name="mainShape">Node shape.</param> /// <param name="bSource">True if graphical dependency shape is source.</param> public void UpdateLinkShapePosition(LinkShape linkShape, GraphicalDependencyShape shape, NodeShape mainShape, bool bSource) { if (linkShape == null) { return; } if (bSource) { linkShape.SourceAnchor.AbsoluteLocation = new PointD(shape.AbsoluteBounds.Right + LinkAnchorMargin, shape.AbsoluteBounds.Center.Y); linkShape.TargetAnchor.AbsoluteLocation = new PointD(mainShape.AbsoluteBounds.Left - LinkAnchorMargin, mainShape.AbsoluteBounds.Center.Y); linkShape.Layout(FixedGeometryPoints.SourceAndTarget); } else { linkShape.SourceAnchor.AbsoluteLocation = new PointD(mainShape.AbsoluteBounds.Right + LinkAnchorMargin, mainShape.AbsoluteBounds.Center.Y); linkShape.TargetAnchor.AbsoluteLocation = new PointD(shape.AbsoluteBounds.Left - LinkAnchorMargin, shape.AbsoluteBounds.Center.Y); linkShape.Layout(FixedGeometryPoints.SourceAndTarget); } /* * if (bSource) * { * linkShape.SourceAnchor.AbsoluteLocation = LinkShape.CalculateLocation( * LinkPlacement.Right, shape.AbsoluteBounds, new PointD(shape.AbsoluteBounds.Right + LinkAnchorMargin, shape.AbsoluteBounds.Center.Y)); * linkShape.TargetAnchor.AbsoluteLocation = LinkShape.CalculateLocation( * LinkPlacement.Left, mainShape.AbsoluteBounds, new PointD(mainShape.AbsoluteBounds.Left - LinkAnchorMargin, mainShape.AbsoluteBounds.Center.Y)); * } * else * { * linkShape.SourceAnchor.AbsoluteLocation = LinkShape.CalculateLocation(LinkPlacement.Right, * mainShape.AbsoluteBounds, new PointD(mainShape.AbsoluteBounds.Right + LinkAnchorMargin, mainShape.AbsoluteBounds.Center.Y)); * linkShape.TargetAnchor.AbsoluteLocation = LinkShape.CalculateLocation(LinkPlacement.Left, shape.AbsoluteBounds, * new PointD(shape.AbsoluteBounds.Left - LinkAnchorMargin, shape.AbsoluteBounds.Center.Y)); * } */ }
private void UpdateLinkShapePosition(GraphicalDependencyShape shape, NodeShape mainShape, bool bSource) { UpdateLinkShapePosition(shape.LinkShape, shape, mainShape, bSource); }
public GraphicalDependencyHostViewModel(ViewModelStore viewModelStore, GraphicalDependenciesViewModel diagram, GraphicalDependencyShape shapeElement) : base(viewModelStore, diagram, shapeElement) { }
/// <summary> /// Layouts the diagram. /// </summary> public virtual void Layout() { RectangleD rectSource = new RectangleD(new PointD(0, 0), new SizeD(0, 0)); RectangleD rectTarget = new RectangleD(new PointD(0, 0), new SizeD(0, 0)); double maineElementTop = 0.0; double maineElementLeft = MarginMainElementLeft; double maineElementLeftTemp = 0.0; if (this.SourceDependencyShapes.Count == 0) { maineElementLeft = MarginMainNoElementLeft; } for (int i = 0; i < this.SourceDependencyShapes.Count; i++) { GraphicalDependencyShape shape = this.SourceDependencyShapes[i]; UpdateShapeLayout(shape); rectSource.Width += shape.Size.Width; rectSource.Height += shape.Size.Height + VerticalSpaceBetweenElements; if (shape.Size.Width > maineElementLeftTemp) { maineElementLeftTemp = shape.Size.Width; } } for (int i = 0; i < this.TargetDependencyShapes.Count; i++) { GraphicalDependencyShape shape = this.TargetDependencyShapes[i]; UpdateShapeLayout(shape); rectTarget.Width += shape.Size.Width; rectTarget.Height += shape.Size.Height + VerticalSpaceBetweenElements; } if (this.SourceDependencyShapes.Count == 0 && this.TargetDependencyShapes.Count == 0) { this.MainElementShape.SetLocation( new PointD(MarginMainNoElementLeft, MarginMainNoElementTop)); } else { // position elements if (rectSource.Height > rectTarget.Height) { // first source element is positioned at 0,0 (+margins) // first target element is poisitioned at (rectSource.Height - rectTaget.Height)/2.0 // following elements are positioned at *prev element height* + margin double start = (rectSource.Height - rectTarget.Height) / 2.0 + MarginTopStart; double x = maineElementLeft + maineElementLeftTemp + this.MainElementShape.Size.Width + TargetMarginLeft; for (int i = 0; i < this.TargetDependencyShapes.Count; i++) { double y = this.TargetDependencyShapes[i].Size.Height; this.TargetDependencyShapes[i].SetLocation(new PointD(x, start)); start = start + y + VerticalSpaceBetweenElements; } start = MarginTopStart; x = SourceMarginLeft; for (int i = 0; i < this.SourceDependencyShapes.Count; i++) { double y = this.SourceDependencyShapes[i].Size.Height; this.SourceDependencyShapes[i].SetLocation(new PointD(x, start)); start = start + y + VerticalSpaceBetweenElements; } maineElementTop = rectSource.Height / 2.0 - this.MainElementShape.Size.Height / 2.0 + MarginTopStart; } else { // first target element is positioned at 0,0 (+margins) // first source element is poisitioned at (rectTaget.Height - rectSource.Height)/2.0 // following elements are positioned at *prev element height* + margin double start = (rectTarget.Height - rectSource.Height) / 2.0 + MarginTopStart; double x = SourceMarginLeft; for (int i = 0; i < this.SourceDependencyShapes.Count; i++) { double y = this.SourceDependencyShapes[i].Size.Height; this.SourceDependencyShapes[i].SetLocation(new PointD(x, start)); start = start + y + VerticalSpaceBetweenElements; } start = MarginTopStart; x = maineElementLeft + maineElementLeftTemp + this.MainElementShape.Size.Width + TargetMarginLeft; for (int i = 0; i < this.TargetDependencyShapes.Count; i++) { double y = this.TargetDependencyShapes[i].Size.Height; this.TargetDependencyShapes[i].SetLocation(new PointD(x, start)); start = start + y + VerticalSpaceBetweenElements; } maineElementTop = rectTarget.Height / 2.0 - this.MainElementShape.Size.Height / 2.0 + MarginTopStart; } this.MainElementShape.SetLocation( new PointD(maineElementLeft + maineElementLeftTemp, maineElementTop)); UpdateLinkShapePositions(); } }
public static GraphicalDependencyLinkShape GetLinkShape(GraphicalDependencyShape element) { return DslModeling::DomainRoleInfo.GetLinkedElement(element, GraphicalDependencyShapeDomainRoleId) as GraphicalDependencyLinkShape; }
public static void SetDependencyShape(GraphicalDependencyLinkShape element, GraphicalDependencyShape newGraphicalDependencyShape) { DslModeling::DomainRoleInfo.SetLinkedElement(element, GraphicalDependencyLinkShapeDomainRoleId, newGraphicalDependencyShape); }
public static void SetGraphicalDependenciesDiagram(GraphicalDependencyShape element, GraphicalDependenciesDiagram newGraphicalDependenciesDiagram) { DslModeling::DomainRoleInfo.SetLinkedElement(element, GraphicalDependencyShapeDomainRoleId, newGraphicalDependenciesDiagram); }
/// <summary> /// Constructor /// Creates a GraphicalDependencyLinkShapeReferencesDependencyShape link in the same Partition as the given GraphicalDependencyLinkShape /// </summary> /// <param name="source">GraphicalDependencyLinkShape to use as the source of the relationship.</param> /// <param name="target">GraphicalDependencyShape to use as the target of the relationship.</param> public GraphicalDependencyLinkShapeReferencesDependencyShape(GraphicalDependencyLinkShape source, GraphicalDependencyShape target) : base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(GraphicalDependencyLinkShapeReferencesDependencyShape.GraphicalDependencyLinkShapeDomainRoleId, source), new DslModeling::RoleAssignment(GraphicalDependencyLinkShapeReferencesDependencyShape.GraphicalDependencyShapeDomainRoleId, target)}, null) { }
public static GraphicalDependenciesDiagram GetGraphicalDependenciesDiagram(GraphicalDependencyShape element) { return DslModeling::DomainRoleInfo.GetLinkedElement(element, GraphicalDependencyShapeDomainRoleId) as GraphicalDependenciesDiagram; }
/// <summary> /// Constructor /// Creates a GraphicalDependenciesDiagramReferencesTargetDependencyShapes link in the same Partition as the given GraphicalDependenciesDiagram /// </summary> /// <param name="source">GraphicalDependenciesDiagram to use as the source of the relationship.</param> /// <param name="target">GraphicalDependencyShape to use as the target of the relationship.</param> public GraphicalDependenciesDiagramReferencesTargetDependencyShapes(GraphicalDependenciesDiagram source, GraphicalDependencyShape target) : base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(GraphicalDependenciesDiagramReferencesTargetDependencyShapes.GraphicalDependenciesDiagramDomainRoleId, source), new DslModeling::RoleAssignment(GraphicalDependenciesDiagramReferencesTargetDependencyShapes.GraphicalDependencyShapeDomainRoleId, target)}, null) { }
private void UpdateShapeLayout(GraphicalDependencyShape shape, double maxShapeWidth) { double x = ChildMarginLeft; double y = ChildMarginTopStart; shape.SetLocation(new PointD(MarginMainElementLeft, MarginTopStart)); double maxWidth = 0; for (int i = 0; i < shape.Children.Count; i++) { double temp = shape.Children[i].Size.Height; shape.Children[i].SetLocation(new PointD(x, y), false); y += temp + VerticalSpaceBetweenElements; if (shape.Children[i].Size.Width > maxWidth) maxWidth = shape.Children[i].Size.Width; } //double desiredWidth = GetDesiredWidth(shape.RelationshipName); //if (maxWidth < desiredWidth) // maxWidth = desiredWidth; shape.SetSize(new SizeD(maxWidth + MarginRight, y - VerticalSpaceBetweenElements + MarginTopEnd + RelationshipNameSpace)); }
/// <summary> /// Updates the position of a link shape. /// </summary> /// <param name="linkShape">Link shape.</param> /// <param name="shape">Graphical dependency shape.</param> /// <param name="mainShape">Node shape.</param> /// <param name="bSource">True if graphical dependency shape is source.</param> public void UpdateLinkShapePosition(LinkShape linkShape, GraphicalDependencyShape shape, NodeShape mainShape, bool bSource) { if (linkShape == null) return; if (bSource) { linkShape.SourceAnchor.AbsoluteLocation = new PointD(shape.AbsoluteBounds.Right + LinkAnchorMargin, shape.AbsoluteBounds.Center.Y); linkShape.TargetAnchor.AbsoluteLocation = new PointD(mainShape.AbsoluteBounds.Left - LinkAnchorMargin, mainShape.AbsoluteBounds.Center.Y); linkShape.Layout(FixedGeometryPoints.SourceAndTarget); } else { linkShape.SourceAnchor.AbsoluteLocation = new PointD(mainShape.AbsoluteBounds.Right + LinkAnchorMargin, mainShape.AbsoluteBounds.Center.Y); linkShape.TargetAnchor.AbsoluteLocation = new PointD(shape.AbsoluteBounds.Left - LinkAnchorMargin, shape.AbsoluteBounds.Center.Y); linkShape.Layout(FixedGeometryPoints.SourceAndTarget); } /* if (bSource) { linkShape.SourceAnchor.AbsoluteLocation = LinkShape.CalculateLocation( LinkPlacement.Right, shape.AbsoluteBounds, new PointD(shape.AbsoluteBounds.Right + LinkAnchorMargin, shape.AbsoluteBounds.Center.Y)); linkShape.TargetAnchor.AbsoluteLocation = LinkShape.CalculateLocation( LinkPlacement.Left, mainShape.AbsoluteBounds, new PointD(mainShape.AbsoluteBounds.Left - LinkAnchorMargin, mainShape.AbsoluteBounds.Center.Y)); } else { linkShape.SourceAnchor.AbsoluteLocation = LinkShape.CalculateLocation(LinkPlacement.Right, mainShape.AbsoluteBounds, new PointD(mainShape.AbsoluteBounds.Right + LinkAnchorMargin, mainShape.AbsoluteBounds.Center.Y)); linkShape.TargetAnchor.AbsoluteLocation = LinkShape.CalculateLocation(LinkPlacement.Left, shape.AbsoluteBounds, new PointD(shape.AbsoluteBounds.Left - LinkAnchorMargin, shape.AbsoluteBounds.Center.Y)); } */ }