C# UWP Render InkStrokes in InkCanvas Seperately

188 Views Asked by At

enter image description here

I have captured points data from bamboo slate,and converted them to Windows.UI.Input.Inking.InkStroke data.Then I put them in a InkPresenter.StrokeContainer rendered like this image above.Strokes sticked to each other,how can I seperate them? This is my code below.

private void DataDisplay()
    {
        List<InkPoint> list = new List<InkPoint>();
        List<InkStroke> strokes = new List<InkStroke>();
        InkDrawingAttributes drawingAttributes1 = new InkDrawingAttributes();
        drawingAttributes1.Color = Colors.Black;
        drawingAttributes1.Size = new Size(1, 1);
        InkStrokeBuilder builder = new InkStrokeBuilder();
        builder.SetDefaultDrawingAttributes(drawingAttributes1);
        inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes1);
        inkCanvas.InkPresenter.IsInputEnabled = true;
        foreach (var item in data.Stroke)
        {
                string[] strArray = item.Split(',');
                for (int i = 9; i <= strArray.Length - 5; i += 5)
                {
                    float x = float.Parse(strArray[i]) / 30;
                    float y = float.Parse(strArray[i + 1]) / 30;
                    float pressure = float.Parse(strArray[i + 2]) / 1000;
                    Point point = new Point(x, y);
                    InkPoint ip = new InkPoint(point, pressure);
                    list.Add(ip);
                }
                Matrix3x2 matrix3X2 = new Matrix3x2(1, 0, 0, 1, 0, 0);
                InkStroke newStroke = builder.CreateStrokeFromInkPoints(list, matrix3X2);
                strokes.Add(newStroke);
            }
            inkCanvas.InkPresenter.StrokeContainer.AddStroke(strokes);
}
0

There are 0 best solutions below