Hello
I woring with custom handles.
I found2 troubles.
1- when i select multiple circular shapes, the 4 handles of corners not resize, work as move.
Only gandlers of the middle act as resize.
Something i missing on the code?
2- Kike can observ the handles are 20x20 pixels.
I note handler act like if point of control is the top border near to bounds of node.
If i catch the handler in any point position not near to border, when i resize is see a Little jumps in the size of the objject.
In this way resize object with presicion is a big problema.
I mniss something in the coe or is related to mindfusion diagram component?
I note this also happen with non custom handlers.
For reproduce this, just use this handlers and try resize any node selectinng the handler from near to internal corner of handler.
How can correct this?
private void form_HitTestAdjustmentHandles(object sender, HitTestEventArgs e)
{
var node = e.Item as DiagramNode;
var size2 = new Size(form.AdjustmentHandlesSize, form.AdjustmentHandlesSize);
var size = new Size( 20,20);
Rect r = e.Item.GetBounds();
if (r.Contains(e.MousePosition))
e.HitResult = 8;
if (node != null)
{
var location = node.Bounds.Location;
var diagOffset = new Vector(location.X, location.Y);
double rotationAngle = node.RotationAngle;
Point localPoint = RotatePointAt(e.MousePosition, node.GetCenter(), -rotationAngle);
if (r.Contains(localPoint))
{
e.HitResult = 8;
}
localPoint = localPoint - diagOffset;
var TopLeft = new Point(0, 0);
var TopLeftRect = new Rect(TopLeft, size);
if (TopLeftRect.Contains(localPoint))
e.HitResult = 0;
var TopMiddle = new Point(node.Bounds.Width / 2 - size.Width / 2, 0);
var TopMiddleRect = new Rect(TopMiddle, size);
if (TopMiddleRect.Contains(localPoint))
e.HitResult = 4;
var TopRight = new Point(node.Bounds.Width - size.Width, 0);
var TopRightRect = new Rect(TopRight, size);
if (TopRightRect.Contains(localPoint))
e.HitResult = 1;
var MiddleLeft = new Point(0, node.Bounds.Height / 2 - size.Height / 2);
var MiddleLeftRect = new Rect(MiddleLeft, size);
if (MiddleLeftRect.Contains(localPoint))
e.HitResult = 7;
var MiddleRight = new Point(node.Bounds.Width - size.Width, node.Bounds.Height / 2 - size.Height / 2);
var MiddleRightRect = new Rect(MiddleRight, size);
if (MiddleRightRect.Contains(localPoint))
e.HitResult = 5;
var bottomLeft = new Point(0, node.Bounds.Height - size.Height);
var bottomLeftRect = new Rect(bottomLeft, size);
if (bottomLeftRect.Contains(localPoint))
e.HitResult = 3;
var bottomMiddle = new Point(node.Bounds.Width / 2 - size.Width / 2, node.Bounds.Height - size.Height);
var bottomMiddleRect = new Rect(bottomMiddle, size);
if (bottomMiddleRect.Contains(localPoint))
e.HitResult = 6;
var bottomRight = new Point(node.Bounds.Width - size.Width, node.Bounds.Height - size.Height);
var bottomRightRect = new Rect(bottomRight, size);
if (bottomRightRect.Contains(localPoint))
e.HitResult = 2;
}
}
void form_DrawAdjustmentHandles(object sender, DrawItemEventArgs e)
{
var node = e.Item as DiagramNode;
var size2 = new Size(form.AdjustmentHandlesSize,form.AdjustmentHandlesSize);
var size = new Size(20, 20);
if (node != null)
{
var TopLeft = new Point(0, 0);
e.Graphics.DrawRectangle(form.SelectedItemHandlesStyle.PatternBrush, form.SelectedItemHandlesStyle.DashPen, new Rect(TopLeft, size));
var TopMiddle = new Point(node.Bounds.Width / 2 - size.Width / 2, 0);
e.Graphics.DrawRectangle(form.SelectedItemHandlesStyle.PatternBrush, form.SelectedItemHandlesStyle.DashPen, new Rect(TopMiddle, size));
var TopRight = new Point(node.Bounds.Width - size.Width , 0);
e.Graphics.DrawRectangle(form.SelectedItemHandlesStyle.PatternBrush, form.SelectedItemHandlesStyle.DashPen, new Rect(TopRight, size));
var MiddleTop = new Point(0, node.Bounds.Height /2 - size.Height /2);
e.Graphics.DrawRectangle(form.SelectedItemHandlesStyle.PatternBrush, form.SelectedItemHandlesStyle.DashPen, new Rect(MiddleTop, size));
var MiddleBott = new Point(node.Bounds.Width - size.Width, node.Bounds.Height / 2 - size.Height / 2);
e.Graphics.DrawRectangle(form.SelectedItemHandlesStyle.PatternBrush, form.SelectedItemHandlesStyle.DashPen, new Rect(MiddleBott, size));
var bottomLeft = new Point(0, node.Bounds.Height - size.Height);
e.Graphics.DrawRectangle(form.SelectedItemHandlesStyle.PatternBrush, form.SelectedItemHandlesStyle.DashPen, new Rect(bottomLeft, size));
var bottomMiddle = new Point(node.Bounds.Width / 2 - size.Width / 2, node.Bounds.Height - size.Height);
e.Graphics.DrawRectangle(form.SelectedItemHandlesStyle.PatternBrush, form.SelectedItemHandlesStyle.DashPen, new Rect(bottomMiddle, size));
var bottomRight = new Point(node.Bounds.Width - size.Width ,node.Bounds.Height - size.Height);
e.Graphics.DrawRectangle(form.SelectedItemHandlesStyle.PatternBrush, form.SelectedItemHandlesStyle.DashPen, new Rect(bottomRight, size));
}
}