Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#UWP在InkCanvas中分别渲染墨迹_C#_Uwp_Stroke_Inkcanvas - Fatal编程技术网

C#UWP在InkCanvas中分别渲染墨迹

C#UWP在InkCanvas中分别渲染墨迹,c#,uwp,stroke,inkcanvas,C#,Uwp,Stroke,Inkcanvas,我已经从竹板岩中捕获了点数据,并将它们转换为Windows.UI.Input.Inking.InkStroke数据。然后我将它们放在一个InkPresenter.StrokeContainer中,呈现方式如上图所示。笔划彼此粘连,如何将它们分开? 下面是我的代码 private void DataDisplay() { List<InkPoint> list = new List<InkPoint>(); List<InkSt

我已经从竹板岩中捕获了点数据,并将它们转换为Windows.UI.Input.Inking.InkStroke数据。然后我将它们放在一个InkPresenter.StrokeContainer中,呈现方式如上图所示。笔划彼此粘连,如何将它们分开? 下面是我的代码

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);
}
private void DataDisplay()
{
列表=新列表();
列表笔划=新列表();
InkDrawingAttributes DrawingAttributes 1=新的InkDrawingAttributes();
绘图属性1.颜色=颜色.黑色;
图纸属性1.Size=新尺寸(1,1);
InkStrokeBuilder=新的InkStrokeBuilder();
生成器。设置默认DrawingAttribute(DrawingAttribute 1);
inkCanvas.InkPresenter.UpdateDefaultDrawingAttribute(DrawingAttribute 1);
inkCanvas.InkPresenter.IsInputEnabled=true;
foreach(data.Stroke中的变量项)
{
字符串[]strArray=item.Split(',');

对于(int i=9;i)要向InkStrokeContainer添加更多墨水笔划,需要使用方法而不是StrokeContainer.AddStroke()。此外,我不太明白在InkCanvas中单独渲染InkStrokes意味着什么。您能详细告诉我您的预期行为是什么或您面临什么问题吗?谢谢您的评论。我也尝试了InkStrokeContainer.AddStrokes方法,但没有任何更改。正如您在我上传的图像中看到的,似乎有人只在一个笔划中写入此内容。我想用字母分隔此笔划。我不清楚
string[]strArray=item.Split(“,”)
,项是InkStroke对象,您能告诉我为什么将其作为字符串类型操作吗?在您的场景中,您对每个InkStroke对象使用了相同的Matrix3x2值,这导致这些笔划将获得相同的变换(例如平移或旋转),因此这些笔划无法分离。很难达到您预期的效果,因为您需要为每个笔划找到合适的矩阵对象,并根据每个笔划的指定情况进行调整。