public CursorMgr(VdDocument doc, IPaletteOwner palette) { _doc = doc; _palette = palette; setListeners(true); }
//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 static bool IsPaletteHit(VdDocument doc, Point pos) { HitTestResult htr = VisualTreeHelper.HitTest(doc.Scene, pos); if (htr == null) { return(false); } Ellipse paletteEllipse = htr.VisualHit as Ellipse; return(paletteEllipse != null); }
//ctor for drawing public VdCluster(int owner, int shapeId, VdDocument doc, OnClusterUncluster onClusterUncluster, OnClusterCleanup OnClusterCleanup) : base(owner, shapeId) { _doc = doc; _endpoint = new ClientCluster(shapeId, boundsProvider); _onClusterUncluster = onClusterUncluster; _OnClusterCleanup = OnClusterCleanup; init(DaoUtils.UserIdToColor(owner)); }
public SceneManager(Canvas scene, DistributedInkCanvas ink, Palette palette, InkPalette inkPalette, int topicId, int discussionId, bool shapeVisibility) { _scene = scene; _palette = palette; _ink = ink; _inkPalette = inkPalette; //non-NaN palette coords Canvas.SetLeft(_palette, 200); Canvas.SetTop(_palette, 200); _doc = new VdDocument(palette, scene, ShapePostCtor, topicId, discussionId, shapeVisibility); inkPalette.Init(FinishFreeDrawing, ink); setListeners(true); }
public SceneManager(Canvas scene, DistributedInkCanvas ink, Palette palette, InkPalette inkPalette, int topicId, int discussionId) { _scene = scene; _palette = palette; _ink = ink; _inkPalette = inkPalette; //non-NaN palette coords Canvas.SetLeft(_palette, 200); Canvas.SetTop(_palette, 200); _doc = new VdDocument(palette, scene, ShapePostCtor, topicId, discussionId); _doc.VolatileCtx.localCursorChanged += localCursorChanged; _ink.OnInkChanged += OnLocalInkChanged; inkPalette.Init(finishFreeDrawing); setListeners(true); }
private static IVdShape NearestShape(VdDocument doc, Point point) { IVdShape res = null; double minDist = double.MaxValue; foreach (var sh in doc.GetShapes()) { if (!sh.IsVisible()) { continue; } if (sh.ShapeCode() == VdShapeType.Badge) { continue; } double d_i = sh.distToFigure(point); if (sh.ShapeCode() == VdShapeType.Arrow) { d_i /= 2.0; } if (d_i < minDist) { minDist = d_i; res = sh; } } const double MAX_NEIGHBOURHOOD = 70; if (minDist > MAX_NEIGHBOURHOOD) { res = null; } return(res); }
public VdClusterLink(ClientLinkable end1, ClientLinkable end2, int shapeId, int owner, VdDocument doc, LinkHeadType headType) : base(owner, shapeId) { _doc = doc; _end1 = end1; _end2 = end2; _headType = headType; initLine(DaoUtils.UserIdToColor(owner), headType); //wait until actual size is set line.Dispatcher.BeginInvoke(new Action(() => { NotifyLinkableMoved(); }), System.Windows.Threading.DispatcherPriority.Background); RemoveFocus(); updateUserCursor(); }
static IVdShape NearestShape(VdDocument doc, Point point) { IVdShape res = null; double minDist = double.MaxValue; foreach (var sh in doc.GetShapes()) { double d_i = sh.distToFigure(point); if (d_i < minDist) { minDist = d_i; res = sh; } } const double MAX_NEIGHBOURHOOD = 150; if (minDist > MAX_NEIGHBOURHOOD) { res = null; } return(res); }
public static bool IsPaletteHit(VdDocument doc, Point pos) { HitTestResult htr = VisualTreeHelper.HitTest(doc.Scene, pos); if (htr == null) return false; Ellipse paletteEllipse = htr.VisualHit as Ellipse; return paletteEllipse != null; }