locked
Programmatically move a node RRS feed

  • Question

  • How do you programmatically move a node in the same way that the sample is able to let you click and drag a node?
    Thursday, February 25, 2010 9:51 PM

Answers

  • How about similar codes to

     

    private void incrementalLayout_Click(object sender, EventArgs e)

    {

     

    ArrayList al = new ArrayList();

     

    foreach (Microsoft.Msagl.Drawing.IViewerObject ob in gViewer.Entities)

     

    if (ob.MarkedForDragging)

    al.Add(ob);

     

    foreach (Microsoft.Msagl.Drawing.IViewerObject ob in al)

    {

    Microsoft.Msagl.

    Node node = ob.DrawingObject.GeometryObject as Microsoft.Msagl.Node;

     

    if (null != node)

    {

     

    //gViewer.Graph.GeometryGraph.IncrementalLayout(node);

    node.Center +=

    new Microsoft.Msagl.Point (100, 100);  

    }

    }

    gViewer.Invalidate();

    }

     

    mi =

    new MenuItem();

    mi.Text =

    "Incremental layout selected";

    mi.Click +=

    new EventHandler(incrementalLayout_Click);

    cm.MenuItems.Add(mi);

     

    Above code is my test to add a context menu item to move selected item (100, 100) every time you click it. I haven't yet figure out how the view size could be automatically extend to display the moved nodes. "gViewer.AutoSize = true;" doesn't help.

    HTH

    -Patrick.

    Tuesday, April 27, 2010 6:23 PM

All replies

  • There is no API for it I am afraid. It would require some effort, but one can implement this API since the sources of graph editing are a part of the distribution. Thanks, Lev
    Lev Nachmanson
    Friday, February 26, 2010 5:33 PM
  • How about similar codes to

     

    private void incrementalLayout_Click(object sender, EventArgs e)

    {

     

    ArrayList al = new ArrayList();

     

    foreach (Microsoft.Msagl.Drawing.IViewerObject ob in gViewer.Entities)

     

    if (ob.MarkedForDragging)

    al.Add(ob);

     

    foreach (Microsoft.Msagl.Drawing.IViewerObject ob in al)

    {

    Microsoft.Msagl.

    Node node = ob.DrawingObject.GeometryObject as Microsoft.Msagl.Node;

     

    if (null != node)

    {

     

    //gViewer.Graph.GeometryGraph.IncrementalLayout(node);

    node.Center +=

    new Microsoft.Msagl.Point (100, 100);  

    }

    }

    gViewer.Invalidate();

    }

     

    mi =

    new MenuItem();

    mi.Text =

    "Incremental layout selected";

    mi.Click +=

    new EventHandler(incrementalLayout_Click);

    cm.MenuItems.Add(mi);

     

    Above code is my test to add a context menu item to move selected item (100, 100) every time you click it. I haven't yet figure out how the view size could be automatically extend to display the moved nodes. "gViewer.AutoSize = true;" doesn't help.

    HTH

    -Patrick.

    Tuesday, April 27, 2010 6:23 PM