1

WindowsPhone7.1で署名をキャプチャしようとしています。

画面に描画することはできますが、mousemoveイベントに処理を追加する以外に、描画領域をInkPresenterコントロールに制限することはできません。

XAMLを使用して描画領域を制限するにはどうすればよいですか、またはこれは不可能ですか?

XAMLコード

<InkPresenter  Name="inkTest" Background="White"  MinHeight="180" MinWidth="250" />

コードビハインド

private Stroke _currentStroke;

private void inkTest_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
    _currentStroke = null;
}

private void inkTest_MouseMove(object sender, MouseEventArgs e)
{
    if (_currentStroke == null) return;
        //HACK: want to set this in XAML
        var position = e.GetPosition(inkTest);
        if (position.X <= inkTest.ActualWidth &&
            position.Y <= inkTest.ActualHeight)

            _currentStroke.StylusPoints.Add(GetStylusPoint(position));
}

private void inkTest_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    inkTest.CaptureMouse();
    _currentStroke = new Stroke();
    _currentStroke.StylusPoints.Add(GetStylusPoint(e.GetPosition(inkTest)));
    _currentStroke.DrawingAttributes.Color = Colors.Blue;
    inkTest.Strokes.Add(_currentStroke);
}

private StylusPoint GetStylusPoint(Point position)
{
    return new StylusPoint(position.X, position.Y);
}   
4

1 に答える 1

2

テストされていませんが、クリッピングを試してください:

<InkPresenter  Name="inkTest" Background="White"  MinHeight="180" MinWidth="250">
    <InkPresenter.Clip>
         <RectangleGeometry Rect="0,0,180,250"/>  
    </InkPresenter.Clip>
</InkPresenter>

の境界を必要RectangleGeometryなものに変更します(またはRectangleGeometry、別の形状が必要な場合は要素自体を変更します)。

于 2012-12-11T16:50:34.887 に答える