0

InkCanvasが受信するイベントを手動で送信するにはどうすればよいですか?

私がする必要があるのは、InkCanvasのモードをインクモードに設定してから、仮想イベントをInkCanvasに送信して、ユーザーが実際のマウスを使用しているかのように描画動作を取得することです。

ありがとう

4

2 に答える 2

0

次のコード スニペットは、InkCanvas で図形を描画する例を示しています。

StylusPointCollection stroke1Points = new StylusPointCollection();
stroke1Points.Add(new StylusPoint(50,10));
stroke1Points.Add(new StylusPoint(90,50));
stroke1Points.Add(new StylusPoint(10,50));
stroke1Points.Add(new StylusPoint(50,10));

Stroke stroke1 = new Stroke(stroke1Points);

canvas.Strokes.Add(stroke1);            

canvasの型はInkCanvasです。上記は、キャンバスに三角形を生成します。


「はい、それがあなたに役立つなら、あなたは答えを受け入れるかもしれません。」

于 2011-09-11T14:08:05.220 に答える
0

このようなもの?

    private void inkSurface_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        inkSurface.CaptureMouse();

        _inkStroke = new Stroke(
            e.StylusDevice.GetStylusPoints(inkSurface));
        _inkStroke.DrawingAttributes.Width = 5;
        _inkStroke.DrawingAttributes.Height = 5;
        _inkStroke.DrawingAttributes.Color = Colors.Black;

        inkSurface.Strokes.Add(_inkStroke);
        e.Handled = true;
    }

    private void inkSurface_MouseMove(object sender, MouseEventArgs e)
    {
        if (_inkStroke != null)
        {
            _inkStroke.StylusPoints.Add(
                e.StylusDevice.GetStylusPoints(inkSurface));
        }
        e.Handled = true;
    }

    private void inkSurface_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {
        inkSurface.ReleaseMouseCapture();
        e.Handled = true;
    }
于 2011-10-26T20:42:40.347 に答える