Beispiel #1
0
 //caption was removed
 public void InvalidateCaption(IVdShape caption)
 {
     if (caption == text)
         text = null;
     else if (caption == _freeDraw)
         _freeDraw = null;
 }
Beispiel #2
0
        public void LockIfPossible(IVdShape shape, Shape resizeNode, Point pos, TouchDevice touchDev)
        {
            var shapeFree       = shape.GetCursor() == null;
            var shapeLockedByUs = false;

            if (!shapeFree)
            {
                shapeLockedByUs = shape.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(shape.Id());
            }
            else if (shapeLockedByUs)
            {
                CaptureAndStartManip(shape, pos, resizeNode, touchDev);
            }
        }
Beispiel #3
0
        /// <summary>
        /// call this when
        /// 1. user removes contact points so that local cursor needs to be removed
        /// 2. palette owner changes and we invalidate previous cursor
        /// </summary>
        /// <param name="ownId"></param>
        public void BeginFreeCursor(bool supressClusterMoveEvent)
        {
            //if currently we hold cursor on shape, remove it
            var ownedSh = DocTools.CursorOwnerToShape(_palette.GetOwnerId(), _doc.GetShapes());

            if (ownedSh != null && ownedSh.GetCursor() != null)
            {
                _rt.clienRt.SendCursorRequest(false, _palette.GetOwnerId(), ownedSh.Id(), _doc.TopicId);

                if (_movementDetected)
                {
                    if (ownedSh is VdBadge)
                    {
                        _rt.clienRt.SendStatsEvent(Discussions.model.StEvent.BadgeMoved,
                                                   ownedSh.GetCursor().OwnerId,
                                                   _doc.DiscussionId,
                                                   _doc.TopicId,
                                                   Discussions.model.DeviceType.Wpf);
                    }
                    else if (!supressClusterMoveEvent && ownedSh is VdCluster)
                    {
                        _rt.clienRt.SendStatsEvent(Discussions.model.StEvent.ClusterMoved,
                                                   ownedSh.GetCursor().OwnerId,
                                                   _doc.DiscussionId,
                                                   _doc.TopicId,
                                                   Discussions.model.DeviceType.Wpf);
                    }
                    else if (ownedSh is VdFreeForm)
                    {
                        _rt.clienRt.SendStatsEvent(Discussions.model.StEvent.FreeDrawingMoved,
                                                   ownedSh.GetCursor().OwnerId,
                                                   _doc.DiscussionId,
                                                   _doc.TopicId,
                                                   Discussions.model.DeviceType.Wpf);
                    }
                }

                if (_resizeDetected)
                {
                    if (ownedSh is VdFreeForm)
                    {
                        _rt.clienRt.SendStatsEvent(Discussions.model.StEvent.FreeDrawingResize,
                                                   ownedSh.GetCursor().OwnerId,
                                                   _doc.DiscussionId,
                                                   _doc.TopicId,
                                                   Discussions.model.DeviceType.Wpf);
                    }
                }

                _localCursorShape = null;
                if (localCursorChanged != null)
                {
                    localCursorChanged(this);
                }
            }

            _movementDetected = false;
            _resizeDetected   = false;
        }
Beispiel #4
0
        private void TryEndHostCaption(IVdShape caption, CaptionType type)
        {
            //inject caption
            if (_hostAwaitingCaption == null)
            {
                return;
            }

            RemovePreviousCaption(_hostAwaitingCaption, type);

            if (caption is VdFreeForm)
            {
                _hostAwaitingCaption.CapMgr().FreeDraw = (VdFreeForm)caption;

                //initial resize of free form
                _hostAwaitingCaption.CapMgr().InitialResizeOfFreeForm();

                //send resized free form
                SendSyncState(_hostAwaitingCaption.CapMgr().FreeDraw);

                //cluster + title stats event
                _rt.clienRt.SendStatsEvent(StEvent.ClusterTitleAdded,
                                           _palette.GetOwnerId(),
                                           _doc.DiscussionId,
                                           _doc.TopicId,
                                           DeviceType.Wpf);
            }
            else if (caption is VdText)
            {
                _hostAwaitingCaption.CapMgr().text = (VdText)caption;

                //increase caption font
                //for(int i = 0; i<6; ++i)
                //    _hostAwaitingCaption.CapMgr().text.ScaleInPlace(true);

                SendSyncState(_hostAwaitingCaption.CapMgr().text);

                //cluster + title stats event
                _rt.clienRt.SendStatsEvent(StEvent.ClusterTitleAdded,
                                           _palette.GetOwnerId(),
                                           _doc.DiscussionId,
                                           _doc.TopicId,
                                           DeviceType.Wpf);
            }
            else
            {
                throw new NotSupportedException();
            }

            //update first time after build
            _hostAwaitingCaption.CapMgr().UpdateRelatives();

            //send state of cluster to attach captions on other clients
            SendSyncState(_hostAwaitingCaption);

            _hostAwaitingCaption = null;
        }
