[Winodows Phone 7控件详解]绘图控件-1

Silverlight的绘图能力是有目共睹的,那Phone7上也一样不会差,以下就是其绘图控件。

一.InkPresenter:可以产生手写效果的控件。

 <InkPresenter MouseLeftButtonDown="inkPresenter1_MouseLeftButtonDown" MouseMove="inkPresenter1_MouseMove"  LostMouseCapture="inkPresenter1_LostMouseCapture" Height="493" HorizontalAlignment="Left" Margin="28,34,0,0" Name="inkPresenter1" VerticalAlignment="Top" Width="405" Background="Yellow"  />        

InkPresenter和InkCanvas不同,前者需要实现相关的事件来产生手写效果。

        private Stroke NewStroke;
public InkPresenterPage()
{
InitializeComponent();
}

private void inkPresenter1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
inkPresenter1.CaptureMouse();
StylusPointCollection sc = new StylusPointCollection();
sc.Add(e.StylusDevice.GetStylusPoints(inkPresenter1 ));
NewStroke = new Stroke();
inkPresenter1.Strokes.Add(NewStroke);
}

private void inkPresenter1_MouseMove(object sender, MouseEventArgs e)
{
if (NewStroke != null)
{
NewStroke.StylusPoints.Add(e.StylusDevice.GetStylusPoints(inkPresenter1));
}
}

private void inkPresenter1_LostMouseCapture(object sender, MouseEventArgs e)
{
NewStroke = null;
}

 

posted @ 2012-03-29 20:47  DebugLZQ  阅读(368)  评论(0编辑  收藏  举报