Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Insert Image in Flowchart (Read 2829 times)
ampersand
Junior Member
**
Offline



Posts: 55
Joined: Sep 21st, 2006
Insert Image in Flowchart
Oct 17th, 2006 at 6:41pm
Print Post  
I try to insert images via an OpenFileDialog into flowchart. As far as I see it I have to create a Box and put the selected image into the Image property of the box.

Code
Select All
Box box  =  btChart.CreateBox(10,10,50,50);
box.Style = BoxStyle.Rectangle;
if (openImageDialog.ShowDialog() == DialogResult.OK)
{
  try
  {
     box.Image = new Bitmap(openImageDialog.FileName);
     box.FitSizeToImage();
  }
  catch (ArgumentException)
  {
  }
 


So far so good. The image appears within the box.

But if the user now tries to resize the image by resizing the box with the mouse the box does not keep the aspect ratio of the image and the box appears behind the image.

So two questions arise:

Is it the best way to insert an image into flowchart by putting it into a box object? Or is there another (better) way?

How can I keep the aspect ratio of a Box and an embedded image?

Thanks for your help

Dirk
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Insert Image in Flowchart
Reply #1 - Oct 18th, 2006 at 4:53am
Print Post  
There isn't any way to insert an image other than loading it into a box or a table.

Set the box.ImageAlign property to Fit; that should let you resize the image, preserving its aspect ratio.

Set box.Transparent = true to hide the box borders and background, but keep its Image and Text visible.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
ampersand
Junior Member
**
Offline



Posts: 55
Joined: Sep 21st, 2006
Re: Insert Image in Flowchart
Reply #2 - Oct 18th, 2006 at 6:34am
Print Post  
I did as you suggested.
Code
Select All
Box box  =  btChart.CreateBox(10,10,50,50);
box.Style = BoxStyle.Rectangle;
if (openImageDialog.ShowDialog() == DialogResult.OK)
{
try
{
box.Image = new Bitmap(openImageDialog.FileName);
box.ImageAlign = ImageAlign.Fit;
box.Transparent = true;
}
catch (ArgumentException)
{
}
 


But now if I try to connect the ImageBox with another Box and the ImageBox is not exactly of the same size as the embedded image the arrow will begin in the nowhere.

This is because the box does not keep the aspect ration of the image and so the arrow begins at the transparent box.

Please see below picture



Is there an easy way to let the box keep the same size as the emebdded image?

Dirk
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Insert Image in Flowchart
Reply #3 - Oct 18th, 2006 at 7:01am
Print Post  
If you don't need your users to resize the image, set the box.EnabledHandles = Move. Otherwise, after calling FitSizeToImage, set box.Cosntraints.KeepRatio = true.

Stoyan
  
Back to top
 
IP Logged
 
ampersand
Junior Member
**
Offline



Posts: 55
Joined: Sep 21st, 2006
Re: Insert Image in Flowchart
Reply #4 - Oct 18th, 2006 at 10:57am
Print Post  
Stoyan, your support is just fantastic! That is exactly what I was looking for.

Sorry that I didn't find it myself.

Thanks
Dirk
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint