コード例 #1
0
        private void receiveStrokeAndAddToCanvas()
        {
            SignedStroke stroke = StrokeBitConverter.GetSignedStroke(remoteStream);

            lanCanvas.ManualHandler.AddSignedStroke(stroke);
            StrokeReceived(stroke);
        }
コード例 #2
0
ファイル: StrokeBitConverter.cs プロジェクト: Cendrb/LANPaint
        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
ファイル: PainterSender.cs プロジェクト: Cendrb/LANPaint
 public void SendStroke(SignedStroke stroke)
 {
     lock (stream)
     {
         sendBeginByte();
         stream.WriteByte(Commands.CS_SEND_STROKE);
         StrokeBitConverter.Serialize(stream, stroke);
     }
 }
コード例 #4
0
ファイル: PainterSender.cs プロジェクト: Cendrb/LANPaint
 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
ファイル: StrokeBitConverter.cs プロジェクト: Cendrb/LANPaint
        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
ファイル: StrokeBitConverter.cs プロジェクト: Cendrb/LANPaint
        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
ファイル: PainterSender.cs プロジェクト: Cendrb/LANPaint
 public void SendSignedStroke(SignedStroke signed)
 {
     painterSender.SendStroke(signed);
 }
コード例 #17
0
ファイル: PainterSender.cs プロジェクト: Cendrb/LANPaint
 public void RemoveSignedStroke(SignedStroke signed)
 {
     painterSender.RemoveStroke(signed);
 }