Beispiel #5
0
 private void CaptureAndStartManip(IVdShape sh, Point pt, object sender, TouchDevice td)
 {
     sh.StartManip(pt, sender);
     sh.UnderlyingControl().CaptureMouse();
     if (td != null)
     {
         sh.UnderlyingControl().CaptureTouch(td);
     }
     Console.WriteLine("Scene Mgr : CaptureAndStartManip");
 }
Beispiel #6
0
        //shape can be either cluster, text, free draw
        private void CleanupClusterCaptions(IVdShape shape, int indirectOwner)
        {
            ICaptionHost capHost = null;

            switch (shape.ShapeCode())
            {
            case VdShapeType.FreeForm:
                capHost = DocTools.GetCaptionHost(GetShapes(), shape);
                if (capHost != null)
                {
                    capHost.CapMgr().InvalidateCaption(shape);
                }

                //caption removed locally, update cluster
                if (capHost != null && shape.Id() == recentLocallyRemovedShapeId)
                {
                    _rt.clienRt.SendSyncState(capHost.Id(),
                                              capHost.GetState(TopicId));
                }
                break;

            case VdShapeType.Text:
                capHost = DocTools.GetCaptionHost(GetShapes(), shape);
                if (capHost != null)
                {
                    capHost.CapMgr().InvalidateCaption(shape);
                }

                //caption removed locally, update cluster
                if (capHost != null && shape.Id() == recentLocallyRemovedShapeId)
                {
                    _rt.clienRt.SendSyncState(capHost.Id(),
                                              capHost.GetState(TopicId));
                }
                break;

            case VdShapeType.Cluster:
            case VdShapeType.ClusterLink:
                //cluster removed locally, remove captions
                capHost = (ICaptionHost)shape;
                if (indirectOwner == _palette.GetOwnerId())
                {
                    if (capHost.CapMgr().text != null)
                    {
                        BeginRemoveSingleShape(capHost.CapMgr().text.Id());
                    }

                    if (capHost.CapMgr().FreeDraw != null)
                    {
                        BeginRemoveSingleShape(capHost.CapMgr().FreeDraw.Id());
                    }
                }
                break;
            }
        }
Beispiel #7
0
 //caption was removed
 public void InvalidateCaption(IVdShape caption)
 {
     if (caption == text)
     {
         text = null;
     }
     else if (caption == _freeDraw)
     {
         _freeDraw = null;
     }
 }
Beispiel #8
0
        public static ClientLinkable RequestLinkable(IVdShape sh)
        {
            var badge = sh as LinkableHost;

            if (badge != null)
            {
                return(badge.GetLinkable());
            }

            return(null);
        }
Beispiel #9
0
 private void NotifyClusterableMoved(IVdShape sh)
 {
     if (sh.ShapeCode() == VdShapeType.Badge)
     {
         var clustShapes = _doc.GetShapes().Where(sh0 => sh0.ShapeCode() == VdShapeType.Cluster);
         //todo: optimization possible
         foreach (var clust in clustShapes)
         {
             ((VdCluster)clust).ClusterableMoved(((VdBadge)sh).GetClusterable());
         }
     }
 }
Beispiel #10
0
        //if it's real-time creation, shape is locked by its owner.
        //if it's initial loading, we don't lock the shape,
        //lock requests will follow in this case
        public IVdShape PlayCreateShape(VdShapeType shapeType,
                                        int shapeId,
                                        int owner,
                                        double startX,
                                        double startY,
                                        bool takeCursor,
                                        // for badge creation events, it's false, as badges are created in private board
                                        int tag)
        {
            if (!_shapes.ContainsKey(shapeId))
            {
                //update id generator
                if (shapeType != VdShapeType.Badge)
                {
                    ShapeIdGenerator.Instance.CorrectLowBound(owner, shapeId);
                }

                IVdShape res = null;
                switch (shapeType)
                {
                case VdShapeType.Cluster:
                    res = new VdCluster(owner, shapeId, this, onClusterUncluster, OnClusterCleanup);
                    break;

                case VdShapeType.Text:
                    res = new VdText(startX, startY, owner, shapeId);
                    break;

                default:
                    res = DocTools.MakeShape(shapeType, owner, shapeId, startX, startY, tag);
                    break;
                }

                _shapePostHandler(res, shapeType);

                if (!_shapeVisibility)
                {
                    res.Hide();
                }

                this.Add(res);
                DocTools.SortScene(_scene);
                if (takeCursor)
                {
                    VolatileCtx.PlayTakeCursor(owner, shapeId);
                }
                return(res);
            }
            else
            {
                return(_shapes[shapeId]);
            }
        }
