private void CopyState(Model.ShapeState st, bool ignoreNullBytes)
        {
            if (_state == null)
            {
                _state = new Model.ShapeState();
            }

            if (ignoreNullBytes)
            {
                if (st.bytes != null)
                {
                    _state.bytes = st.bytes;
                }
            }
            else
            {
                _state.bytes = st.bytes;
            }

            _state.doBroadcast  = st.doBroadcast;
            _state.doubles      = st.doubles;
            _state.initialOwner = st.initialOwner;
            _state.ints         = st.ints;
            _state.shapeId      = st.shapeId;
            _state.shapeType    = st.shapeType;
            _state.topicId      = st.topicId;
        }
Exemple #2
0
 public void ApplyState(ShapeState st)
 {
     line.X1 = st.doubles[0];
     line.Y1 = st.doubles[1];
     line.X2 = st.doubles[2];
     line.Y2 = st.doubles[3];
     SetMarkers();
     updateUserCursor();
 }
        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);
        }
Exemple #4
0
 public static ShapeState Read(Dictionary<byte, object> par)
 {
     var res = new ShapeState();
     res.shapeType = (VdShapeType) par[(byte) DiscussionParamKey.ShapeType];
     res.initialOwner = (int) par[(byte) DiscussionParamKey.InitialShapeOwnerId];
     res.shapeId = (int) par[(byte) DiscussionParamKey.ShapeId];
     res.bytes = (byte[]) par[(byte) DiscussionParamKey.ArrayOfBytes];
     res.ints = (int[]) par[(byte) DiscussionParamKey.ArrayOfInts];
     res.doubles = (double[]) par[(byte) DiscussionParamKey.ArrayOfDoubles];
     res.topicId = (int) par[(byte) DiscussionParamKey.ChangedTopicId];
     res.doBroadcast = (bool) par[(byte) DiscussionParamKey.DoBroadcast];
     return res;
 }
Exemple #5
0
        public static ShapeState Read(Dictionary <byte, object> par)
        {
            var res = new ShapeState();

            res.shapeType    = (VdShapeType)par[(byte)DiscussionParamKey.ShapeType];
            res.initialOwner = (int)par[(byte)DiscussionParamKey.InitialShapeOwnerId];
            res.shapeId      = (int)par[(byte)DiscussionParamKey.ShapeId];
            res.bytes        = (byte[])par[(byte)DiscussionParamKey.ArrayOfBytes];
            res.ints         = (int[])par[(byte)DiscussionParamKey.ArrayOfInts];
            res.doubles      = (double[])par[(byte)DiscussionParamKey.ArrayOfDoubles];
            res.topicId      = (int)par[(byte)DiscussionParamKey.ChangedTopicId];
            res.doBroadcast  = (bool)par[(byte)DiscussionParamKey.DoBroadcast];
            return(res);
        }
Exemple #6
0
        public void ApplyState(ShapeState st)
        {
            //bind caption shapes if not already bound
            if (st.ints[0] != -1 && _captions.text == null)
                _captions.text = (VdText) _doc.IdToShape(st.ints[0]);

            if (st.ints[1] != -1 && _captions.FreeDraw == null)
                _captions.FreeDraw = (VdFreeForm) _doc.IdToShape(st.ints[1]);

            //update relative caption positions
            _captions.textX = st.doubles[0];
            _captions.textY = st.doubles[1];
            _captions.freeDrawX = st.doubles[2];
            _captions.freeDrawY = st.doubles[3];
        }
        public void ApplyState(Model.ShapeState st)
        {
            switch (ShapeCode())
            {
            case VdShapeType.FreeForm:
                CopyState(st, true);
                break;

            case VdShapeType.Text:
                CopyState(st, true);
                break;

            default:
                CopyState(st, false);
                break;
            }
        }
Exemple #8
0
        public void ApplyState(ShapeState st)
        {
            _bounds.X = st.doubles[0];
            _bounds.Y = st.doubles[1];
            _bounds.Width = st.doubles[2];
            _bounds.Height = st.doubles[3];

            if (st.bytes != null)
            {
                var s = new MemoryStream();
                s.Write(st.bytes, 0, st.bytes.Length);
                s.Position = 0;
                _strokes = new System.Windows.Ink.StrokeCollection(s);
                extractGeomtry(_strokes, _bounds);
            }

            SetBounds();
            SetMarkers();
        }
Exemple #9
0
 public ShapeState GetState(int topicId)
 {
     var res = new ShapeState(ShapeCode(),
                              InitialOwner(),
                              Id(),
                              null,
                              new int[] {_captions.GetTextId(), _captions.GetFreeDrawId()},
                              new double[]
                                  {
                                      _dx, _dy, _captions.textX, _captions.textY,
                                      _captions.freeDrawX, _captions.freeDrawY
                                  },
                              topicId);
     _dx = 0;
     _dy = 0;
     return res;
 }
