I have attached an exported XML from the control (using diagram.SaveToXml(Stream)). We generate the nodes and links in code, but I assume that the export will have all the properties you need?
The custom shape is simply there so that I could use a templated control with bindings to the data context to our model objects - maybe we can do the same thing with a ControlNode?
public class DataTypeNode : ShapeNode { public DataTypeNode(Diagram parent) : base(parent) { DefaultStyleKey = typeof (DataTypeNode); }
public DataTypeNode(ShapeNode prototype) : base(prototype) { DefaultStyleKey = typeof (DataTypeNode); }
public DataTypeNode() { DefaultStyleKey = typeof (DataTypeNode); } }
The diagram XAML is: <mfd:Diagram x:Name="_modelDiagram" MinWidth="200" MinHeight="200" AutoSnapLinks="False" AutoScroll="True" ShowGrid="False" AutoAlignNodes="False" ShapeBrush="White" LinkBrush="Black" AlignToGrid="False" Behavior="Modify" AllowUnconnectedLinks="False" AllowInplaceEdit="False" RouteLinks="True" DynamicLinks="True" ModificationStart="AutoHandles" LinkCrossings="Arcs" BackBrush="White" FontSize="12" ShapeHandlesStyle="EasyMove" />
With the following set in the code behind constructor: _modelDiagram.AdjustmentHandlesSize = 10; _modelDiagram.DynamicLinks = true; _modelDiagram.LinkStyle = LinkStyle.Cascading; _modelDiagram.RoutingOptions.Anchoring = Anchoring.Reassign; _modelDiagram.RoutingOptions.TriggerRerouting = RerouteLinks.WhenModified; I have disabled node/link creation and deletion using the *Creating/*Deleting events and args.CancelDrag().
The custom anchor pattern is created like this: AnchorPattern = new AnchorPattern("DataTypeAnchorPattern"); for (var x = 20; x <= 80; x += 10) { AnchorPattern.Points.Add(new AnchorPoint(x, 0, true, true, MarkStyle.Cross)); AnchorPattern.Points.Add(new AnchorPoint(x, 100, true, true, MarkStyle.Cross)); } for (var y = 20; y <= 80; y += 10) { AnchorPattern.Points.Add(new AnchorPoint(0, y, true, true, MarkStyle.Cross)); AnchorPattern.Points.Add(new AnchorPoint(100, y, true, true, MarkStyle.Cross)); }
To arrange the diagram I have used:
var layout = new OrthogonalLayout { Anchoring = Anchoring.Reassign, KeepGroupLayout = true, MultipleGraphsPlacement = MultipleGraphsPlacement.VerticalSortDescending, Refine = true, Padding = 150, Margins = new Size(100, 100), } layout.Arrange(_diagram) _diagram.ResizeToFitItems(100); _diagram.RouteAllLinks(); _diagram.UpdateLayout();
|