How to change the type of an edge


Author
Message
Sandor Nagy
Sandor Nagy
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)
Group: Forum Members
Posts: 7, Visits: 1
Hi,

Thanks, it is working. But I have another question.
With this sample code all edges will be NArrowShape edges. But I need different edge types during importing edges using NGraphDataSourceImporter.
So the selected edge type should be determined based on the current database record in the MyEdgeShapeFactory.CreateShape method. How can I do this?
When a breakpoint is hit in the NGraphDataSourceImporter.EdgeImported event, the edge is already created as NArrowShape.

Thanks,
Sandor Nagy
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Sandor,

The following is a simple implementation of a shape factory:

 

public class MyEdgeShapeFactory : NShapesFactory

{

      public MyEdgeShapeFactory()

            : base("MyEdgeShapeFactory")

      {

      }

 

      public override int ShapesCount

      {

            get

            {

                  return Enum.GetValues(GetEnumType()).Length;

            }

      }

     

      public override NShape CreateShape(int index)

      {

            switch ((MyEdgeShapes)index)

            {

                  case MyEdgeShapes.ArrowShape:

                        NArrowShape arrowShape = new NArrowShape(new NPointF(0, 0), new NPointF(DefaultSize.Width, DefaultSize.Height));

                        return arrowShape;

 

                  default:

                        throw new Exception("New shape type ?");

            }

      }

      protected override NShapeInfo CreateShapeInfo(int index)

      {

            MyEdgeShapes edgeShape = (MyEdgeShapes)index;

            NShapeInfo info = new NShapeInfo(NSystem.InsertSpacesBeforeUppers(edgeShape.ToString()));

            return info;

      }

      protected override Type GetEnumType()

      {

            return typeof(MyEdgeShapes);

      }

}

 

public enum MyEdgeShapes

{

      ArrowShape

}

 

To make the graph data importer use this shape factory to create edges, use the following piece of code:

 

MyEdgeShapeFactory edgesFactory = new MyEdgeShapeFactory();

edgesFactory.DefaultSize = new NSizeF(60, 30);

graphImporter.EdgeShapesFactory = edgesFactory;

graphImporter.EdgeShapesName = MyEdgeShapes.ArrowShape.ToString();



Best Regards,
Nevron Support Team


Sandor Nagy
Sandor Nagy
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)
Group: Forum Members
Posts: 7, Visits: 1
Hi,
Can you provide me a sample code?

Thanks,
Sandor Nagy
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
Hi,
You can create a shape factory (by implementing the INShapeFactory interface) that creates the edge types you want and assign it to the EdgesShapeFactory property of the graph importer.

Best Regards,
Nevron Support Team


Sandor Nagy
Sandor Nagy
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)
Group: Forum Members
Posts: 7, Visits: 1
Hi,

I'm using the NGraphDataSourceImporter class to import the vertices and edges into the diagram. By default the types of the edges is NRoutableConnector.
How can I change the type of some edges to e.g. NArrowShape in the NGraphDataSourceImporter.EdgeImported event?

Thanks,
Sandor Nagy
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search