Beispiel #11
0
        public static ClientLinkable RequestLinkable(IVdShape sh)
        {
            var badge = sh as LinkableHost;

            if (badge != null)
            {
                return(badge.GetLinkable());
            }

            //var cluster = sh as ClientLinkable;
            //if (cluster != null)
            //    return cluster;

            return(null);
        }
Beispiel #12
0
        private void ReleaseCaptureAndFinishManip(IVdShape sh)
        {
            sh.UnderlyingControl().ReleaseMouseCapture();
            sh.UnderlyingControl().ReleaseAllTouchCaptures();
            sh.FinishManip();

            //if the moved shape is a caption of caption host, save caption host to save new relative position of caption
            var capHost = DocTools.GetCaptionHost(_doc.GetShapes(), sh);

            if (capHost != null)
            {
                capHost.CapMgr().UpdateRelatives();
                SendSyncState(capHost);
            }
        }
Beispiel #13
0
        public void BeginApplyPoint(IVdShape sh,
                                    double X,
                                    double Y)
        {
            if (_doc.clusterRebuildPending)
            {
                return;
            }

            //apply point locally
            switch (sh.ApplyCurrentPoint(new Point(X, Y)))
            {
            case PointApplyResult.None:
                break;

            case PointApplyResult.Move:
                _doc.VolatileCtx.MovementDetected();
                break;

            case PointApplyResult.MoveResize:
                _doc.VolatileCtx.MovementDetected();
                _doc.VolatileCtx.ResizeDetected();
                break;

            case PointApplyResult.Resize:
                _doc.VolatileCtx.ResizeDetected();
                break;

            default:
                throw new NotSupportedException();
            }

            if (sh.ShapeCode() != VdShapeType.ClusterLink)
            {
                SendSyncState(sh);
            }

            switch (sh.ShapeCode())
            {
            case VdShapeType.Badge:
                NotifyClusterableMoved(sh);
                break;

            case VdShapeType.Cluster:
                updateClusterCaptions((VdCluster)sh);
                break;
            }
        }
Beispiel #14
0
        void CaptureAndStartManip(IVdShape sh, Point pt, object sender, TouchDevice td)
        {
            if (sh.ShapeCode() == VdShapeType.Cluster)
            {
                ((VdCluster)sh).Captions.UpdateRelatives();
            }

            sh.StartManip(pt, sender);
            sh.UnderlyingControl().CaptureMouse();
            if (td != null)
            {
                sh.UnderlyingControl().CaptureTouch(td);
            }

            Console.WriteLine("CaptureAndStartManip");
        }
Beispiel #15
0
        public static ICaptionHost GetCaptionHost(IEnumerable <IVdShape> shapes, IVdShape captionShape)
        {
            foreach (var s in shapes)
            {
                var capHost = s as ICaptionHost;
                if (capHost == null)
                {
                    continue;
                }

                if (capHost.CapMgr().text == captionShape || capHost.CapMgr().FreeDraw == captionShape)
                {
                    return(capHost);
                }
            }
            return(null);
        }
Beispiel #16
0
        public void StopManipulation(IVdShape sh, bool stopEvenForText)
        {
            if (sh is VdText && !stopEvenForText)
            {
                return;
            }

            if (_modeMgr.Mode == ShapeInputMode.Manipulating)
            {
                _modeMgr.Mode = ShapeInputMode.ManipulationExpected;
            }
            else if (_modeMgr.Mode == ShapeInputMode.CursorApprovalExpected)
            {
                _modeMgr.Mode = ShapeInputMode.ManipulationExpected;
            }

            if (sh != null)
            {
                //cluster created event ?
                var clust = sh as VdCluster;

                //if this finish manip completes initial cluster drawing, don't generate move event
                var supressClusterMoveEvent = false;

                if (clust != null && !clust.ClusterCreated)
                {
                    supressClusterMoveEvent = true;
                    _rt.clienRt.SendStatsEvent(StEvent.ClusterCreated,
                                               _palette.GetOwnerId(),
                                               _doc.DiscussionId,
                                               _doc.TopicId,
                                               DeviceType.Wpf);
                }

                ReleaseCaptureAndFinishManip(sh);
                _doc.VolatileCtx.BeginFreeCursor(supressClusterMoveEvent);
            }
            else
            {
                _doc.VolatileCtx.NotifyPointUpEvent();
            }
        }
Beispiel #17
0
        void ShapePostCtor(IVdShape sh, VdShapeType shapeType)
        {
            var ctl = sh.UnderlyingControl();

            ctl.IsManipulationEnabled  = true;
            ctl.ManipulationStarting  += ManipulationStarting;
            ctl.ManipulationDelta     += ManipulationDelta;
            ctl.ManipulationCompleted += ManipulationCompleted;

            switch (shapeType)
            {
            case VdShapeType.Text:
                ((VdText)sh).onChanged += onTextChanged;
                break;

            case VdShapeType.Cluster:
                ((VdCluster)sh).InitCaptions(CaptionCreationRequested);
                break;
            }
        }
Beispiel #18
0
        public static VdCluster GetCaptionHost(IEnumerable <IVdShape> shapes, IVdShape captionShape)
        {
            foreach (var s in shapes)
            {
                if (s.ShapeCode() != VdShapeType.Cluster)
                {
                    continue;
                }

                var captions = ((VdCluster)s).Captions;
                if (captions.text == captionShape)
                {
                    return((VdCluster)s);
                }
                else if (captions.FreeDraw == captionShape)
                {
                    return((VdCluster)s);
                }
            }
            return(null);
        }
Beispiel #19
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);
        }
Beispiel #20
0
        public void BeginApplyPoint(IVdShape sh,
            double X,
            double Y)
        {
            if (_doc.clusterRebuildPending)
                return;

            //apply point locally
            switch (sh.ApplyCurrentPoint(new Point(X, Y)))
            {
                case PointApplyResult.None:
                    break;
                case PointApplyResult.Move:
                    _doc.VolatileCtx.MovementDetected();
                    break;
                case PointApplyResult.MoveResize:
                    _doc.VolatileCtx.MovementDetected();
                    _doc.VolatileCtx.ResizeDetected();
                    break;
                case PointApplyResult.Resize:
                    _doc.VolatileCtx.ResizeDetected();
                    break;
                default:
                    throw new NotSupportedException();
            }

            SendSyncState(sh);

            switch (sh.ShapeCode())
            {
                case VdShapeType.Badge:
                    NotifyClusterableMoved(sh);
                    break;
                case VdShapeType.Cluster:
                case VdShapeType.ClusterLink:
                    updateHostCaptions((ICaptionHost) sh);
                    break;
            }
        }
Beispiel #21
0
        void TryEndClusterCaption(IVdShape caption, CaptionType type)
        {
            //inject caption
            if (clusterAwaitingCaption == null)
            {
                return;
            }

            RemovePreviousCaption(clusterAwaitingCaption, type);

            if (caption is VdFreeForm)
            {
                clusterAwaitingCaption.Captions.FreeDraw = (VdFreeForm)caption;

                //initial resize of free form
                clusterAwaitingCaption.Captions.InitialResizeOfFreeForm();

                //send resized free form
                SendSyncState(clusterAwaitingCaption.Captions.FreeDraw);
            }
            else if (caption is VdText)
            {
                clusterAwaitingCaption.Captions.text = (VdText)caption;
                SendSyncState(clusterAwaitingCaption.Captions.text);
            }
            else
            {
                throw new NotSupportedException();
            }

            //update first time after build
            clusterAwaitingCaption.Captions.UpdateRelatives();

            //send state of cluster to attach captions on other clients
            SendSyncState(clusterAwaitingCaption);

            clusterAwaitingCaption = null;
        }
Beispiel #22
0
        public void PlayTakeCursor(int owner, int shapeId)
        {
            cursorCaptureExpected = false;

            //if point up event is pending, and this cursor capture is our,
            //we want to cancel cursor capture. locally it was not set,
            //send cancellation to server
            if (owner == _palette.GetOwnerId() && pointUpEventDuringCursorCapture)
            {
                pointUpEventDuringCursorCapture = false;
                _rt.clienRt.SendCursorRequest(false, owner, shapeId, _doc.TopicId);
                return;
            }

            var sh = _doc.IdToShape(shapeId);

            if (sh == null)
            {
                //error of initialization (not all existing shapes were loaded to local station)
                return;
            }
            if (sh.GetCursor() != null)
            {
                return;
            }

            sh.SetCursor(new Cursor(owner));

            //if owner is local, save local cursor
            if (owner == _palette.GetOwnerId())
            {
                _localCursorShape = sh;
                if (localCursorChanged != null)
                {
                    localCursorChanged(this);
                }
            }
        }
