C# 将InkPresenter剪切到绘图区域
我正在尝试在windows phone 7.1中捕获签名 我可以在屏幕上绘图,但我不能将绘图区域限制为InkPresenter控件,除非在mousemove事件中添加一些处理 如何使用XAML限制绘图区域,或者这是不可能的 XAML代码C# 将InkPresenter剪切到绘图区域,c#,windows-phone-7,C#,Windows Phone 7,我正在尝试在windows phone 7.1中捕获签名 我可以在屏幕上绘图,但我不能将绘图区域限制为InkPresenter控件,除非在mousemove事件中添加一些处理 如何使用XAML限制绘图区域,或者这是不可能的 XAML代码 <InkPresenter Name="inkTest" Background="White" MinHeight="180" MinWidth="250" /> 代码隐藏 private Stroke _currentStroke; p
<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);
}
private Stroke\u currentStroke;
私有无效inkTest_MouseLeftButtonUp(对象发送器,MouseButtonEventArgs e)
{
_currentStroke=null;
}
私有void inkTest_MouseMove(对象发送方,MouseEventArgs e)
{
if(_currentstrope==null)返回;
//HACK:想在XAML中设置它吗
var位置=e.GetPosition(inkTest);
如果(位置X未测试,但尝试剪裁:
<InkPresenter Name="inkTest" Background="White" MinHeight="180" MinWidth="250">
<InkPresenter.Clip>
<RectangleGeometry Rect="0,0,180,250"/>
</InkPresenter.Clip>
</InkPresenter>
将矩形几何体
的边界更改为所需的边界(如果需要不同的形状,请更改矩形几何体
元素本身)