Example #1
0
        public void WriteJson(Utf8JsonWriter writer)
        {
            SerializableStrokeList = new List <SerializableStroke>(Strokes.Count);
            foreach (var stroke in Strokes)
            {
                var serializableStroke = new SerializableStroke();
                var points             = stroke.GetInkPoints();
                var finalPointList     = new List <InkPoint>(points.Count);
                foreach (var point in points)
                {
                    finalPointList.Add(point);
                }

                serializableStroke.FinalPointList = finalPointList;

                serializableStroke.DrawingAttributesIgnored = stroke.DrawingAttributes;
                serializableStroke.PointTransform           = stroke.PointTransform;
                SerializableStrokeList.Add(serializableStroke);
            }

            var options = new JsonSerializerOptions();

            options.Converters.Add(new SerializableStrokeConverter());
            JsonSerializer.Serialize(writer, this, options);

            SerializableStrokeList = null;
        }
Example #2
0
        internal void OnSerializingMethod(StreamingContext context)
        {
            SerializableStrokeList = new List <SerializableStroke>(Strokes.Count);
            foreach (var stroke in Strokes)
            {
                var serializableStroke = new SerializableStroke();
                var points             = stroke.GetInkPoints();
                var finalPointList     = new List <InkPoint>(points.Count);
                foreach (var point in points)
                {
                    finalPointList.Add(point);
                }

                serializableStroke.FinalPointList = finalPointList;

                serializableStroke.DrawingAttributes = stroke.DrawingAttributes;
                serializableStroke.PointTransform    = stroke.PointTransform;
                SerializableStrokeList.Add(serializableStroke);
            }
        }