//IVdShape public static object DetectSelectedShape(VdDocument doc, Point pos, TouchDevice d, out Shape resizeNode) { resizeNode = null; HitTestResult htr = VisualTreeHelper.HitTest(doc.Scene, pos); if (htr == null) { return(null); } var cluster = ShapeHitTester.findVdCluster(htr.VisualHit); if (cluster != null) { return(cluster); } var text = ShapeHitTester.findVdText(htr.VisualHit); if (text != null) { return(text); } var badge = ShapeHitTester.findVdBadge(htr.VisualHit); if (badge != null) { return(badge); } var img = ShapeHitTester.findVdImg(htr.VisualHit); if (img != null) { return(img); } //is it resize node? resizeNode = htr.VisualHit as Shape; if (resizeNode != null) { var vdShape = resizeNode.Tag as IVdShape; if (vdShape != null && vdShape.IsVisible()) { return(vdShape); } } //empty area, find nearest shape return(NearestShape(doc, pos)); }
public void InpDeviceDown(Point pos, TouchDevice touchDev) { if (ShapeHitTester.IsPaletteHit(_doc, pos)) { _palette.StartManip(pos, touchDev); return; } DocTools.UnfocusAll(_doc.GetShapes().Where(sh => !sh.IsManipulated())); switch (_modeMgr.Mode) { case ShapeInputMode.CreationExpected: _modeMgr.Mode = ShapeInputMode.ManipulationExpected; CreateManipulate(_palette.shapeType, pos.X, pos.Y); if (_palette != null) { _palette.ResetOvers(); } break; case ShapeInputMode.LinkedObj1Expected: GetLinkables(pos, touchDev); if (linkCreation.end1 != null) { ModeMgr.Mode = ShapeInputMode.LinkedObj2Expected; } break; case ShapeInputMode.LinkedObj2Expected: GetLinkables(pos, touchDev); if (linkCreation.end1 != null && linkCreation.end2 != null) { _doc.BeginCreateLink(linkCreation.end1.GetId(), linkCreation.end2.GetId(), linkCreation.linkHead); linkCreation.end1 = null; linkCreation.end2 = null; ModeMgr.Mode = ShapeInputMode.ManipulationExpected; if (_palette != null) { _palette.ResetOvers(); } } break; case ShapeInputMode.ManipulationExpected: //no current touch points on shapes (maybe touch points over empty space) Shape resizeNode = null; var underContact = DocTools.DetectSelectedShape(_doc, pos, touchDev, out resizeNode) as IVdShape; if (underContact == null) { return; } var shapeFree = underContact.GetCursor() == null; var shapeLockedByUs = false; if (!shapeFree) { shapeLockedByUs = underContact.GetCursor().OwnerId == _palette.GetOwnerId(); } //this shape free and we don't have cursors if (shapeFree && _doc.VolatileCtx.LocalCursor == null) { //shape free, try lock it and schedule cursor approval continuation { cursorApproval.resizeNode = resizeNode; cursorApproval.pos = pos; cursorApproval.td = touchDev; _modeMgr.Mode = ShapeInputMode.CursorApprovalExpected; } //take new local cursor _doc.VolatileCtx.BeginTakeShapeWithLocalCursor(underContact.Id()); } else if (shapeLockedByUs) { CaptureAndStartManip(underContact, pos, resizeNode, touchDev); } break; case ShapeInputMode.Manipulating: break; case ShapeInputMode.CursorApprovalExpected: break; default: throw new NotSupportedException(); } }