Beispiel #1
0
        void GetLinkables(Point pos, TouchDevice d)
        {
            Shape resizeNode = null;
            var   sh         = DocTools.DetectSelectedShape(_doc, pos, d, out resizeNode) as IVdShape;
            var   end        = DocTools.RequestLinkable(sh);

            if (end == null)
            {
                MessageBox.Show("Badges or clusters are accepted as link endpoints",
                                "Tip",
                                MessageBoxButton.OK,
                                MessageBoxImage.Information);
                return;
            }

            if (linkCreation.end1 == null)
            {
                linkCreation.end1 = end;
            }
            else if (end == linkCreation.end1)
            {
                MessageBox.Show("Cannot link object with itself",
                                "Error",
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
            else
            {
                linkCreation.end2 = end;
            }
        }
Beispiel #2
0
        private void GetLinkables(Point pos, TouchDevice d)
        {
            Shape resizeNode = null;
            var   sh         = DocTools.DetectSelectedShape(_doc, pos, d, out resizeNode) as IVdShape;
            var   end        = DocTools.RequestLinkable(sh);

            if (end == null)
            {
                MessageDlg.Show("Can only link points and groups/付箋とグループ以外はリンクできません",
                                "Tip",
                                MessageBoxButton.OK,
                                MessageBoxImage.Information);
                _palette.ResetTool();
                _modeMgr.Mode = ShapeInputMode.ManipulationExpected;
                return;
            }

            if (_linkCreation.end1 == null)
            {
                _linkCreation.end1 = end;
            }
            else if (end == _linkCreation.end1)
            {
                _palette.ResetTool();
                _modeMgr.Mode = ShapeInputMode.ManipulationExpected;
                MessageDlg.Show("Cannot link points with itself/同じ付箋・グループをリンクする事はできません",
                                "Error",
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
            else
            {
                _linkCreation.end2 = end;
            }
        }
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
 public void ShowShapes()
 {
     foreach (var sh in GetShapes())
     {
         sh.Show();
     }
     DocTools.UnfocusAll(GetShapes());
     _shapeVisibility = true;
 }
Beispiel #5
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 #6
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 #7
0
        VdClusterLink PlayLinkCreate(ClientLinkable end1, ClientLinkable end2,
                                     int shapeId, int initOwnerId, bool takeCursor)
        {
            ShapeIdGenerator.Instance.CorrectLowBound(initOwnerId, shapeId);
            var res = new VdClusterLink(end1, end2, shapeId, initOwnerId);

            end1.AddEdge(res);
            end2.AddEdge(res);
            //no post handler for cluster link
            this.Add(res);
            DocTools.SortScene(_scene);
            //no initial lock, as link is created in free state (no pressed buttons)
            return(res);
        }
Beispiel #8
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 #9
0
        private VdClusterLink PlayLinkCreate(ClientLinkable end1, ClientLinkable end2,
                                             int shapeId, int initOwnerId, bool takeCursor,
                                             LinkHeadType linkHead)
        {
            ShapeIdGenerator.Instance.CorrectLowBound(initOwnerId, shapeId);
            var res = new VdClusterLink(end1, end2, shapeId, initOwnerId, this, linkHead);

            _shapePostHandler(res, VdShapeType.ClusterLink);
            end1.AddEdge(res);
            end2.AddEdge(res);

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

            //no post handler for cluster link

            this.Add(res);

            DocTools.SortScene(_scene);
            //no initial lock, as link is created in free state (no pressed buttons)
            return(res);
        }
Beispiel #10
0
 private void ReloadBadgeContexts()
 {
     BadgesCtx.DropContext();
     DocTools.ToggleBadgeContexts(BadgesCtx.Get(),
                                  _doc.GetShapes().Where(sh => sh.ShapeCode() == VdShapeType.Badge));
 }
Beispiel #11
0
        public bool InpDeviceDown(Point pos, TouchDevice touchDev)
        {
            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();
                }
                return(true);

            case ShapeInputMode.LinkedObj1Expected:
                GetLinkables(pos, touchDev);
                if (_linkCreation.end1 != null)
                {
                    ModeMgr.Mode = ShapeInputMode.LinkedObj2Expected;
                }
                return(true);

            case ShapeInputMode.LinkedObj2Expected:
                GetLinkables(pos, touchDev);
                if (_linkCreation.end1 != null && _linkCreation.end2 != null)
                {
                    _linkCreation.linkId = _doc.BeginCreateLink(_linkCreation.end1.GetId(), _linkCreation.end2.GetId(),
                                                                _linkCreation.headType);
                    _linkCreation.end1 = null;
                    _linkCreation.end2 = null;
                    ModeMgr.Mode       = ShapeInputMode.ManipulationExpected;

                    if (_palette != null)
                    {
                        _palette.ResetOvers();
                    }
                }
                return(true);

            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(false);
                }

                LockIfPossible(underContact, resizeNode, pos, touchDev);
                return(true);

            case ShapeInputMode.Manipulating:
                DocTools.UnfocusAll(_doc.GetShapes().Where(sh => !sh.IsManipulated()));
                StopManipulation(_doc.VolatileCtx.LocalCursor, true);
                return(true);

            case ShapeInputMode.CursorApprovalExpected:
                return(true);

            default:
                throw new NotSupportedException();
            }
        }
Beispiel #12
0
        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();
            }
        }