Exemplo n.º 1
0
        private void receiveStrokeAndAddToCanvas()
        {
            SignedStroke stroke = StrokeBitConverter.GetSignedStroke(remoteStream);

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