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); }
public void SendStroke(SignedStroke stroke) { lock (stream) { sendBeginByte(); stream.WriteByte(Commands.CS_SEND_STROKE); StrokeBitConverter.Serialize(stream, stroke); } }
public void RemoveStroke(SignedStroke stroke) { lock (stream) { sendBeginByte(); stream.WriteByte(Commands.CS_REMOVE_STROKE); stream.Write(BitConverter.GetBytes(stroke.GetIdentifier()), 0, sizeof(long)); } }
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); }
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); }
public SignedPointerStroke(SignedStroke signed, int stayTime, int fadeTime) : base(signed.StylusPoints, signed.DrawingAttributes) { Id = signed.Id; Owner = signed.Owner; StayTime = stayTime; FadeTime = fadeTime; initialize(); }
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); }
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); } }
public Fader(SignedStroke stroke, int fadeTime) { FadeTime = fadeTime; this.stroke = stroke; }
public void RemoveSignedStroke(SignedStroke stroke) { canvas.Dispatcher.Invoke(new Action(() => canvas.Strokes.Remove(stroke))); }
public void AddSignedStroke(SignedStroke signed) { canvas.Dispatcher.Invoke(new Action(() => canvas.Strokes.Add(signed))); }
private void drawer_StrokeDrawn(SignedStroke obj) { StrokeCollected(obj); }
private void eraser_StrokeErased(SignedStroke obj) { StrokeRemoved(obj); }
public void SendSignedStroke(SignedStroke signed) { painterSender.SendStroke(signed); }
public void RemoveSignedStroke(SignedStroke signed) { painterSender.RemoveStroke(signed); }