Beispiel #23
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);
        }
Beispiel #24
0
        private void ShapePostCtor(IVdShape sh, VdShapeType shapeType)
        {
            var ctl = sh.UnderlyingControl();

            ctl.IsManipulationEnabled  = true;
            ctl.ManipulationStarting  += ManipulationStarting;
            ctl.ManipulationDelta     += ManipulationDelta;
            ctl.ManipulationCompleted += ManipulationCompleted;

            switch (shapeType)
            {
            case VdShapeType.Text:
                ((VdText)sh).onChanged        += OnTextChanged;
                ((VdText)sh).onEdited         += OnTextEdited;
                ((VdText)sh).onFocusLost      += OnTextFocusLost;
                ((VdText)sh).onCleanupRequest += OnTextCleanup;

                break;

            case VdShapeType.Cluster:
                ((ICaptionHost)sh).InitCaptions(CaptionCreationRequested);
                break;

            case VdShapeType.ClusterLink:
                ((ICaptionHost)sh).InitCaptions(CaptionCreationRequested);

                //if the link was created locally, send its state
                if (sh.Id() == _linkCreation.linkId)
                {
                    SendSyncState(sh);
                    _linkCreation.linkId          = -1;
                    _linkCreation.LastCreatedLink = (VdClusterLink)sh;
                }
                break;
            }
        }
Beispiel #25
0
        /// <summary>
        /// call this when 
        /// 1. user removes contact points so that local cursor needs to be removed
        /// 2. palette owner changes and we invalidate previous cursor
        /// </summary>
        /// <param name="ownId"></param>
        public void BeginFreeCursor(bool supressClusterMoveEvent)
        {     
            //if currently we hold cursor on shape, remove it
            var ownedSh = DocTools.CursorOwnerToShape(_palette.GetOwnerId(), _doc.GetShapes());
            if (ownedSh != null && ownedSh.GetCursor()!=null)
            {
                _rt.clienRt.SendCursorRequest(false, _palette.GetOwnerId(), ownedSh.Id(), _doc.TopicId);

                if (_movementDetected)
                {
                    if (ownedSh is VdBadge)
                    {
                        _rt.clienRt.SendStatsEvent(Discussions.model.StEvent.BadgeMoved,
                                                   ownedSh.GetCursor().OwnerId,
                                                   _doc.DiscussionId,
                                                   _doc.TopicId,
                                                   Discussions.model.DeviceType.Wpf);
                    }
                    else if (!supressClusterMoveEvent && ownedSh is VdCluster)
                    {
                        _rt.clienRt.SendStatsEvent(Discussions.model.StEvent.ClusterMoved,
                                                    ownedSh.GetCursor().OwnerId,
                                                    _doc.DiscussionId,
                                                    _doc.TopicId,
                                                    Discussions.model.DeviceType.Wpf);
                    }
                    else if (ownedSh is VdFreeForm)
                    {
                        _rt.clienRt.SendStatsEvent(Discussions.model.StEvent.FreeDrawingMoved,
                                                    ownedSh.GetCursor().OwnerId,
                                                    _doc.DiscussionId,
                                                    _doc.TopicId,
                                                    Discussions.model.DeviceType.Wpf);
                    }
                }

                if (_resizeDetected)
                {
                    if (ownedSh is VdFreeForm)
                    {
                        _rt.clienRt.SendStatsEvent(Discussions.model.StEvent.FreeDrawingResize,
                                                    ownedSh.GetCursor().OwnerId,
                                                    _doc.DiscussionId,
                                                    _doc.TopicId,
                                                    Discussions.model.DeviceType.Wpf);
                    }
                }

                _localCursorShape = null;
                if (localCursorChanged != null)
                    localCursorChanged(this);
            }

            _movementDetected = false;
            _resizeDetected = false; 
        }
