Hi,
For selection appearance and moving from any point inside node, set HandlesStyle = Custom and handle the Draw/HitTest events like this:
void diagram_DrawAdjustmentHandles(object sender, DrawItemEventArgs e)
{
var node = (DiagramNode)e.Item;
var bounds = node.Bounds;
bounds.Location = new Point();
var handlesStyles = new[] { HandlesStyle.DashFrame, HandlesStyle.SquareHandles };
foreach (var style in handlesStyles)
{
InternalUtils.DrawAdjustmentHandles(
e.Graphics,
diagram.ActiveItemHandlesStyle,
diagram.DisabledHandlesStyle,
bounds,
node.RotationAngle,
node.EnabledHandles & ~AdjustmentHandles.Move,
false,
style,
diagram.AdjustmentHandlesSize,
node);
}
}
private void diagram_HitTestAdjustmentHandles(object sender, HitTestEventArgs e)
{
var node = e.Item as DiagramNode;
var size = new Size(
diagram.AdjustmentHandlesSize,
diagram.AdjustmentHandlesSize);
Rect r = e.Item.GetBounds();
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;
}
}
You could draw the red rectangles from either DrawAnchorPoint, DrawNode or DrawForeground event handlers. For first two options you will have to either set MarkStyle.Custom for anchor points or set node.CustomDraw = Additional.
I hope that helps,
Stoyan