hi,
I'm evaluating the FlowChart.Net and i have a problem redisplay the link from the stored list.
i have a testNode and testLink basically follow the basic tutorial.
here is my code:
public class myLink: DiagramLink { public MyLink(Diagram diagram) : base(diagram) { }
public MyLink(Diagram diagram, MyNode src, MyNode dest) : base(diagram, src, dest) { }
public MyLink(MyLink prototype, MyNode src, MyNode dest) : base(prototype, src, dest) { }
public MyLink(MyLink prototype, Diagram diagram) : base(diagram) { }
protected override void LoadFrom(System.IO.BinaryReader reader, PersistContext context) { base.LoadFrom(reader, context); }
protected override void SaveTo(System.IO.BinaryWriter writer, PersistContext context) { base.SaveTo(writer, context); } }
TestLink public class MyNode:DiagramNode { public MyNode(Diagram diagram) : base(diagram) { }
public MyNode(MyNode prototype) : base(prototype) { }
protected override void LoadFrom(System.IO.BinaryReader reader, PersistContext context) { base.LoadFrom(reader, context); }
protected override void SaveTo(System.IO.BinaryWriter writer, PersistContext context) { base.SaveTo(writer, context); }
public override void Draw(MindFusion.Drawing.IGraphics graphics, RenderOptions options) { graphics.DrawRectangle(Pens.Black, Rectangle.Truncate(this.bounds)); }
public override void DrawShadow(MindFusion.Drawing.IGraphics graphics) {
}
and i'm trying see if i can recreate the diagram from a stored List
private List<myNode> testNodes = new List<myNode> (); private List<myLink> testLinks = new List<myLink>();
private void testToolStripMenuItem1_Click(object sender, EventArgs e) { TestDiagramNode node0 = new TestDiagramNode(currentDiagram()); TestDiagramNode node1 = new TestDiagramNode(currentDiagram());
node0.Bounds = new RectangleF(18F, 26F, 7.2736F, 7.878159F); node1.Bounds = new RectangleF(62F, 26F, 6.280975F, 7.878159F);
currentDiagram().Nodes.Add(node0); currentDiagram().Nodes.Add(node1);
TestDiagramLink link = new TestDiagramLink(currentDiagram(), node0, node1); TestDiagramLink link2 = new TestDiagramLink(currentDiagram(), node1, node0);
currentDiagram().Links.Add(link); currentDiagram().Links.Add(link2);
testLinks.Add(link); testLinks.Add(link2); testNodes.Add(node0); testNodes.Add(node1); }
then i try to retrieve and recreate:
private void retrieveToolStripMenuItem_Click(object sender, EventArgs e) { foreach (TestDiagramNode node in testNodes) { currentDiagram().Nodes.Add(node); }
TestDiagramLink link = new TestDiagramLink(currentDiagram(),testNodes[0],testNodes[1]);
currentDiagram().Links.Add(link);
TestDiagramLink link1 = new TestDiagramLink(currentDiagram(), testNodes[1], testNodes[0]);
currentDiagram().Links.Add(link1); }
the above work fine, the arrow origin and destination were perfect, but not this:
TestDiagramLink link2 = new TestDiagramLink(currentDiagram()); link2.Origin = testNodes[0]; link2.Destination = testNodes[1]; currentDiagram().Links.Add(link2);
The link's origin alway located at 0.0 (upper left corner of the diagram view) then the arrow end at the destination node, do you know why?
|