Beispiel #26
0
        private void ShapePostCtor(IVdShape sh, VdShapeType shapeType)
        {
            var ctl = sh.UnderlyingControl();
            ctl.IsManipulationEnabled = true;
            ctl.ManipulationStarting += ManipulationStarting;
            ctl.ManipulationDelta += ManipulationDelta;
            ctl.ManipulationCompleted += ManipulationCompleted;

            switch (shapeType)
            {
                case VdShapeType.Text:
                    ((VdText) sh).onChanged += OnTextChanged;
                    ((VdText)sh).onEdited += OnTextEdited;
                    ((VdText)sh).onFocusLost += OnTextFocusLost;
                    ((VdText) sh).onCleanupRequest += OnTextCleanup;

                    break;
                case VdShapeType.Cluster:
                    ((ICaptionHost) sh).InitCaptions(CaptionCreationRequested);
                    break;
                case VdShapeType.ClusterLink:
                    ((ICaptionHost) sh).InitCaptions(CaptionCreationRequested);

                    //if the link was created locally, send its state
                    if (sh.Id() == _linkCreation.linkId)
                    {
                        SendSyncState(sh);
                        _linkCreation.linkId = -1;
                        _linkCreation.LastCreatedLink = (VdClusterLink)sh;
                    }
                    break;
            }
        }
Beispiel #27
0
        //shape can be either cluster, text, free draw
        void CleanupClusterCaptions(IVdShape shape, int indirectOwner)
        {
            VdCluster changedCluster = null;
            switch (shape.ShapeCode())
            {               
                case VdShapeType.FreeForm:
                    changedCluster = DocTools.GetCaptionHost(GetShapes(), shape);
                    if (changedCluster != null)
                        changedCluster.Captions.InvalidateCaption(shape);   
                   
                    //caption removed locally, update cluster 
                    if (changedCluster != null && shape.Id() == recentLocallyRemovedShapeId)
                    {                                
                        _rt.clienRt.SendSyncState(changedCluster.Id(),
                                                  changedCluster.GetState(TopicId));
                    }                     
                    break;
                case VdShapeType.Text:
                    changedCluster = DocTools.GetCaptionHost(GetShapes(), shape);
                    if (changedCluster != null)
                        changedCluster.Captions.InvalidateCaption(shape);    
                    
                    //caption removed locally, update cluster 
                    if (changedCluster != null && shape.Id() == recentLocallyRemovedShapeId)
                    {                                
                        _rt.clienRt.SendSyncState(changedCluster.Id(),
                                                  changedCluster.GetState(TopicId));
                    }  
                    break;
                case VdShapeType.Cluster:
                    //cluster removed locally, remove captions
                    changedCluster = (VdCluster)shape;
                    if (indirectOwner == _palette.GetOwnerId())                   
                    {
                        if (changedCluster.Captions.text!=null)
                        {
                            BeginRemoveSingleShape(changedCluster.Captions.text.Id());                       
                        }

                        if (changedCluster.Captions.FreeDraw != null)
                        {
                            BeginRemoveSingleShape(changedCluster.Captions.FreeDraw.Id());                      
                        }    
                    }
                    break;
            }   
        }
Beispiel #28
0
 public void SendSyncState(IVdShape sh)
 {
     _rt.clienRt.SendSyncState(sh.Id(), sh.GetState(_doc.TopicId));
 }
Beispiel #29
0
        void TryEndClusterCaption(IVdShape caption, CaptionType type)
        {
            //inject caption
            if (clusterAwaitingCaption == null)
                return;

            RemovePreviousCaption(clusterAwaitingCaption, type);

            if (caption is VdFreeForm)
            {
                clusterAwaitingCaption.Captions.FreeDraw = (VdFreeForm)caption;
                
                //initial resize of free form
                clusterAwaitingCaption.Captions.InitialResizeOfFreeForm();

                //send resized free form 
                SendSyncState(clusterAwaitingCaption.Captions.FreeDraw);
            }
            else if (caption is VdText)
            {
                clusterAwaitingCaption.Captions.text = (VdText)caption;
                SendSyncState(clusterAwaitingCaption.Captions.text);
            }
            else
                throw new NotSupportedException();

            //update first time after build
            clusterAwaitingCaption.Captions.UpdateRelatives();

            //send state of cluster to attach captions on other clients 
            SendSyncState(clusterAwaitingCaption);
               
            clusterAwaitingCaption = null;            
        }
Beispiel #30
0
 void ReleaseCaptureAndFinishManip(IVdShape sh)
 {
     sh.UnderlyingControl().ReleaseMouseCapture();
     sh.UnderlyingControl().ReleaseAllTouchCaptures();
     sh.FinishManip();
 }
