Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic ShapeTemplate and Image (Read 3279 times)
meriturva
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Feb 27th, 2007
ShapeTemplate and Image
Feb 27th, 2007 at 6:30am
Print Post  
I need to insert and image into a ShapeTemplate.
This is the code i wrote for a simple test:
[code]
Bitmap bitmap = new Bitmap("ResourceFiles\\SynopticsIcons\\test.png");
bitmap.SetResolution(96, 96);
ShapeTemplate st = new ShapeTemplate(new ElementTemplate[] {}, FillMode.Winding, "test");
st.Image = bitmap;
st.ImageRectangle = new RectangleF(0, 0, 100, 100);
Box box = flowChart_Synoptic.CreateBox(10, 10, bitmap.Width, bitmap.Height);
box.Shape = st;
box.Style = BoxStyle.Shape;   
[/code]

I don't know why but there is no image displayed.
Where could i find a running example?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ShapeTemplate and Image
Reply #1 - Feb 27th, 2007 at 6:39am
Print Post  
Hello,

Perhaps it does not work because the list of outline elements is empty. Try how it will work if the outline is defined, e.g.:

ShapeTemplate st = new ShapeTemplate(
     ShapeTemplate.FromId("Rectangle").Outline, FillMode.Winding, "test");

Set the Box.Transparent property if you do not want to see the box shape but only the image.

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


I love YaBB 1G - SP1!

Posts: 17
Joined: Feb 27th, 2007
Re: ShapeTemplate and Image
Reply #2 - Feb 27th, 2007 at 7:10am
Print Post  
Perfect!
Thanks...
I have another litte question....
When i create a new Box i use:
[code]
Box box = flowChart_Synoptic.CreateBox(10, 100, bitmap.Width, bitmap.Height);
[/code]

but the size is not correct (bigger than normal)
I would like to know where is the measure unit of the width and height  in CreateBox.
In the documentation i have:

width

The width of the box to draw.

height

The height of the box to draw.

There is no indication about pixel o mm o cm?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ShapeTemplate and Image
Reply #3 - Feb 27th, 2007 at 7:23am
Print Post  
The width and height are measured in the unit specified in FlowChart.MeasureUnit. The default is mm. You might call Box.FitSizeToImage and the control will calculate the correct size for you.

Stoyan
  
Back to top
 
IP Logged
 
meriturva
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Feb 27th, 2007
Re: ShapeTemplate and Image
Reply #4 - Feb 27th, 2007 at 7:41am
Print Post  
I think that the code:
[code]
st.ImageRectangle = new RectangleF(0, 0, 100, 100);
[/code]
It is the left-top pixel where to start the image (respect to the shape) and the % of the width and height  (respect to the size of the shape).
am i correct?

So the Box.FitSizeToImage doesn't work (i think it is valid only when you use box.Image and not Shape.Image and Shape.ImageRectangle)

So i prefer to rescale by my self the shape with:
[code]
Box box = flowChart_Synoptic.CreateBox(10, 100, (float)(bitmap.Width * 25.4 / bitmap.HorizontalResolution), (float)(bitmap.Height * 25.4 / bitmap.VerticalResolution));
[/code]

Thanks again for your great support.
Meriturva
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ShapeTemplate and Image
Reply #5 - Feb 27th, 2007 at 7:50am
Print Post  
FitToImage is supposed to work with the ShapeTemplate.Image too. In that case you must call the method after Box.Style is set to BoxStyle.Shape and the Box.Shape is assigned.

Stoyan
  
Back to top
 
IP Logged
 
meriturva
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Feb 27th, 2007
Re: ShapeTemplate and Image
Reply #6 - Feb 27th, 2007 at 7:59am
Print Post  
You are right,
the FitSizeToImage call must be after the
[code]
box.Shape = st;
box.Style = BoxStyle.Shape;

box.FitSizeToImage();
[/code]

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