Exemplo n.º 1
0
        /// <summary>
        /// Converts a board point collection into a stroke.
        /// </summary>
        /// <param name="bpc">The BPC.</param>
        /// <returns>A stroke created from the given board point collection.</returns>
        private System.Windows.Ink.Stroke GetStroke(BoardPointCollection bpc)
        {
            System.Windows.Input.StylusPointCollection spc = new System.Windows.Input.StylusPointCollection();

            bpc.Points.ForEach(point =>
            {
                spc.Add(new System.Windows.Input.StylusPoint(point.X, point.Y, point.PressureFactor));
            });
            var stroke = new System.Windows.Ink.Stroke(spc, new System.Windows.Ink.DrawingAttributes()
            {
                Color = (Color)ColorConverter.ConvertFromString(bpc.Color)
            });

            stroke.AddPropertyData(bpc.ID, bpc.User);
            stroke.DrawingAttributes.Height = bpc.BrushHeight;
            stroke.DrawingAttributes.Width  = bpc.BrushWidth;
            return(stroke);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the board point collection.  This allows serializable messages to be sent to the server.
        /// </summary>
        /// <param name="stroke">The stroke.</param>
        /// <returns>A new board point collection.</returns>
        private BoardPointCollection GetBoardPointCollection(System.Windows.Ink.Stroke stroke)
        {
            var bpc = new BoardPointCollection();

            bpc.Color = stroke.DrawingAttributes.Color.ToString();
            var customProperties = stroke.GetPropertyDataIds();

            bpc.ID          = customProperties.First();
            bpc.User        = stroke.GetPropertyData(customProperties.First()).ToString();
            bpc.BrushWidth  = stroke.DrawingAttributes.Width;
            bpc.BrushHeight = stroke.DrawingAttributes.Height;
            stroke.StylusPoints.ToList().ForEach(point =>
            {
                bpc.Points.Add(new BoardPoint()
                {
                    X = point.X,
                    Y = point.Y,
                    PressureFactor = point.PressureFactor
                });
            });
            return(bpc);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Receivers the stroke to erase.
        /// </summary>
        /// <param name="serializedStroke">The serialized stroke.</param>
        private void ReceiveStrokeToErase(string serializedStroke)
        {
            BoardPointCollection bpc = JsonConvert.DeserializeObject <BoardPointCollection>(serializedStroke);

            StrokeErasedEvent?.Invoke(bpc.ID);
        }