Beispiel #31
0
 //we have editing permission if either shape is free or if shape is cursored by us
 private bool editingPermission(IVdShape sh)
 {
     var noPermission = sh.GetCursor() != null && sh.GetCursor().OwnerId != _palette.GetOwnerId();
     return !noPermission;
 }
Beispiel #32
0
 public bool Contains(IVdShape sh)
 {
     return(_shapes.ContainsKey(sh.Id()));
 }
Beispiel #33
0
 private void NotifyClusterableMoved(IVdShape sh)
 {
     if (sh.ShapeCode() == VdShapeType.Badge)
     {
         var clustShapes = _doc.GetShapes().Where(sh0 => sh0.ShapeCode() == VdShapeType.Cluster);
         //todo: optimization possible
         foreach (var clust in clustShapes)
         {
             ((VdCluster) clust).ClusterableMoved(((VdBadge) sh).GetClusterable());
         }
     }
 }
Beispiel #34
0
        private void TryEndHostCaption(IVdShape caption, CaptionType type)
        {
            //inject caption
            if (_hostAwaitingCaption == null)
                return;

            RemovePreviousCaption(_hostAwaitingCaption, type);

            if (caption is VdFreeForm)
            {
                _hostAwaitingCaption.CapMgr().FreeDraw = (VdFreeForm)caption;

                //initial resize of free form
                _hostAwaitingCaption.CapMgr().InitialResizeOfFreeForm();

                //send resized free form
                SendSyncState(_hostAwaitingCaption.CapMgr().FreeDraw);

                //cluster + title stats event
                _rt.clienRt.SendStatsEvent(StEvent.ClusterTitleAdded,
                                            _palette.GetOwnerId(),
                                            _doc.DiscussionId,
                                            _doc.TopicId,
                                            DeviceType.Wpf);
            }
            else if (caption is VdText)
            {
                _hostAwaitingCaption.CapMgr().text = (VdText)caption;

                //increase caption font
                //for(int i = 0; i<6; ++i)
                //    _hostAwaitingCaption.CapMgr().text.ScaleInPlace(true);

                SendSyncState(_hostAwaitingCaption.CapMgr().text);

                //cluster + title stats event
                _rt.clienRt.SendStatsEvent(StEvent.ClusterTitleAdded,
                                            _palette.GetOwnerId(),
                                            _doc.DiscussionId,
                                            _doc.TopicId,
                                            DeviceType.Wpf);
            }
            else
                throw new NotSupportedException();

            //update first time after build
            _hostAwaitingCaption.CapMgr().UpdateRelatives();

            //send state of cluster to attach captions on other clients
            SendSyncState(_hostAwaitingCaption);

            _hostAwaitingCaption = null;
        }
Beispiel #35
0
        //we have editing permission if either shape is free or if shape is cursored by us
        private bool editingPermission(IVdShape sh)
        {
            var noPermission = sh.GetCursor() != null && sh.GetCursor().OwnerId != _palette.GetOwnerId();

            return(!noPermission);
        }
Beispiel #36
0
        void ShapePostCtor(IVdShape sh, VdShapeType shapeType)
        {
            var ctl = sh.UnderlyingControl();
            ctl.IsManipulationEnabled = true;
            ctl.ManipulationStarting += ManipulationStarting;
            ctl.ManipulationDelta += ManipulationDelta;
            ctl.ManipulationCompleted += ManipulationCompleted;

            switch (shapeType)
            {
                case VdShapeType.Text:
                    ((VdText)sh).onChanged += onTextChanged;
                    break;
                case VdShapeType.Cluster:
                    ((VdCluster)sh).InitCaptions(CaptionCreationRequested);
                    break;
            }           
        }
Beispiel #37
0
 private void Add(IVdShape shape)
 {
     shape.AttachToCanvas(_scene);
     _shapes.Add(shape.Id(), shape);
 }
Beispiel #38
0
        void CaptureAndStartManip(IVdShape sh, Point pt, object sender, TouchDevice td)
        {
            if (sh.ShapeCode() == VdShapeType.Cluster)
            {
                ((VdCluster)sh).Captions.UpdateRelatives();
            }
            
            sh.StartManip(pt, sender);
            sh.UnderlyingControl().CaptureMouse();
            if (td != null)
                sh.UnderlyingControl().CaptureTouch(td);

            Console.WriteLine("CaptureAndStartManip");
        }
