Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Set the size of an image on a ShapeNode (Read 3600 times)
slowjoe
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Jul 28th, 2010
Set the size of an image on a ShapeNode
Jul 28th, 2010 at 12:09am
Print Post  
Hi,

I am using MindFusion diagramming controls v5.3.

I have a tree diagram and want to add different bitmaps to shapenodes depending on certain conditions.

I have an imagelist that contains 16x16 icons. I can assign an image to each shapenode as it is created but it always seems to be 32x32 so it looks fuzzy and you can sort of see the color that was meant to be transparent in the bitmap.

ShapeNode childNode = new ShapeNode(diagramMain);
:
:
childNode.ImageAlign = Align.BottomCenter;
childNode.Image = imlLog.Images[m_rand.Next(0, 10)];

Any ideas?

Thank you,
Joe
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Set the size of an image on a ShapeNode
Reply #1 - Jul 28th, 2010 at 7:39am
Print Post  
Hi,

The image size looks correct in my test. Could you verify if some code later doesn't change ImageAlign to Fit or Stretch?

The transparent color selected in the ImageList control also worked for me. Perhaps you are seeing the node's background color - you can hide it by setting ShapeNode.Transparent.

Stoyan
  
Back to top
 
IP Logged
 
slowjoe
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Jul 28th, 2010
Re: Set the size of an image on a ShapeNode
Reply #2 - Jul 28th, 2010 at 2:47pm
Print Post  
Hi Stoyan,

Thank you for the reply. I think what is happening is that I am creating the ShapeNode too small

childNode.Bounds = new RectangleF(0, 0, 22, 15);

so when I add an image to it, the image looks distorted. I changed the size to (0, 0, 64, 32) and the image looks clearer.

I'm new at this so I'm sure I'll have many more questions.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Set the size of an image on a ShapeNode
Reply #3 - Jul 28th, 2010 at 3:01pm
Print Post  
Hi Joe,

If it depends on the node size, then probably the ImageAlign value is set to Fit or Stretch. Does the image get bigger if you resize the node?

Stoyan
  
Back to top
 
IP Logged
 
slowjoe
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Jul 28th, 2010
Re: Set the size of an image on a ShapeNode
Reply #4 - Jul 28th, 2010 at 3:41pm
Print Post  
Hi Stoyo,

When I resize the node, the image stays the same.  The ImageAlign property is set to BottomCenter.  I think what is happening is that since I created the node so small and I call ResizeToFitItems, it "zooms in" and the icon looks funny...

Thank you,
Joe
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Set the size of an image on a ShapeNode
Reply #5 - Jul 28th, 2010 at 4:56pm
Print Post  
Hi Joe,

Indeed the images scale too if you change the diagram's ZoomFactor, e.g. by calling ZoomToFit. Do you need them drawn without scaling even if the diagram is zoomed?

Stoyan
  
Back to top
 
IP Logged
 
slowjoe
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Jul 28th, 2010
Re: Set the size of an image on a ShapeNode
Reply #6 - Jul 28th, 2010 at 5:19pm
Print Post  
Hi Stoyan,

No - I don't need them to stay the same size.  I guess my real problem is determining an initial size to draw the ShapeNodes so that the font and bitmap look good.  I'll mess around with it some and hopefully come up with a good size...

Thanks again,
Joe
  
Back to top
 
IP Logged
 
slowjoe
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Jul 28th, 2010
Re: Set the size of an image on a ShapeNode
Reply #7 - Jul 28th, 2010 at 5:42pm
Print Post  
Hi Stoyan,

Since I'm thinking about it - what is the effect of setting Node.Shape.ImageRectangle and then setting the ImageAlign property?  How do they interact together?

Thank you for you time,
Joe
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Set the size of an image on a ShapeNode
Reply #8 - Jul 28th, 2010 at 6:23pm
Print Post  
Hi Joe,

Shape.ImageRectangle specifies the bounding rectangle inside a node in which the image should be displayed. ImageAlign specifies at what side or corner of that rectangle the image should be displayed, or if the image should stretch to fill that rectangle.

None of the built-in shapes specifies ImageRectangle; in that case the image is aligned relatively to node.Bounds. As with other shape definitions coordinates, you specify ImageRectangle in 100x100 coordinate space which is then mapped to the node's absolute coordinates; e.g. 50,50 in the ImageRectangle always maps to the center of the node.

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


I love YaBB 1G - SP1!

Posts: 10
Joined: Jul 28th, 2010
Re: Set the size of an image on a ShapeNode
Reply #9 - Jul 28th, 2010 at 7:54pm
Print Post  
Now things are starting to make sense.  I didn't realize the rectangle was in terms of percentage.

Thanks for the info,
Joe
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint