public override bool HitTest(NPoint point) { this.SelectedPoint = null; this.IsSelected = false; this.MouseState = NMouseState.NONE; if (NMathHelper.Distance(this.Model.StartPoint, point) <= NConfig.HIT_DISTANCE) { this.SelectedPoint = this.Model.StartPoint; this.IsSelected = true; this.MouseState = NMouseState.RESIZE; } else if (NMathHelper.Distance(this.Model.EndPoint, point) <= NConfig.HIT_DISTANCE) { this.SelectedPoint = this.Model.EndPoint; this.IsSelected = true; this.MouseState = NMouseState.RESIZE; } else if (HitTestNodeX(EndNode, point)) { this.IsSelected = true; this.MouseState = NMouseState.MOVE; } return(this.IsSelected); }
private bool HitTestNodeX(NNodeX node, NPoint point) { if (node != null && node.Parent != null) { if (NMathHelper.Distance(node.Point, point) <= NConfig.HIT_DISTANCE) { return(true); } else { return(HitTestNodeX(node.Parent, point)); } } return(false); }
public override void Visit(NBox component) { component.IsCloseEnough = false; for (int i = 0; i < component.ConnectPoints.Length; i++) { double d = NMathHelper.Distance(SelectedPoint, component.ConnectPoints[i]); if (d <= NConfig.CONNECT_DISTANCE) { component.IsCloseEnough = true; if (Connect) { if (Connector.Model.StartPoint == SelectedPoint) { Connector.StartBox = component; Connector.Model.StartBoxIndex = i; Connector.Model.StartBoxID = component.Model.ID; } else { Connector.EndBox = component; Connector.Model.EndBoxIndex = i; Connector.Model.EndBoxID = component.Model.ID; } SelectedPoint.Set(component.ConnectPoints[i]); PathResolver.Connector = Connector; PathResolver.StartPoint = Connector.Model.StartPoint; PathResolver.EndPoint = Connector.Model.EndPoint; PathResolver.RebuildGraph(); PathResolver.Resolve(); return; } } } }