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()); } }
//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; } }
//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]); } }
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")); }
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")); }
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; } }
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; }
//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]; } }
void updateClusterCaptions(VdCluster cluster) { cluster.Captions.SetBounds(); }
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; } }
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; }
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()); }
void BeginClusterCaption(VdCluster cluster, CaptionType type) { clusterAwaitingCaption = cluster; RemovePreviousCaption(cluster, type); }
void updateClusterCaptions(VdCluster cluster) { cluster.Captions.SetBounds(); }
void BeginClusterCaption(VdCluster cluster, CaptionType type) { clusterAwaitingCaption = cluster; RemovePreviousCaption(cluster, type); }