Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How-to add text to BottomCenter (Read 1557 times)
jsims
Guest


How-to add text to BottomCenter
Jul 10th, 2006 at 3:34pm
Print Post  
I am trying to add text to the bottom center of an icon but I am running to some troubles trying to get everything to work. I need the text field to auto expand to the text length while staying centered at the bottom of the icon. If someone already has a method or is knowledgeable enough with this control to whip up a source example for me, that would be great.

Basically I would like to have a method where all I need to do is pass the text and icon as parameters and it would just create the object. I am not concerned where it is put on the control since I will use the layout system.

Thanks in advance for your help!  Wink

Jake
  
Back to top
 
IP Logged
 
jsims
Guest


Re: How-to add text to BottomCenter
Reply #1 - Jul 10th, 2006 at 4:40pm
Print Post  
I was able to find the answer from a previous post. Thanks to thoes who might have replied... I have attached the code:

private void CreateHostObject(Host host, Point pt)
       {
           Box icon = flowChart.CreateBox(pt.X, pt.Y, 10, 10);
           icon.Image = Properties.Resources.host_n_16_3;
           icon.FitSizeToImage();
           icon.Transparent = true;

           SizeF labelSize = GetLineSize(host.ServerName, flowChart.Font);
           Box label = flowChart.CreateBox(pt.X - 16, pt.Y + 10, labelSize.Width, labelSize.Height);
           label.Transparent = true;
           label.FrameColor = Color.Black;
           label.IgnoreLayout = true;
           label.Text = host.ServerName;

           RectangleF rcNode = icon.BoundingRect;
           RectangleF rc = label.BoundingRect;
           rc.X = rcNode.X + rcNode.Width / 2 - rc.Width / 2;
           label.BoundingRect = rc;

           Group g = flowChart.CreateGroup(icon);
           g.AttachToSideMiddle(label, 2);
       }

       private SizeF GetLineSize(String s, Font f)
       {
           Graphics g = flowChart.CreateGraphics();
           g.PageUnit = flowChart.MeasureUnit;
           SizeF size = g.MeasureString(s, f);
           g.Dispose();
           return size;
       }

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