Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic SVG shapes (Read 2335 times)
sigipa
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Oct 5th, 2019
SVG shapes
Oct 5th, 2019 at 7:19am
Print Post  
Hi,

I am in the process of evaluating MindFusion diagramming for winforms. I have a bunch of svg files that I want to use from a previous project. I'm trying to figure out how to create shapes from them and add them to the ShapeListBox. I also need to associate a class instance with each shape and serialize everything to a database. I have started with the svg file stuff. I can't seem to find an example the shows how to do this. Would someone be so kind as to point me in the right direction?

Thanks,
-S
  
Back to top
 
IP Logged
 
sigipa
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Oct 5th, 2019
Re: SVG shapes
Reply #1 - Oct 5th, 2019 at 10:43am
Print Post  
Hi,

Ok. I made a little progress. I managed to get a shape created from an svg file and add it to a diagram. That part seems ok. However, when I try to add the shape to the ShapeListBox, it doesn't display it correctly. After a bit of reading, it would appear that this won't work. Apparently, there is some additional information that is missing. I have a couple of questions about this.

1. Is it possible to create a shape from an svg file and add it to the ShapeListBox in code?

2. Is there a way to create a shape library without using the shape editor tool?


Code (C++)
Select All
      diagram.ShowGrid = true;

      SvgNode svgNode = new SvgNode();

      SvgContent content = new SvgContent();
      content.Parse(@"c:\users\sigipa\Downloads\drawing-1.svg");

      svgNode.Content = content;
      svgNode.ShadowOffsetX = 0;
      svgNode.ShadowOffsetY = 0;
      svgNode.Transparent = true;
      svgNode.Shape.DisplayName = "test";


      shapeListBox.ClearShapes();
      shapeListBox.AddShape(svgNode.Shape);

      diagram.Items.Add(svgNode);
 



Thanks,
-S

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: SVG shapes
Reply #2 - Oct 7th, 2019 at 6:20am
Print Post  
Hi,

Both ShapeListBox and shape libraries work with Shape objects, which define ShapeNode's geometry in diagram control's own format. So I guess ShapeListBox will only show the default rectangle shape which SvgNode inherits from ShapeNode.

In any case you can display a list of SvgNode instances using the NodeListView control - it clones the nodes when they are dragged into DiagramView. NodeListView can also contain other node classes, including your custom ones. For drag and drop to work with custom classes, you'll need to implement the Clone method and also SaveTo/LoadFrom serialization methods - latter ones are used to serialize into a data object expected by .NET's drag and drop API.

Instead of shape libraries, maybe use a list of SVG drawings embedded as resources in a resource assembly, or just files stored in a zip archive.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
sigipa
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Oct 5th, 2019
Re: SVG shapes
Reply #3 - Oct 7th, 2019 at 6:51am
Print Post  
Hi,

Ok. I guess you are saying that I can use the NodeListView as a replacement for the ShapeListBox, if I implement the functions you mentioned?

Is there an example that shows how to do this somewhere?

Thanks,
-S
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: SVG shapes
Reply #4 - Oct 7th, 2019 at 7:13am
Print Post  
Hi,

I can see NodeListView used in the LogicModel sample project. Adding SVG specifically can be done like -

Code
Select All
var svg = new SvgContent();
svg.Parse("drawing1.svg");

nodeListView.AddNode(
    new SvgNode
    {
        Content = svg
    }); 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint