private VectorInkStroke CreateDryStrokeFromVectorBrush(DecodedVectorInkBuilder decodedVectorInkBuilder, Wacom.Ink.Serialization.Model.VectorBrush vectorBrush, Stroke stroke) { Wacom.Ink.Geometry.VectorBrush vb; if (vectorBrush.BrushPolygons.Count > 0) { vb = new Wacom.Ink.Geometry.VectorBrush(vectorBrush.BrushPolygons.ToArray()); } else if (vectorBrush.BrushPrototypeURIs.Count > 0) { List <BrushPolygon> brushPolygons = new List <BrushPolygon>(vectorBrush.BrushPrototypeURIs.Count); foreach (var uri in vectorBrush.BrushPrototypeURIs) { brushPolygons.Add(new BrushPolygon(uri.MinScale, ShapeUriResolver.ResolveShape(uri.ShapeUri))); } vb = new Wacom.Ink.Geometry.VectorBrush(brushPolygons.ToArray()); } else { throw new ArgumentException("Missing vector brush information! Expected BrushPolygons, BrushPolyhedrons or BrushPrototypeURIs."); } var pipelineData = decodedVectorInkBuilder.AddWholePath(stroke.Spline, stroke.Layout, vb); return(new VectorInkStroke(stroke, vb, pipelineData)); }
private List <VectorInkStroke> RecreateDryStrokes(InkModel inkDataModel) { if (inkDataModel.InkTree.Root == null) { return(new List <VectorInkStroke>()); } List <VectorInkStroke> dryStrokes = new List <VectorInkStroke>(inkDataModel.Strokes.Count); DecodedVectorInkBuilder decodedVectorInkBuilder = new DecodedVectorInkBuilder(); IEnumerator <InkNode> enumerator = inkDataModel.InkTree.Root.GetRecursiveEnumerator(); while (enumerator.MoveNext()) { if (enumerator.Current is StrokeNode strokeNode) { var vectorInkStroke = CreateDryStroke(decodedVectorInkBuilder, strokeNode.Stroke, inkDataModel); dryStrokes.Add(vectorInkStroke); mSpatialModel.Add(vectorInkStroke); bool res = inkDataModel.SensorData.GetSensorData(vectorInkStroke.SensorDataId, out SensorData sensorData); if (res) { mSerializer.LoadSensorDataFromModel(inkDataModel, sensorData); } } } return(dryStrokes); }
private VectorInkStroke CreateDryStroke(DecodedVectorInkBuilder decodedVectorInkBuilder, Stroke stroke, InkModel inkDataModel) { inkDataModel.Brushes.TryGetBrush(stroke.Style.BrushUri, out Wacom.Ink.Serialization.Model.Brush brush); if (brush is Wacom.Ink.Serialization.Model.VectorBrush vectorBrush) { return(CreateDryStrokeFromVectorBrush(decodedVectorInkBuilder, vectorBrush, stroke)); } else if (brush is RasterBrush rasterBrush) { throw new Exception("This sample does not support serialization of both raster and vector brushes"); } else { throw new Exception("Brush not recognized"); } }
private DryStroke CreateDryStrokeFromVectorBrush(DecodedVectorInkBuilder decodedVectorInkBuilder, Wacom.Ink.Serialization.Model.VectorBrush vectorBrush, Stroke stroke) { Wacom.Ink.Geometry.VectorBrush vb; if (vectorBrush.BrushPolygons.Count > 0) { vb = new Wacom.Ink.Geometry.VectorBrush(vectorBrush.BrushPolygons.ToArray()); } else if (vectorBrush.BrushPrototypeURIs.Count > 0) { List <BrushPolygon> brushPolygons = new List <BrushPolygon>(vectorBrush.BrushPrototypeURIs.Count); foreach (var uri in vectorBrush.BrushPrototypeURIs) { brushPolygons.Add(new BrushPolygon(uri.MinScale, ShapeUriResolver.ResolveShape(uri.ShapeUri))); } vb = new Wacom.Ink.Geometry.VectorBrush(brushPolygons.ToArray()); } else { throw new ArgumentException("Missing vector brush information! Expected BrushPolygons, BrushPolyhedrons or BrushPrototypeURIs."); } var result = decodedVectorInkBuilder.AddWholePath(stroke.Spline, stroke.Layout, vb); var ppp = stroke.Style.PathPointProperties; DryStroke dryStroke = new DryStroke { mPolygon = PolygonUtil.ConvertPolygon(result.Addition), mColor = MediaColor.FromArgb( ppp.Alpha.HasValue ? (byte)(ppp.Alpha * 255.0f) : byte.MinValue, ppp.Red.HasValue ? (byte)(ppp.Red * 255.0f) : byte.MinValue, ppp.Green.HasValue ? (byte)(ppp.Green * 255.0f) : byte.MinValue, ppp.Blue.HasValue ? (byte)(ppp.Blue * 255.0f) : byte.MinValue) }; return(dryStroke); }
private List <DryStroke> RecreateDryStrokes(InkModel inkDataModel) { if (inkDataModel.InkTree.Root == null) { return(new List <DryStroke>()); } List <DryStroke> dryStrokes = new List <DryStroke>(inkDataModel.Strokes.Count); DecodedVectorInkBuilder decodedVectorInkBuilder = new DecodedVectorInkBuilder(); IEnumerator <InkNode> enumerator = inkDataModel.InkTree.Root.GetRecursiveEnumerator(); while (enumerator.MoveNext()) { if ((enumerator.Current is StrokeNode strokeNode)) { dryStrokes.Add(CreateDryStroke(decodedVectorInkBuilder, strokeNode.Stroke, inkDataModel)); } } return(dryStrokes); }