Пример #1
0
 void RemovePreviousCaption(VdCluster cluster, CaptionType type)
 {
     if (clusterAwaitingCaption.Captions.FreeDraw != null)
     {
         _doc.BeginRemoveSingleShape(clusterAwaitingCaption.Captions.FreeDraw.Id());
     }
     if (clusterAwaitingCaption.Captions.text != null)
     {
         _doc.BeginRemoveSingleShape(clusterAwaitingCaption.Captions.text.Id());
     }
 }
Пример #2
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;
            }
        }
Пример #3
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]);
            }
        }
Пример #4
0
        public ClusterCaptions(VdCluster cluster, CaptionCreationRequested captionCreationRequested)
        {
            this.cluster = cluster;

            _captionCreationRequested = captionCreationRequested;

            btnDraw = new ClusterButton();
            btnDraw.btn.Click += __bntDraw;
            btnDraw.SetBrush((System.Windows.Media.Brush)Application.Current.TryFindResource("editBrush"));

            btnType = new ClusterButton();
            btnType.btn.Click += __bntType;
            btnType.SetBrush((System.Windows.Media.Brush)Application.Current.TryFindResource("typeBrush"));
        }
Пример #5
0
        public ClusterCaptions(VdCluster cluster, CaptionCreationRequested captionCreationRequested)
        {
            this.cluster = cluster;

            _captionCreationRequested = captionCreationRequested;

            btnDraw            = new ClusterButton();
            btnDraw.btn.Click += __bntDraw;
            btnDraw.SetBrush((System.Windows.Media.Brush)Application.Current.TryFindResource("editBrush"));

            btnType            = new ClusterButton();
            btnType.btn.Click += __bntType;
            btnType.SetBrush((System.Windows.Media.Brush)Application.Current.TryFindResource("typeBrush"));
        }
Пример #6
0
        void CaptionCreationRequested(CaptionType type, VdCluster cluster)
        {
            BeginClusterCaption(cluster, type);
            switch (type)
            {
            case CaptionType.FreeDraw:
                EnterShapeCreationMode(VdShapeType.FreeForm);
                break;

            case CaptionType.Text:
                //emulate text creation
                _palette.shapeType = VdShapeType.Text;
                EnterShapeCreationMode(VdShapeType.Text);
                var clustBounds = cluster.boundsProvider();
                InpDeviceDown(new Point(clustBounds.X + 140, clustBounds.Y - 160), null);
                break;
            }
        }
Пример #7
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;
        }
Пример #8
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, OnTextCleanup);
                        break;
                    default:
                        res = DocTools.MakeShape(shapeType, owner, shapeId, startX, startY, tag);
                        break;
                }                

                _shapePostHandler(res, shapeType);
                this.Add(res);
                DocTools.SortScene(_scene);
                if(takeCursor)
                    VolatileCtx.PlayTakeCursor(owner, shapeId);
                return res;
            }
            else
            {
                return shapes[shapeId];
            }
        }
Пример #9
0
 void updateClusterCaptions(VdCluster cluster)
 {
     cluster.Captions.SetBounds();
 }
Пример #10
0
 void CaptionCreationRequested(CaptionType type, VdCluster cluster)
 {
     BeginClusterCaption(cluster, type);
     switch (type)
     {
         case CaptionType.FreeDraw:
             EnterShapeCreationMode(VdShapeType.FreeForm);
             break;
         case CaptionType.Text:
             //emulate text creation              
             _palette.shapeType = VdShapeType.Text;
             EnterShapeCreationMode(VdShapeType.Text);                    
             var clustBounds = cluster.boundsProvider();
             InpDeviceDown(new Point(clustBounds.X + 140, clustBounds.Y- 160), null);                   
             break;
     }
 }
Пример #11
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;            
        }
Пример #12
0
 void RemovePreviousCaption(VdCluster cluster, CaptionType type)
 {
     if (clusterAwaitingCaption.Captions.FreeDraw != null)
         _doc.BeginRemoveSingleShape(clusterAwaitingCaption.Captions.FreeDraw.Id());
     if (clusterAwaitingCaption.Captions.text != null)
         _doc.BeginRemoveSingleShape(clusterAwaitingCaption.Captions.text.Id());
 }
Пример #13
0
        void BeginClusterCaption(VdCluster cluster, CaptionType type)
        {            
            clusterAwaitingCaption = cluster;

            RemovePreviousCaption(cluster, type);
        }
Пример #14
0
 void updateClusterCaptions(VdCluster cluster)
 {
     cluster.Captions.SetBounds();
 }
Пример #15
0
        void BeginClusterCaption(VdCluster cluster, CaptionType type)
        {
            clusterAwaitingCaption = cluster;

            RemovePreviousCaption(cluster, type);
        }