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

            lanCanvas.ManualHandler.AddSignedStroke(stroke);
            StrokeReceived(stroke);
        }
        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);
        }
Exemple #3
0
 public void SendStroke(SignedStroke stroke)
 {
     lock (stream)
     {
         sendBeginByte();
         stream.WriteByte(Commands.CS_SEND_STROKE);
         StrokeBitConverter.Serialize(stream, stroke);
     }
 }
Exemple #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));
     }
 }
Exemple #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);
 }
Exemple #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);
        }
Exemple #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();
        }
Exemple #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.");
                }
            }
        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);
        }
Exemple #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);
            }
        }
Exemple #11
0
 public Fader(SignedStroke stroke, int fadeTime)
 {
     FadeTime    = fadeTime;
     this.stroke = stroke;
 }
Exemple #12
0
 public void RemoveSignedStroke(SignedStroke stroke)
 {
     canvas.Dispatcher.Invoke(new Action(() => canvas.Strokes.Remove(stroke)));
 }
Exemple #13
0
 public void AddSignedStroke(SignedStroke signed)
 {
     canvas.Dispatcher.Invoke(new Action(() => canvas.Strokes.Add(signed)));
 }
Exemple #14
0
 private void drawer_StrokeDrawn(SignedStroke obj)
 {
     StrokeCollected(obj);
 }
Exemple #15
0
 private void eraser_StrokeErased(SignedStroke obj)
 {
     StrokeRemoved(obj);
 }
Exemple #16
0
 public void SendSignedStroke(SignedStroke signed)
 {
     painterSender.SendStroke(signed);
 }
Exemple #17
0
 public void RemoveSignedStroke(SignedStroke signed)
 {
     painterSender.RemoveStroke(signed);
 }