internal Util.WinForms.HitTestResult HitTest(PointT mouseLoc) { var mouseSS = ToShapeSpace(mouseLoc); // SS=Shape Space var htRadiusSS = ToShapeSpace(HitTestRadius); Util.WinForms.HitTestResult best = null; bool bestSel = false; int bestZOrder = 0; foreach (IShapeWidget shapeW in WidgetsOnScreen(mouseLoc)) { var shape = shapeW as Shape; var result = shapeW.HitTest(mouseSS, htRadiusSS, GetSelType(shapeW as Shape)); if (result != null) { Debug.Assert(result.Shape == shapeW); bool resultSel = shape == null || _selectedShapes.Contains(shape); int zOrder = shape != null ? shape.HitTestZOrder : int.MaxValue; // Prefer to hit test against an already-selected shape (unless // it's a panel) or a non-Shape widget, otherwise the thing with // the highest Z-order. if (shape != null && shape.IsPanel) { resultSel = false; } if (best == null || (resultSel && !bestSel) || (bestSel == resultSel && bestZOrder < zOrder)) { best = result; bestSel = resultSel; bestZOrder = zOrder; } } } return(best); }
public override DoOrUndo DoubleClickAction(Util.WinForms.HitTestResult htr) { return(@do => { var t = BoxType; if (@do) { BoxType = (t == BoxType.Rect ? BoxType.Ellipse : t == BoxType.Ellipse ? BoxType.Borderless : BoxType.Rect); } else { BoxType = (t == BoxType.Rect ? BoxType.Borderless : t == BoxType.Borderless ? BoxType.Ellipse : BoxType.Rect); } }); }
public override DoOrUndo DragMoveAction(Util.WinForms.HitTestResult htr, VectorT amount) { if (htr == null || htr.MouseCursor == Cursors.SizeAll) { return(@do => { _bbox = null; var amount2 = @do ? amount : amount.Neg(); for (int i = 0; i < Points.Count; i++) { Points[i] = Points[i].Add(amount2); } }); } return(null); }
public override DoOrUndo DoubleClickAction(Util.WinForms.HitTestResult htr_) { var htr = (HitTestResult)htr_; Arrowhead old = null; if (htr.IsPointHit) { if (htr.PointOrSegment == 0) { return @do => { if (@do) { old = FromArrow; FromArrow = NextArrow(FromArrow); } else { FromArrow = old; } } } ; else if (htr.PointOrSegment == Points.Count - 1) { return @do => { if (@do) { old = ToArrow; ToArrow = NextArrow(ToArrow); } else { ToArrow = old; } } } ; } else { // TODO: switch between curved and straight } return(null); }
public override DoOrUndo DragMoveAction(Util.WinForms.HitTestResult htr_, VectorT amount) { var htr = htr_ as HitTestResult; var rf = htr == null ? RF.Move : htr.ResizeFlags; BoundingBox <float> old = null; return(@do => { if (@do) { old = _bbox.Clone(); Coord x1 = _bbox.X1 + ((rf & RF.Left) != 0 ? amount.X : 0); Coord x2 = _bbox.X2 + ((rf & RF.Right) != 0 ? amount.X : 0); Coord y1 = _bbox.Y1 + ((rf & RF.Top) != 0 ? amount.Y : 0); Coord y2 = _bbox.Y2 + ((rf & RF.Bottom) != 0 ? amount.Y : 0); _bbox = new BoundingBox <float>(x1, y1, x2, y2); _bbox.Normalize(); } else { _bbox = old; } }); }