Hi Brian,
Flowchart.NET deliberately aligns images to the on-screen pixel boundaries by choosing the integer pixel coordinates closest to the floating-point coordinates of the image. Unfortunately, that leads to the images seemingly changing their distance when displayed on screen.
If an image is not aligned to the physical pixel boundaries, the GDI+ DrawImage method renders it blurred, and we have actually implemented the alignment after customers complained about the smeared image appearance.
You could verify this with a similar code -
private void button1_Click(object sender, System.EventArgs e)
{
diagram.DefaultShape = Shapes.Rectangle;
diagram.ShapeText = "";
diagram.AlignToGrid = false;
ShapeNode main = diagram.Factory.CreateShapeNode(0, 0, 100, 100);
for (int i = 0; i < 3; ++i)
{
ShapeNode btn = diagram.Factory.CreateShapeNode(3 + 12*i, 3, 10, 10);
btn.AttachTo(main, AttachToNode.TopLeft);
btn.Transparent = true;
btn.Image = Image.FromFile(@"D:\Images\Icons\all-icons\ac-icons\ac0001\gif\ac0001-32.gif");
btn.ImageAlign = ImageAlign.Center;
}
for (int i = 0; i < 3; ++i)
{
ShapeNode btn = diagram.Factory.CreateShapeNode(3 + 12 * i, 15, 10, 10);
btn.AttachTo(main, AttachToNode.TopLeft);
btn.CustomDraw = CustomDraw.Full;
}
}
private void diagram_DrawNode(object sender, DrawNodeEventArgs e)
{
if (!e.Shadow)
{
Image img = Image.FromFile(@"D:\Images\Icons\all-icons\ac-icons\ac0001\gif\ac0001-32.gif");
e.Graphics.DrawImage(img, e.Bounds.X, e.Bounds.Y);
}
}
If you run this and move the main node, you will notice that the images on the first row always appear quite sharp, but the distance between them seems to change, while the images on the second row keep their distance, but appear blurred.
One option for you would be to switch MeasureUnit to Pixel, and after any node is modified, round its coordinates to their closest integer values.
Another option is to glue the smaller button images into a single large toolbar image. E.g.you could do that dynamically by creating a Bitmap object, calling Graphics.FromImage(the bitmap), and using Image.Draw to draw the smaller images. Then when you get the NodeClicked event for the toolbar node, check over what part of the large bitmap the mouse cursor is located and act accordingly.
I hope that helps,
Stoyan