为什么要在 WPF 中使用 InkCanvas?
在我的 WPF 应用程序中,我有一些绘图功能。我已经使用 Canvas 并手动处理鼠标手势解决了这个问题,并且还将绘制的笔画(包装在 InkPresenter 中)添加到了该 Canvas 中。
使用Blend我突然发现有一个东西叫InkCanvas。根据 Blend 的说法,这是一个“定义接收和显示墨迹笔划的区域。”的控件,因此它听起来与我所做的事情相关。但使用普通画布似乎一切都工作正常
。 InkCanvas 与普通 Canvas 有何不同,为什么我应该选择使用它?
In my WPF application I have some drawing functionality. I have solved this using a Canvas and handling mouse gestures manually, and I also add the drawn Strokes (wrapped in InkPresenter) to this Canvas.
Using Blend I suddenly discover that there is something called InkCanvas. According to Blend this is a control that "Defines an area that receives and displays ink strokes.", so it sounds relevant to what I do. But everything seems to work fine using a plain Canvas..
So; how does the InkCanvas differ from the plain Canvas, and why should I choose to use this instead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
它们实际上是为了服务于两个不同的目的。
Canvas
用于布局。特别是为了使用绝对定位更精确地控制布局。如您所知,InkCanvas
用于捕获和显示笔画。您所做的一切都很好,但是
InkCanvas
有一些不错的附加功能,例如EditMode
等。它的目的是让您免于使用Canvas
手动编写大量内容。使用Canvas
是一种您自己的方法,其中InkCanvas
是一种使用预构建的方法。They really are meant to serve two different purposes.
Canvas
is for layout. Specifically for more exact control over layout using absolute positioning.InkCanvas
is, as you know, for capturing and displaying strokes.What you are doing is just fine, but
InkCanvas
has some nice additional features likeEditMode
among others. It is meant to save you from writing a lot of the stuff you would have to do by hand usingCanvas
. UsingCanvas
is a roll your own kind of approach whereInkCanvas
is a use a pre-built in kind of approach.InkCanvas 处理鼠标事件以便您在画布上绘图。它还具有以下功能:
http://www.kirupa.com/blend_wpf/inkcanvas_pg1.htm
An InkCanvas handles the mouse events for you to draw on the canvas. It also has this functionality:
http://www.kirupa.com/blend_wpf/inkcanvas_pg1.htm
就性能而言,具有真实鼠标事件的 InkCanvas 比从 StylusPointCollection 中创建笔画要快得多,我发现向 StylusPointCollection 添加新点是一项昂贵的操作。
When performance in concerned, InkCanvas with real mouse events is much faster than creating a stroke out of StylusPointCollection, I found that adding new points to a StylusPointCollection is an expensive operation.
我们可以使用 InkCanvas WPF 开发白板应用程序、绘画应用程序。
EditMode 为我们提供了很多功能,例如
手势、绘图、擦除、多点触摸操作、选择元素拖放选项。
插入形状、图像、视频、笔画注释等元素
我们可以保存/加载所有笔画和元素。
我们可以自定义 InkCanvas 类。
we can develop whiteboard application,paint application using InkCanvas WPF.
EditMode gives us so many features like
Gestures,drawing,,erasing,multi touch operations,select element drag drop options.
insert elements like shapes,images,videos,stroke annotations
we can save/load all strokes and elements.
we can customise InkCanvas class.