Beispiel #39
0
 private void CaptureAndStartManip(IVdShape sh, Point pt, object sender, TouchDevice td)
 {
     sh.StartManip(pt, sender);
     sh.UnderlyingControl().CaptureMouse();
     if (td!=null)
         sh.UnderlyingControl().CaptureTouch(td);
     Console.WriteLine("Scene Mgr : CaptureAndStartManip");
 }
Beispiel #40
0
        public void StopManipulation(IVdShape sh, bool stopEvenForText)
        {
            if (sh is VdText && !stopEvenForText)
                return;

            if (_modeMgr.Mode == ShapeInputMode.Manipulating)
            {
                _modeMgr.Mode = ShapeInputMode.ManipulationExpected;
            }
            else if (_modeMgr.Mode == ShapeInputMode.CursorApprovalExpected)
            {
                _modeMgr.Mode = ShapeInputMode.ManipulationExpected;
            }

            if (sh != null)
            {
                //cluster created event ?
                var clust = sh as VdCluster;

                //if this finish manip completes initial cluster drawing, don't generate move event
                var supressClusterMoveEvent = false;

                if (clust != null && !clust.ClusterCreated)
                {
                    supressClusterMoveEvent = true;
                    _rt.clienRt.SendStatsEvent(StEvent.ClusterCreated,
                                               _palette.GetOwnerId(),
                                               _doc.DiscussionId,
                                               _doc.TopicId,
                                               DeviceType.Wpf);
                }

                ReleaseCaptureAndFinishManip(sh);
                _doc.VolatileCtx.BeginFreeCursor(supressClusterMoveEvent);
            }
            else
            {
                _doc.VolatileCtx.NotifyPointUpEvent();
            }
        }
Beispiel #41
0
 public void SendSyncState(IVdShape sh)
 {
     _rt.clienRt.SendSyncState(sh.Id(), sh.GetState(_doc.TopicId));
 }
Beispiel #42
0
 void ReleaseCaptureAndFinishManip(IVdShape sh)
 {
     sh.UnderlyingControl().ReleaseMouseCapture();
     sh.UnderlyingControl().ReleaseAllTouchCaptures();
     sh.FinishManip();
 }
Beispiel #43
0
        public void LockIfPossible(IVdShape shape, Shape resizeNode, Point pos, TouchDevice touchDev)
        {
            var shapeFree = shape.GetCursor() == null;
            var shapeLockedByUs = false;
            if (!shapeFree)
                shapeLockedByUs = shape.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(shape.Id());
            }
            else if (shapeLockedByUs)
            {
                CaptureAndStartManip(shape, pos, resizeNode, touchDev);
            }
        }
Beispiel #44
0
 public bool Contains(IVdShape sh)
 {
     return shapes.ContainsKey(sh.Id());
 }
Beispiel #45
0
        public void PlayTakeCursor(int owner, int shapeId)
        {
            cursorCaptureExpected = false;
            
            //if point up event is pending, and this cursor capture is our,  
            //we want to cancel cursor capture. locally it was not set, 
            //send cancellation to server 
            if (owner == _palette.GetOwnerId() && pointUpEventDuringCursorCapture)
            {
                pointUpEventDuringCursorCapture = false;
                _rt.clienRt.SendCursorRequest(false, owner, shapeId, _doc.TopicId);
                return;
            }

            var sh = _doc.IdToShape(shapeId);
            if (sh == null)
            {
                //error of initialization (not all existing shapes were loaded to local station)
                return;
            }
            if (sh.GetCursor() != null)
                return;

            sh.SetCursor(new Cursor(owner));

            //if owner is local, save local cursor
            if (owner == _palette.GetOwnerId())
            {
                _localCursorShape = sh;
                if (localCursorChanged != null)
                    localCursorChanged(this);
            }                       
        }
Beispiel #46
0
 void Add(IVdShape shape)
 {
     shape.AttachToCanvas(_scene);
     shapes.Add(shape.Id(), shape);
 }
Beispiel #47
0
        private void ReleaseCaptureAndFinishManip(IVdShape sh)
        {
            sh.UnderlyingControl().ReleaseMouseCapture();
            sh.UnderlyingControl().ReleaseAllTouchCaptures();
            sh.FinishManip();

            //if the moved shape is a caption of caption host, save caption host to save new relative position of caption
            var capHost = DocTools.GetCaptionHost(_doc.GetShapes(), sh);
            if (capHost != null)
            {
                capHost.CapMgr().UpdateRelatives();
                SendSyncState(capHost);
            }
        }