Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Problems with redisplay the link (Read 2763 times)
KNguyen
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Mar 28th, 2008
Problems with redisplay the link
Mar 28th, 2008 at 3:06pm
Print Post  
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?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problems with redisplay the link
Reply #1 - Mar 28th, 2008 at 3:37pm
Print Post  
Hi. Are you using more than one diagrams?
  
Back to top
 
IP Logged
 
KNguyen
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Mar 28th, 2008
Re: Problems with redisplay the link
Reply #2 - Mar 28th, 2008 at 8:11pm
Print Post  
yes, and my currentDiagram() return the selected diagram.
  
Back to top
 
IP Logged
 
KNguyen
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Mar 28th, 2008
Re: Problems with redisplay the link
Reply #3 - Mar 28th, 2008 at 8:43pm
Print Post  
Hi stoyo,

from your last comment, i was thinking maybe multiple diagrams could be the reason for the link not to display correctly, so i created another test form with only one diagram this time, it still doesn't display the link correctly if i set the origin and destination outside of the constructor. This is driving me nut!

here is my new test code:
public partial class Form1 : Form
    {
       public Form1()
       {
           InitializeComponent();
           test();
       }

       private List<MyNode> testNodes = new List<MyNode>();
       private List<MyLink> testLinks = new List<MyLink>();

       private void test()
       {
           MyNode node0 = new MyNode(diagram1);
           MyNode node1 = new MyNode(diagram1);

           node0.Bounds = new RectangleF(18F, 26F, 7.2736F, 7.878159F);
           node1.Bounds = new RectangleF(62F, 26F, 6.280975F, 7.878159F);

           testNodes.Add(node0);
           testNodes.Add(node1);
       }


       private void button1_Click(object sender, EventArgs e)
       {
           foreach (MyNode node in testNodes)
           {
               diagram1.Nodes.Add(node);
           }

           //MyLink link = new MyLink(diagram1, testNodes[0], testNodes[1]);
           //diagram1.Links.Add(link);

           //TestDiagramLink link1 = new TestDiagramLink(currentDiagram(), testNodes[1], testNodes[0]);
           //currentDiagram().Links.Add(link1);

           MyLink link2 = new MyLink(diagram1);
           link2.Origin = testNodes[1];
           link2.Destination = testNodes[0];
           diagram1.Links.Add(link2);
       }
    }
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problems with redisplay the link
Reply #4 - Mar 29th, 2008 at 10:18am
Print Post  
Hi,

Calling the link's UpdateIntersections method seems to fix that:

MyLink link2 = new MyLink(diagram);
link2.Origin = testNodes[1];
link2.Destination = testNodes[0];
diagram.Links.Add(link2);
link2.UpdateIntersections();
diagram.Invalidate(link2.GetRepaintRect(false));

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
KNguyen
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Mar 28th, 2008
Re: Problems with redisplay the link
Reply #5 - Mar 31st, 2008 at 3:04pm
Print Post  
it works, thanks you.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint