Exemplo n.º 1
0
        public CursorMgr(VdDocument doc, IPaletteOwner palette)
        {
            _doc = doc;
            _palette = palette;

            setListeners(true);
        }
Exemplo n.º 2
0
        public CursorMgr(VdDocument doc, IPaletteOwner palette)
        {
            _doc     = doc;
            _palette = palette;

            setListeners(true);
        }
Exemplo n.º 3
0
        //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));
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        //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));
        }
Exemplo n.º 6
0
        //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));
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        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();
        }
Exemplo n.º 13
0
        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();
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
 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;
 }