public static IVdShape MakeShape(VdShapeType shapeType, int owner, int shapeId, double startX, double startY, int tag) { switch ((VdShapeType)shapeType) { case VdShapeType.Segment: return(new VdSegment(startX, startY, startX + 1, startY + 1, owner, shapeId)); case VdShapeType.Arrow: return(new VdArrow(startX, startY, startX + 1, startY + 1, owner, shapeId)); case VdShapeType.FreeForm: return(new VdFreeForm(shapeId, owner)); case VdShapeType.Badge: return(new VdBadge(startX, startY, owner, shapeId, tag)); default: throw new NotSupportedException(); } }
public ServerBaseVdShape(int id, int initOwner, VdShapeType shapeType, int tag) { _id = id; _initOwner = initOwner; _shapeType = shapeType; _tag = tag; }
public void EnterShapeCreationMode(VdShapeType shapeType, int shapeTag) { if (shapeType == VdShapeType.None) { _linkCreation.end1 = _linkCreation.end2 = null; _modeMgr.Mode = ShapeInputMode.ManipulationExpected; return; } if (_doc.VolatileCtx.LocalCursor != null) { _palette.ResetOvers(); _modeMgr.Mode = ShapeInputMode.ManipulationExpected; return; } switch (shapeType) { case VdShapeType.ClusterLink: _modeMgr.Mode = ShapeInputMode.LinkedObj1Expected; _linkCreation.linkId = -1; //reset Id of previously locally created link _linkCreation.headType = (LinkHeadType)shapeTag; break; case VdShapeType.FreeForm: _modeMgr.Mode = ShapeInputMode.CreationExpected; FreeDrawingMode(true); break; default: _modeMgr.Mode = ShapeInputMode.CreationExpected; break; } }
public void EnterShapeCreationMode(VdShapeType shapeType) { if (_doc.VolatileCtx.LocalCursor != null) { _palette.ResetOvers(); _modeMgr.Mode = ShapeInputMode.ManipulationExpected; return; } switch (shapeType) { case VdShapeType.ClusterLink: _modeMgr.Mode = ShapeInputMode.LinkedObj1Expected; linkCreation.linkHead = LinkHeadType.SingleHeaded; break; case VdShapeType.FreeForm: _modeMgr.Mode = ShapeInputMode.CreationExpected; FreeDrawingMode(true); break; default: _modeMgr.Mode = ShapeInputMode.CreationExpected; break; } }
private void btnNOP_Click(object sender, RoutedEventArgs e) { shapeType = VdShapeType.None; if (noTool != null) { noTool(_ownerId); } }
private void btnArrow_Click(object sender, RoutedEventArgs e) { shapeType = VdShapeType.Arrow; if (toolSelected != null) toolSelected(VdShapeType.Arrow, -1, _ownerId); //ResetOvers(); }
public void SelectText() { shapeType = VdShapeType.Text; if (toolSelected != null) toolSelected(VdShapeType.Text, -1, _ownerId); //ResetOvers(); }
private void btnCluster_Click(object sender, RoutedEventArgs e) { shapeType = VdShapeType.Cluster; if (toolSelected != null) { toolSelected(VdShapeType.Cluster, -1, _ownerId); } //ResetOvers(); }
public void Read(BinaryReader annotation) { _id = annotation.ReadInt32(); _initOwner = annotation.ReadInt32(); _shapeType = (VdShapeType)annotation.ReadInt32(); _tag = annotation.ReadInt32(); _state = new Model.ShapeState(); _state.Read(annotation); }
private void btnFreeForm_Click(object sender, RoutedEventArgs e) { shapeType = VdShapeType.FreeForm; if (toolSelected != null) { toolSelected(VdShapeType.FreeForm, -1, _ownerId); } //ResetOvers(); }
public void SelectText() { shapeType = VdShapeType.Text; if (toolSelected != null) { toolSelected(VdShapeType.Text, -1, _ownerId); } //ResetOvers(); }
private void btnSegment_Click(object sender, RoutedEventArgs e) { shapeType = VdShapeType.Segment; if (toolSelected != null) { toolSelected(VdShapeType.Segment, _ownerId); } ResetOvers(); lineOver.Visibility = Visibility.Visible; }
private void btnArrow_Click(object sender, RoutedEventArgs e) { shapeType = VdShapeType.Arrow; if (toolSelected != null) { toolSelected(VdShapeType.Arrow, _ownerId); } ResetOvers(); arrowOver.Visibility = Visibility.Visible; }
public void SelectText() { shapeType = VdShapeType.Text; if (toolSelected != null) { toolSelected(VdShapeType.Text, _ownerId); } ResetOvers(); textOver.Visibility = Visibility.Visible; }
private void btnClusterLink_Click(object sender, RoutedEventArgs e) { shapeType = VdShapeType.ClusterLink; if (toolSelected != null) { toolSelected(VdShapeType.ClusterLink, _ownerId); } ResetOvers(); linkOver.Visibility = Visibility.Visible; }
private void btnFreeForm_Click(object sender, RoutedEventArgs e) { shapeType = VdShapeType.FreeForm; if (toolSelected != null) { toolSelected(VdShapeType.FreeForm, _ownerId); } ResetOvers(); freeFormOver.Visibility = Visibility.Visible; }
public void SendCreateShapeRequest(int ownerId, int shapeId, VdShapeType shapeType, bool takeCursor, double startX, double startY, int tag, int topicId) { if (peer == null || peer.PeerState != PeerStateValue.Connected) { return; } peer.OpCustom((byte)DiscussionOpCode.CreateShapeRequest, CreateShape.Write(ownerId, shapeId, shapeType, startX, startY, takeCursor, tag, topicId), true); }
//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 ShapeState(VdShapeType shapeType, int initialOwner, int shapeId, byte[] bytes, int[] ints, double[] doubles, int topicId) { this.shapeType = shapeType; this.initialOwner = initialOwner; this.shapeId = shapeId; this.bytes = bytes; this.ints = ints; this.doubles = doubles; this.topicId = topicId; this.doBroadcast = true; }
public static Dictionary<byte, object> Write(int ownerId, int shapeId, VdShapeType shapeType, double startX, double startY, bool takeCursor, int tag, int topicId) { var res = new Dictionary<byte, object>(); res.Add((byte) DiscussionParamKey.ShapeOwnerId, ownerId); res.Add((byte) DiscussionParamKey.ShapeId, shapeId); res.Add((byte) DiscussionParamKey.ShapeType, shapeType); res.Add((byte) DiscussionParamKey.AnchorX, startX); res.Add((byte) DiscussionParamKey.AnchorY, startY); res.Add((byte) DiscussionParamKey.AutoTakeCursor, takeCursor); res.Add((byte) DiscussionParamKey.Tag, tag); res.Add((byte) DiscussionParamKey.ChangedTopicId, topicId); return res; }
private void btnClusterLink2_Click(object sender, RoutedEventArgs e) { shapeType = VdShapeType.ClusterLink; if (toolSelected != null) { if (btnClusterLink2.IsChecked.Value) { toolSelected(VdShapeType.ClusterLink, (int)LinkHeadType.DoubleHeaded, _ownerId); } else { toolSelected(VdShapeType.None, (int)LinkHeadType.DoubleHeaded, _ownerId); } } //ResetOvers(); }
public static Dictionary<byte, object> Write(VdShapeType shapeType, int initialOwner, int shapeId, byte[] bytes, int[] ints, double[] doubles, int topicId, bool doBroadcast) { var res = new Dictionary<byte, object>(); res.Add((byte) DiscussionParamKey.ShapeType, shapeType); res.Add((byte) DiscussionParamKey.InitialShapeOwnerId, initialOwner); res.Add((byte) DiscussionParamKey.ShapeId, shapeId); res.Add((byte) DiscussionParamKey.ArrayOfBytes, bytes); res.Add((byte) DiscussionParamKey.ArrayOfInts, ints); res.Add((byte) DiscussionParamKey.ArrayOfDoubles, doubles); res.Add((byte) DiscussionParamKey.ChangedTopicId, topicId); res.Add((byte) DiscussionParamKey.DoBroadcast, doBroadcast); return res; }
public IVdShape BeginCreateShape(VdShapeType shapeType, double startX, double startY, bool takeCursor, int tag) { var shapeId = ShapeIdGenerator.Instance.NextId(_palette.GetOwnerId()); _rt.clienRt.SendCreateShapeRequest(_palette.GetOwnerId(), shapeId, shapeType, takeCursor, startX, startY, tag, TopicId); //always success var sh = PlayCreateShape(shapeType, shapeId, _palette.GetOwnerId(), startX, startY, takeCursor, tag); return(sh); }
public static Dictionary <byte, object> Write(int ownerId, int shapeId, VdShapeType shapeType, double startX, double startY, bool takeCursor, int tag, int topicId) { var res = new Dictionary <byte, object>(); res.Add((byte)DiscussionParamKey.ShapeOwnerId, ownerId); res.Add((byte)DiscussionParamKey.ShapeId, shapeId); res.Add((byte)DiscussionParamKey.ShapeType, shapeType); res.Add((byte)DiscussionParamKey.AnchorX, startX); res.Add((byte)DiscussionParamKey.AnchorY, startY); res.Add((byte)DiscussionParamKey.AutoTakeCursor, takeCursor); res.Add((byte)DiscussionParamKey.Tag, tag); res.Add((byte)DiscussionParamKey.ChangedTopicId, topicId); return(res); }
private void CreateManipulate(VdShapeType shapeType, double startX, double startY) { if (shapeType == 0) { return; } var sh = _doc.BeginCreateShape(shapeType, startX, startY, true, DocTools.TAG_UNDEFINED); if (shapeType == VdShapeType.FreeForm || shapeType == VdShapeType.Text) { TryEndHostCaption(sh, shapeType == VdShapeType.FreeForm ? CaptionType.FreeDraw : CaptionType.Text); } CaptureAndStartManip(sh, new Point(startX, startY), null, null); _modeMgr.Mode = ShapeInputMode.Manipulating; }
public static Dictionary <byte, object> Write(VdShapeType shapeType, int initialOwner, int shapeId, byte[] bytes, int[] ints, double[] doubles, int topicId, bool doBroadcast) { var res = new Dictionary <byte, object>(); res.Add((byte)DiscussionParamKey.ShapeType, shapeType); res.Add((byte)DiscussionParamKey.InitialShapeOwnerId, initialOwner); res.Add((byte)DiscussionParamKey.ShapeId, shapeId); res.Add((byte)DiscussionParamKey.ArrayOfBytes, bytes); res.Add((byte)DiscussionParamKey.ArrayOfInts, ints); res.Add((byte)DiscussionParamKey.ArrayOfDoubles, doubles); res.Add((byte)DiscussionParamKey.ChangedTopicId, topicId); res.Add((byte)DiscussionParamKey.DoBroadcast, doBroadcast); return(res); }
public void Read(BinaryReader annotation) { var cb = annotation.ReadInt32(); bytes = cb > 0 ? annotation.ReadBytes(cb) : null; var cDoubles = annotation.ReadInt32(); if (cDoubles == 0) { doubles = null; } else { doubles = new double[cDoubles]; for (var i = 0; i < cDoubles; i++) { doubles[i] = annotation.ReadDouble(); } } var cInts = annotation.ReadInt32(); if (cInts == 0) { ints = null; } else { ints = new int[cInts]; for (var i = 0; i < cInts; i++) { ints[i] = annotation.ReadInt32(); } } shapeType = (VdShapeType)annotation.ReadInt32(); shapeId = annotation.ReadInt32(); initialOwner = annotation.ReadInt32(); topicId = annotation.ReadInt32(); doBroadcast = annotation.ReadBoolean(); //doBroadcast }
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; } }
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; } }
private void ToolSelected(VdShapeType shape, int shapeTag, int owner) { mgr.EnterShapeCreationMode(shape, shapeTag); }
public void EnterShapeCreationMode(VdShapeType shapeType, int shapeTag) { if (shapeType == VdShapeType.None) { _linkCreation.end1 = _linkCreation.end2 = null; _modeMgr.Mode = ShapeInputMode.ManipulationExpected; return; } if (_doc.VolatileCtx.LocalCursor != null) { _palette.ResetOvers(); _modeMgr.Mode = ShapeInputMode.ManipulationExpected; return; } switch (shapeType) { case VdShapeType.ClusterLink: _modeMgr.Mode = ShapeInputMode.LinkedObj1Expected; _linkCreation.linkId = -1; //reset Id of previously locally created link _linkCreation.headType = (LinkHeadType) shapeTag; break; case VdShapeType.FreeForm: _modeMgr.Mode = ShapeInputMode.CreationExpected; FreeDrawingMode(true); break; default: _modeMgr.Mode = ShapeInputMode.CreationExpected; break; } }
private void CreateManipulate(VdShapeType shapeType, double startX, double startY) { if (shapeType == 0) return; var sh = _doc.BeginCreateShape(shapeType, startX, startY, true, DocTools.TAG_UNDEFINED); if (shapeType == VdShapeType.FreeForm || shapeType == VdShapeType.Text) TryEndHostCaption(sh, shapeType == VdShapeType.FreeForm ? CaptionType.FreeDraw : CaptionType.Text); CaptureAndStartManip(sh, new Point(startX, startY), null, null); _modeMgr.Mode = ShapeInputMode.Manipulating; }
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; } }
public void ResetTool() { shapeType = VdShapeType.None; toolSelected(VdShapeType.None, 0, 0); ResetOvers(); }
public void Read(BinaryReader annotation) { var cb = annotation.ReadInt32(); bytes = cb > 0 ? annotation.ReadBytes(cb) : null; var cDoubles = annotation.ReadInt32(); if (cDoubles == 0) { doubles = null; } else { doubles = new double[cDoubles]; for (var i = 0; i < cDoubles; i++) doubles[i] = annotation.ReadDouble(); } var cInts = annotation.ReadInt32(); if (cInts == 0) { ints = null; } else { ints = new int[cInts]; for (var i = 0; i < cInts; i++) ints[i] = annotation.ReadInt32(); } shapeType = (VdShapeType) annotation.ReadInt32(); shapeId = annotation.ReadInt32(); initialOwner = annotation.ReadInt32(); topicId = annotation.ReadInt32(); doBroadcast = annotation.ReadBoolean(); //doBroadcast }
private void btnNOP_Click(object sender, RoutedEventArgs e) { shapeType = VdShapeType.None; if (noTool != null) noTool(_ownerId); }
public void Read(BinaryReader annotation) { _id = annotation.ReadInt32(); _initOwner = annotation.ReadInt32(); _shapeType = (VdShapeType) annotation.ReadInt32(); _tag = annotation.ReadInt32(); _state = new Model.ShapeState(); _state.Read(annotation); }
public IVdShape BeginCreateShape(VdShapeType shapeType, double startX, double startY, bool takeCursor, int tag) { var shapeId = ShapeIdGenerator.Instance.NextId(_palette.GetOwnerId()); _rt.clienRt.SendCreateShapeRequest(_palette.GetOwnerId(), shapeId, shapeType, takeCursor, startX, startY, tag, TopicId); //always success var sh = PlayCreateShape(shapeType, shapeId, _palette.GetOwnerId(), startX, startY, takeCursor, tag); return sh; }
private void btnClusterLink_Click(object sender, RoutedEventArgs e) { shapeType = VdShapeType.ClusterLink; if (toolSelected != null) { if(btnClusterLink.IsChecked.Value) toolSelected(VdShapeType.ClusterLink, (int) LinkHeadType.SingleHeaded, _ownerId); else toolSelected(VdShapeType.None, (int)LinkHeadType.SingleHeaded, _ownerId); } //ResetOvers(); }
private void btnFreeForm_Click(object sender, RoutedEventArgs e) { shapeType = VdShapeType.FreeForm; if (toolSelected != null) toolSelected(VdShapeType.FreeForm, _ownerId); ResetOvers(); freeFormOver.Visibility = Visibility.Visible; }
private void btnClusterLink_Click(object sender, RoutedEventArgs e) { shapeType = VdShapeType.ClusterLink; if (toolSelected != null) toolSelected(VdShapeType.ClusterLink, _ownerId); ResetOvers(); linkOver.Visibility = Visibility.Visible; }
void ToolSelected(VdShapeType shape, int owner) { mgr.EnterShapeCreationMode(shape); }
private void btnSegment_Click(object sender, RoutedEventArgs e) { shapeType = VdShapeType.Segment; if (toolSelected != null) toolSelected(VdShapeType.Segment, _ownerId); ResetOvers(); lineOver.Visibility = Visibility.Visible; }
private void btnArrow_Click(object sender, RoutedEventArgs e) { shapeType = VdShapeType.Arrow; if (toolSelected != null) toolSelected(VdShapeType.Arrow, _ownerId); ResetOvers(); arrowOver.Visibility = Visibility.Visible; }
public void SendCreateShapeRequest(int ownerId, int shapeId, VdShapeType shapeType, bool takeCursor, double startX, double startY, int tag, int topicId) { if (peer == null || peer.PeerState != PeerStateValue.Connected) return; peer.OpCustom((byte)DiscussionOpCode.CreateShapeRequest, CreateShape.Write(ownerId, shapeId, shapeType, startX, startY, takeCursor, tag, topicId), true); }
public void SelectText() { shapeType = VdShapeType.Text; if (toolSelected != null) toolSelected(VdShapeType.Text, _ownerId); ResetOvers(); textOver.Visibility = Visibility.Visible; }
//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]; } }