示例#1
0
 public static Dictionary<byte, object> Write(int userId, int color, string name, int topicId, double x, double y, 
                                              LaserPointerTargetSurface targetSurface)
 {
     var lp = new LaserPointer { Color = color, Name = name, TopicId = topicId, 
         UserId = userId, X = x, Y = y, TargetSurface = targetSurface };
     return lp.ToDict();
 }
示例#2
0
        public static Dictionary <byte, object> Write(int userId, int color, string name, int topicId, double x, double y,
                                                      LaserPointerTargetSurface targetSurface)
        {
            var lp = new LaserPointer {
                Color  = color, Name = name, TopicId = topicId,
                UserId = userId, X = x, Y = y, TargetSurface = targetSurface
            };

            return(lp.ToDict());
        }
示例#3
0
 public static LaserPointer Read(Dictionary<byte, object> par)
 {
     var res = new LaserPointer
         {
             UserId = (int)par[(byte)DiscussionParamKey.UserId],
             Color = (int)par[(byte)DiscussionParamKey.Color],
             Name = (string)par[(byte)DiscussionParamKey.UserCursorName],
             TopicId = (int)par[(byte)DiscussionParamKey.ChangedTopicId],
             X = (double)par[(byte)DiscussionParamKey.UserCursorX],
             Y = (double)par[(byte)DiscussionParamKey.UserCursorY],
             TargetSurface = (LaserPointerTargetSurface)par[(byte)DiscussionParamKey.IntParameter1],
         };
     return res;
 }
示例#4
0
        public static LaserPointer Read(Dictionary <byte, object> par)
        {
            var res = new LaserPointer
            {
                UserId        = (int)par[(byte)DiscussionParamKey.UserId],
                Color         = (int)par[(byte)DiscussionParamKey.Color],
                Name          = (string)par[(byte)DiscussionParamKey.UserCursorName],
                TopicId       = (int)par[(byte)DiscussionParamKey.ChangedTopicId],
                X             = (double)par[(byte)DiscussionParamKey.UserCursorX],
                Y             = (double)par[(byte)DiscussionParamKey.UserCursorY],
                TargetSurface = (LaserPointerTargetSurface)par[(byte)DiscussionParamKey.IntParameter1],
            };

            return(res);
        }
示例#5
0
        public void SendLaserPointerMoved(LaserPointer ptr)
        {
            if (peer == null || peer.PeerState != PeerStateValue.Connected)
                return;

            peer.OpCustom((byte)DiscussionOpCode.LaserPointerMovedRequest,
                          ptr.ToDict(),
                          true);
        }
示例#6
0
        private void OnLaserPointerMoved(LaserPointer ptr)
        {
            if (ptr.TopicId != _topicId || ptr.TargetSurface!=_targetSurface)
                return;

            _laserCursorMgr.UpdatePointerLocation(ptr.UserId, new System.Windows.Point(ptr.X, ptr.Y));
        }
示例#7
0
        private void OnDetachLaserPointer(LaserPointer ptr)
        {
            if (ptr.TopicId != _topicId || ptr.TargetSurface != _targetSurface)
                return;

            _laserCursorMgr.DetachLaserPointer(ptr.UserId);
        }
示例#8
0
        private void OnAttachLaserPointer(LaserPointer ptr)
        {
            if (ptr.TopicId != _topicId || ptr.TargetSurface != _targetSurface)
                return;

            _laserCursorMgr.AttachLaserPointer(ptr.UserId, Utils.IntToColor(ptr.Color), ptr.Name);
            _laserCursorMgr.UpdatePointerLocation(ptr.UserId, new System.Windows.Point(ptr.X, ptr.Y));
        }
示例#9
0
 public void HandleLaserPointerMoved(LitePeer peer,
                                     LaserPointer ptr,
                                     OperationRequest operationRequest,
                                     SendParameters sendParameters)
 {
     if (_doc.MoveLaserPointer(ptr))
     {
         _room.Broadcast(peer,
                         operationRequest,
                         sendParameters,
                         (byte)DiscussionEventCode.LaserPointerMovedEvent,
                         BroadcastTo.RoomExceptSelf);
     }
 }
示例#10
0
 public bool MoveLaserPointer(LaserPointer ptr)
 {
     var p = LaserPointers.FirstOrDefault(l0 => l0.UserId == ptr.UserId && l0.TopicId == ptr.TopicId);            
     if (p != null)
     {
         p.X = ptr.X;
         p.Y = ptr.Y;
         return true;
     }
     return false;
 }
示例#11
0
        public bool DetachLaserPointer(LaserPointer ptr)
        {
            var p = LaserPointers.FirstOrDefault(l0 => l0.UserId == ptr.UserId && l0.TopicId == ptr.TopicId);
            if (p == null)
                return false;

            return LaserPointers.Remove(p);
        }
示例#12
0
 public bool AttachLaserPointer(LaserPointer ptr)
 {
     if (LaserPointers.FirstOrDefault(l0 => l0.UserId == ptr.UserId && l0.TopicId == ptr.TopicId) != null)
         return false;
     LaserPointers.Add(ptr);
     return true;
 }
示例#13
0
 void DetachLaserPointerFormAnyTopic(LitePeer peer, int ptrId)
 {
     foreach (var kv in _vectEditors)
     {
         var topicId = kv.Key;
         var lp = new LaserPointer {TopicId = topicId, UserId = ptrId};                
         kv.Value.HandleDetachLaserPointer(peer, lp, 
                                           new OperationRequest((byte)DiscussionOpCode.DetachLaserPointerRequest, lp.ToDict()), 
                                           new SendParameters());
     }
 }