技术开发 频道

Windows Phone 7 学习之画图

  }

  ///

  /// 当手指移动时,将styluspoint 存进stroke

  ///

  ///

  ///

  private void inkPresenter1_MouseMove(object sender, MouseEventArgs e)

  {

  if (mStroke!=null)

  {

  mStroke.StylusPoints.Add(e.StylusDevice.GetStylusPoints(inkPresenter1));

  }

  }

  ///

  /// 当弹起时重新初始化stroke 为null

  ///

  ///

  ///

  private void inkPresenter1_LostMouseCapture(object sender, MouseEventArgs e)

  {

  mStroke = null;

  }

  ///

  /// 清空inkPresenter里面的Stroke

  ///

  ///

  ///

  private void button1_Click(object sender, RoutedEventArgs e)

  {

  this.inkPresenter1.Strokes.Clear();

  }

  最终实现效果:
 

Windows Phone 7 学习之画图(二)

  2.Path 路径

  Path 是众多画图控件使用起来较为麻烦的一个。因为其可以通过两种绘制的方式绘制图形,分别为如下:

  Markup Syntax 可以绘制一个系列的线条

  Geometries 绘制形状,

  以一个圆形的Path 图形为例,通过实现EllipseGeometries 绘制图形,实现代码如下:

  < Path Height="428"

  HorizontalAlignment="Left"

  Margin="30,80,0,0"

  Name="path1"

  Stroke="Red"

  StrokeThickness="10" VerticalAlignment="Top" Width="456" Fill="Blue">

  < Path.Data>

  < EllipseGeometry Center="200,200" RadiusX="30" RadiusY="30"/>

  < /Path.Data>

  < /Path>

  另外Path 还支持Path.Data 数据集,即使用GeometryGroup,在对应的下文可以添加多个形状的图形,代码如下:

  < Path Height="558" HorizontalAlignment="Left" Margin="10,210,0,0" Name="path2" Stroke="Red" StrokeThickness="10" Fill="White"

0
相关文章