Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Diagramming based on engineering shapes (Read 3030 times)
Vivekagarwal
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Aug 5th, 2009
Diagramming based on engineering shapes
Aug 5th, 2009 at 12:16pm
Print Post  
I want to create a diagram in VB.net based on the engineering shapes in Visio. Can someone please tell me if it is possible using Mindfusion?

If yes, can someone please send me sample code?

Thanks,
Vivek
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagramming based on engineering shapes
Reply #1 - Aug 5th, 2009 at 12:36pm
Print Post  
There aren't such shapes available out of the box. If you have them as SVG images, you could use SvgNodes to display them. Otherwise create custom Shape definitions corresponding to the shapes and assign them to ShapeNodes.

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


I love YaBB 1G - SP1!

Posts: 6
Joined: Aug 5th, 2009
Re: Diagramming based on engineering shapes
Reply #2 - Aug 5th, 2009 at 12:40pm
Print Post  
What is SVG images? Can you send me sample code for this?

Otherwise can I create my own .ico or .bmp files saved on the disk and use those files to show on the disgram? Please send me sample code for this also.

Thanks for your help in advance,
Vivek
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagramming based on engineering shapes
Reply #3 - Aug 5th, 2009 at 1:04pm
Print Post  
SVG is a vector graphics format and SVG images scale smoothly when resized; bitmap images don't.

Loading a bitmap image looks like:
Code
Select All
ShapeNode node = new ShapeNode(diagram);
diagram.Nodes.Add(node)
node.Image = Image.FromFile(...);
node.Transparent = true; // show just the image
 



And SVG image:
Code
Select All
SvgContent content = new SvgContent();
content.Parse(...);

SvgNode node = new SvgNode(diagram);
diagram.Nodes.Add(node)
node.Content = content;
node.Transparent = true; // show just the image
 



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


I love YaBB 1G - SP1!

Posts: 6
Joined: Aug 5th, 2009
Re: Diagramming based on engineering shapes
Reply #4 - Aug 5th, 2009 at 1:19pm
Print Post  
Thanks, that helps.

Can you also send me sample code for how to create custom Shape definitions corresponding to the shapes and assign them to the ShapeNodes?

Also, which option you think is the best:
1. use .ico or .bmp files stored on disk.
2. Use SVG images.
3. Create custom Shape definitions corresponding to the shapes .

Thanks again,
Vivek
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagramming based on engineering shapes
Reply #5 - Aug 5th, 2009 at 1:38pm
Print Post  
You can use the shape designer tool to create Shape definitions. E.g. to create the Speaker shape from the "Fundamental Items" Visio palette, choose File->New in shape designer, right-click the top and bottom lines of the default rectangle and choose Split -> To Line, and arrange the 6 line segments to get the Speaker outline. Then right click on empty area and choose Insert Decoration -> Line, do that three times, and arrange them as in the Speaker shape.

You can either save the result in a shape library file and later load it for use by calling ShapeLibrary.LoadFrom(...), or copy and paste the generated code to your app init method:

Code
Select All
// C# ShapeTemplate definition
new Shape(
	new ElementTemplate[]
	{
		new LineTemplate(30, 20, 70, 20),
		new LineTemplate(70, 20, 100, 0),
		new LineTemplate(100, 0, 100, 100),
		new LineTemplate(100, 100, 70, 80),
		new LineTemplate(70, 80, 30, 80),
		new LineTemplate(30, 80, 30, 20)
	},
	new ElementTemplate[]
	{
		new LineTemplate(70, 20, 70, 80),
		new LineTemplate(0, 40, 30, 40),
		new LineTemplate(0, 60, 30, 60)
	},
 null, FillMode.Winding,   "Speaker" );
 



Later you can assign the shape to a node by calling node.Shape = Shape.FromId("Speaker").

For Visio shapes that are not filled, e.g. the "Alternating pulse" shape, leave the default rectangular outline in the shape definition, and later in the code set Shape.EnableOutline = false to leave only the decoration lines visible.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint