Actually, on further investigation (sorry, it's been a few months since I've used these classes), I think I can probably use grouping or ControlHost Attach To to achieve a decent outcome.
I have a few questions though.
Using the code below,
- The Control Host is not attaching below the image, sort of left centered above it (regardless of what AttachTo enum I chose)
- The resize of the control host to fit the text label is giving the incorrect size. Is there a 'Fit To Control' style method/option?
- I have noticed that the size of the image in pixels does not match the box size either, if the image is 16x16 this gives a larger box?
public class ImageBox
{
Box box;
ControlHost chText;
TextBox text;
FlowChart chart;
public ImageBox(FlowChart chart, Image image, PointF pointf)
{
this.chart = chart;
//Create Main Image Box
box = CreateBox(chart, pointf);
box.Image = image;
box.ImageAlign = ImageAlign.Stretch;
box.Transparent = true;
//Create Text Box
text = new TextBox();
text.Text = "Attach Me Please";
text.BorderStyle = BorderStyle.None;
chText = new ControlHost(chart);
chText.Control = text;
chText.ShadowOffsetX = 0f;
chText.ShadowOffsetY = 0f;
chText.Resize(text.Width, chText.BoundingRect.Height);
chText.AttachTo(box, AttachToNode.BottomCenter);
//chText.MasterGroup.Ex = new RectangleF(box.BoundingRect.X, box.BoundingRect.Y, (float)text.Width, box.BoundingRect.Height);
//Group grp = chart.CreateGroup(box);
//grp.AttachProportional(box, 10f, 10f, 50f, 10f);
}
private Box CreateBox(FlowChart chart, PointF pointf)
{
//Create Box
Box box = chart.CreateBox(pointf.X, pointf.Y, 8f, 8f);
//constraints
box.Constraints.MaxWidth = 8f;
box.Constraints.MaxHeight = 8f;
box.Constraints.MinHeight = 8f;
box.Constraints.MinWidth = 8f;
//Handle Style
box.HandlesStyle = HandlesStyle.MoveOnly;
return box;
}
}
Any thought would be appreciated
(I am still interested how the NetSample works as well)
Thanks
JC