Exemple #10
0
        public void ApplyState(ShapeState st)
        {
            if (st.bytes != null)
            {
                using (var s = new MemoryStream(st.bytes))
                {
                    using (var br = new BinaryReader(s))
                    {
                        Text = br.ReadString();
                    }
                }
            }

            var m = new Matrix
            {
                M11 = st.doubles[2],
                M12 = st.doubles[3],
                M21 = st.doubles[4],
                M22 = st.doubles[5],
                OffsetX = st.doubles[6],
                OffsetY = st.doubles[7]
            };

            _textEnterUC.RenderTransform = new MatrixTransform(m);

            _scene.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                          (Action)SetBounds);
        }
Exemple #11
0
        private void CopyState(Model.ShapeState st, bool ignoreNullBytes)
        {
            if (_state == null)
                _state = new Model.ShapeState();

            if (ignoreNullBytes)
            {
                if (st.bytes != null)
                    _state.bytes = st.bytes;
            }
            else
            {
                _state.bytes = st.bytes;
            }

            _state.doBroadcast = st.doBroadcast;
            _state.doubles = st.doubles;
            _state.initialOwner = st.initialOwner;
            _state.ints = st.ints;
            _state.shapeId = st.shapeId;
            _state.shapeType = st.shapeType;
            _state.topicId = st.topicId;
        }
Exemple #12
0
        public void ApplyState(ShapeState st)
        {
            if (st.bytes != null)
            {
                using (var s = new MemoryStream(st.bytes))
                {
                    using (var br = new BinaryReader(s))
                    {
                        Text = br.ReadString();
                    }
                }
            }
            
            Matrix m = new Matrix();
            m.M11 = st.doubles[2];
            m.M12 = st.doubles[3];
            m.M21 = st.doubles[4];
            m.M22 = st.doubles[5];
            m.OffsetX = st.doubles[6];
            m.OffsetY = st.doubles[7];

            _textEnterUC.RenderTransform = new MatrixTransform(m);

            updateUserCursor();
        }
Exemple #13
0
        public void HandleBadgeCreated(int argPointId,
                                       LitePeer peer,
                                       OperationRequest operationRequest,
                                       SendParameters sendParameters)
        {
            var ctx = new DiscCtx(Discussions.ConfigManager.ConnStr);
            var ap = ctx.ArgPoint.FirstOrDefault(ap0 => ap0.Id == argPointId);
            if (ap == null)
                throw new NotSupportedException("cannot find badge in db!");

            var badgeSh = new ServerBaseVdShape(_doc.BadgeIdGen.NextId(), ap.Person.Id, VdShapeType.Badge, argPointId);
            _doc.AddShape(badgeSh);
            _topology.CreateBadge(badgeSh.Id());

            //get position
            double x;
            double y;
            GetBadgeSmartLocation(ap.Person.Id, out x, out y);

            //set initial badge state 
            var st = new ShapeState(VdShapeType.Badge,
                                    ap.Person.Id,
                                    badgeSh.Id(),
                                    null,
                                    null,
                                    new double[] {x, y},
                                    _topicId);
            badgeSh.ApplyState(st);

            var badgeCreateEv = CreateShape.Write(ap.Person.Id, badgeSh.Id(),
                                                  VdShapeType.Badge,
                                                  st.doubles[0], st.doubles[1], false,
                                                  argPointId, _topicId);

            //include self, badge is created in private board, and if our public board is open, we want to play new badge
            _room.Broadcast(peer,
                            badgeCreateEv,
                            sendParameters,
                            (byte) DiscussionEventCode.CreateShapeEvent,
                            BroadcastTo.RoomAll);

            _pendingChanges = true;
        }
Exemple #14
0
 public void ApplyState(ShapeState st)
 {
     setBadgePos(st.doubles[0], st.doubles[1]);
 }
Exemple #15
0
 public void ApplyState(ShapeState st)
 {
     throw new NotSupportedException("links follow linkables");
 }
Exemple #16
0
        private void PlaySyncStateEvent(ShapeState state)
        {
            var sh = _doc.IdToShape(state.shapeId);
            if (sh == null)
            {
                //error of initialization (not all existing shapes were loaded to local station)
                return;
            }

            sh.ApplyState(state);
        }
Exemple #17
0
        private void syncStateEvent(ShapeState state)
        {
            if (state.topicId != _doc.TopicId)
                return;

            PlaySyncStateEvent(state);
        }
Exemple #18
0
        //public void SendApplyPoint(int ownerId, int shapeId, double x, double y)
        //{
        //    if (peer == null || peer.PeerState != PeerStateValue.Connected)
        //        return;

        //    peer.OpCustom((byte)DiscussionOpCode.ApplyPointRequest,
        //                   PointMove.Write(ownerId, shapeId, x, y),
        //                   false);
        //}

        public void SendSyncState(int shapeId, ShapeState st)
        {
            if (peer == null || peer.PeerState != PeerStateValue.Connected)
                return;            

            peer.OpCustom((byte)DiscussionOpCode.StateSyncRequest,
                          st.ToDict(),
                          true);
            Service();
        }
Exemple #19
0
        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);
        }