Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Custom Drawing (Read 3268 times)
frankinstien
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: Nov 10th, 2010
Custom Drawing
Nov 10th, 2010 at 7:51pm
Print Post  
Hello,

I'm trying to draw SVG images on a shape and created a SVGShape class that inherits from the Shape class. When I create the .NET Graphics object from the hdc of the node's IGraphics the svg image won't show. If I create the graphics object from a bitmap and store it in the node's Image I can get a figure, but the image gets stretched or compacted depending on the size of the bitmap and the shape node. Below is the code I'm using:

void Diagram_DrawNode(object sender, MindFusion.Diagramming.DrawNodeEventArgs e)
{
SVGShape aNode = (SVGShape)e.Node;
aNode.ShapeNodeHdc = e.Graphics.GetHdc();
aNode.Load(@"E:\Symbols\Piping\Process_These_Files\OneSymbol.svg");
}

I did look at the custom draw sample which uses the MindFusion IGraphics to draw. The Shape class I created uses a .NET Graphics object, which is why I created the .NET Graphics from the IGraphics hdc.

Any help or examples that draw onto a node using the .NET Graphics would be appreciated.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Drawing
Reply #1 - Nov 10th, 2010 at 8:29pm
Print Post  
Hi,

Is there any reason not to use the SvgNode type that comes with the control? In any case you can get the GDI+ Graphics object like this:

MindFusion.Drawing.GdiGraphics graphicsWrapper = (MindFusion.Drawing.GdiGraphics)e.Graphics;
System.Drawing.Graphics gdiGraphics = graphicsWrapper.Graphics;

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


I love YaBB 1G - SP1!

Posts: 19
Joined: Nov 10th, 2010
Re: Custom Drawing
Reply #2 - Nov 11th, 2010 at 4:12am
Print Post  
Thanks for responding.

I was able to get the .NET Graphics from the node IGraphics as you demonstrated. The final rasterimage is drawn but won't show up in the shapenode. Is there another trick to this?

Also I wasn't aware of a SVGNode only the SVGGraphics interface which isn't what I need. I'm using an SVG picturebox hack and replacing it with a Shape node. The control reads the svg xml directly.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Drawing
Reply #3 - Nov 11th, 2010 at 7:45am
Print Post  
Do you need to copy the content rendered in some svg picturebox control and display it as bitmap in the ShapeNode? If it provides a method that returns a bitmap, you could call e.Graphics.DrawImage to render it inside the node, or just assign it to the Image property. But please try using the SvgNode class, e.g.

Code
Select All
SvgContent content = new SvgContent();
content.Parse(@"E:\Symbols\Piping\Process_These_Files\OneSymbol.svg");
diagram.Factory.CreateSvgNode(bounds, content); 



Or if you need to render several SVG images in the same node, you can do that by calling the SvgContent.Draw(IGraphics, RectangleF) method from the DrawNode handler.

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


I love YaBB 1G - SP1!

Posts: 19
Joined: Nov 10th, 2010
Re: Custom Drawing
Reply #4 - Nov 15th, 2010 at 5:43pm
Print Post  
stoyo,

Thanks for all your help. I did upgrade and now have the svg capability. But now I'm having a problem trying to load the svg images to a shapelistbox. Any suggestions?

Thanks.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Drawing
Reply #5 - Nov 15th, 2010 at 9:09pm
Print Post  
At this time ShapeListBox can display only Shape objects. If you need a list of arbitrary nodes, check the custom-drawn listview implementation from the Flowcharter example.

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