涂鸦效果的实现??????????? <InkPresenter x:Name="ink" Height="434" Width="650" Grid.Row="2"???????????
????????????? Background="Transparent" Opacity="1" ????????????? MouseLeftButtonDown="OnMouseLeftButtonDown" ????????????? MouseMove="OnMouseMove" ????????????? LostMouseCapture="OnLostMouseCapture" Margin="0" ????????????? > ??????????????? <InkPresenter.Clip> ??????????????????? <RectangleGeometry Rect="0,0,650,370" ></RectangleGeometry> ??????????????? </InkPresenter.Clip> ??????? private void OnMouseLeftButtonDown(object sender, MouseEventArgs e)
??????? { ??????????????? ink.CaptureMouse(); //墨迹画笔捕获鼠标 ??????????????? StylusPointCollection MySPC = new StylusPointCollection(); //创建画笔坐标集合 ??????????????? MyStylusPointCollection.Add(e.StylusDevice.GetStylusPoints(ink)); //讲当前ink对象的坐标集合添加到MySPC ??????????????? m_drawStroke = new Stroke(MySPC); //将坐标集合添加到画笔对象 ??????????????? m_drawStroke.DrawingAttributes.Color = Colors.Gray; //设置墨迹颜色 ??????????????? m_drawStroke.DrawingAttributes.OutlineColor = Colors.Gray; ??????????????? m_drawStroke.DrawingAttributes.Width = 3; //设置墨迹尺寸 ??????????????? m_drawStroke.DrawingAttributes.Height = 3; ??????????????? ink.Strokes.Add(m_drawStroke);//将画笔对象添加到ink画笔的对象中 ???????????? ??????? } Comments![]() |