예제 #1
0
        private void receiveStrokeAndAddToCanvas()
        {
            SignedStroke stroke = StrokeBitConverter.GetSignedStroke(remoteStream);

            lanCanvas.ManualHandler.AddSignedStroke(stroke);
            StrokeReceived(stroke);
        }
예제 #2
0
        public static SignedStroke GetSignedStroke(Stream source)
        {
            byte[] ownerBytes = new byte[OWNER_NAME_BYTES_ARRAY_LENGTH];
            source.Read(ownerBytes, 0, ownerBytes.Length);

            byte[] idBytes = new byte[sizeof(UInt32)];
            source.Read(idBytes, 0, idBytes.Length);

            DrawingAttributes attributes = GetDrawingAttributes(source);

            StylusPointCollection points = new StylusPointCollection();

            byte[] numberOfPointsBytes = new byte[sizeof(UInt32)];
            source.Read(numberOfPointsBytes, 0, numberOfPointsBytes.Length);
            int numberOfPoints = BitConverter.ToInt32(numberOfPointsBytes, 0);

            for (int x = numberOfPoints; x != 0; x--)
            {
                points.Add(GetPoint(source));
            }
            SignedStroke stroke = new SignedStroke(points, attributes);

            stroke.Owner = StringBitConverter.GetString(ownerBytes).Replace("\0", "");
            stroke.Id    = BitConverter.ToUInt32(idBytes, 0);
            return(stroke);
        }
예제 #3
0
 public void SendStroke(SignedStroke stroke)
 {
     lock (stream)
     {
         sendBeginByte();
         stream.WriteByte(Commands.CS_SEND_STROKE);
         StrokeBitConverter.Serialize(stream, stroke);
     }
 }
예제 #4
0
 public void RemoveStroke(SignedStroke stroke)
 {
     lock (stream)
     {
         sendBeginByte();
         stream.WriteByte(Commands.CS_REMOVE_STROKE);
         stream.Write(BitConverter.GetBytes(stroke.GetIdentifier()), 0, sizeof(long));
     }
 }
예제 #5
0
 public void BeginDrawingStroke(StylusPoint beginning, DrawingAttributes attributes)
 {
     Drawing      = true;
     activePoints = new StylusPointCollection();
     activePoints.Add(beginning);
     actuallyDrawnStroke       = new SignedStroke(activePoints, attributes.Clone());
     actuallyDrawnStroke.Id    = generator.GetNextId();
     actuallyDrawnStroke.Owner = ownerName;
     signedStrokes.Add(actuallyDrawnStroke);
 }
예제 #6
0
        private void receiveIdAndRemoveStroke()
        {
            byte[] idBuffer = new byte[sizeof(long)];
            remoteStream.Read(idBuffer, 0, idBuffer.Length);
            long id = BitConverter.ToInt64(idBuffer, 0);

            SignedStroke removedStroke = lanCanvas.ManualHandler.RemoveSignedStrokeWithId(id);

            StrokeRemoved(removedStroke);
        }
예제 #7
0
        public SignedPointerStroke(SignedStroke signed, int stayTime, int fadeTime)
            : base(signed.StylusPoints, signed.DrawingAttributes)
        {
            Id    = signed.Id;
            Owner = signed.Owner;

            StayTime = stayTime;
            FadeTime = fadeTime;

            initialize();
        }
예제 #8
0
            public void FinishDrawingStroke(StylusPoint endPoint)
            {
                if (Drawing)
                {
                    activePoints.Add(endPoint);
                    StrokeDrawn(actuallyDrawnStroke);

                    Drawing             = false;
                    activePoints        = null;
                    actuallyDrawnStroke = null;
                }
                else
                {
                    throw new NotSupportedException("Not drawing a stroke. Failed to finish the drawing.");
                }
            }
예제 #9
0
        public static SignedPointerStroke GetSignedPointerStroke(Stream source)
        {
            byte[] stayTimeBytes = new byte[sizeof(Int32)];
            source.Read(stayTimeBytes, 0, stayTimeBytes.Length);
            int stayTime = BitConverter.ToInt32(stayTimeBytes, 0);

            byte[] fadeTimeBytes = new byte[sizeof(Int32)];
            source.Read(fadeTimeBytes, 0, fadeTimeBytes.Length);
            int fadeTime = BitConverter.ToInt32(stayTimeBytes, 0);

            SignedStroke signed = GetSignedStroke(source);

            SignedPointerStroke stroke = new SignedPointerStroke(signed, stayTime, fadeTime);

            return(stroke);
        }
예제 #10
0
        public static void Serialize(Stream target, SignedStroke stroke)
        {
            byte[] ownerBytes = StringBitConverter.GetBytes(stroke.Owner, OWNER_NAME_BYTES_ARRAY_LENGTH);
            target.Write(ownerBytes, 0, ownerBytes.Length);

            target.Write(BitConverter.GetBytes(stroke.Id), 0, sizeof(Int32));

            Serialize(target, stroke.DrawingAttributes);

            StylusPointCollection points = stroke.StylusPoints;

            target.Write(BitConverter.GetBytes(points.Count), 0, sizeof(Int32));

            foreach (StylusPoint point in points)
            {
                Serialize(target, point);
            }
        }
예제 #11
0
 public Fader(SignedStroke stroke, int fadeTime)
 {
     FadeTime    = fadeTime;
     this.stroke = stroke;
 }
예제 #12
0
 public void RemoveSignedStroke(SignedStroke stroke)
 {
     canvas.Dispatcher.Invoke(new Action(() => canvas.Strokes.Remove(stroke)));
 }
예제 #13
0
 public void AddSignedStroke(SignedStroke signed)
 {
     canvas.Dispatcher.Invoke(new Action(() => canvas.Strokes.Add(signed)));
 }
예제 #14
0
 private void drawer_StrokeDrawn(SignedStroke obj)
 {
     StrokeCollected(obj);
 }
예제 #15
0
 private void eraser_StrokeErased(SignedStroke obj)
 {
     StrokeRemoved(obj);
 }
예제 #16
0
 public void SendSignedStroke(SignedStroke signed)
 {
     painterSender.SendStroke(signed);
 }
예제 #17
0
 public void RemoveSignedStroke(SignedStroke signed)
 {
     painterSender.RemoveStroke(signed);
 }