WPF 自定义形状
我正在查看 2007 年的旧 MIX 视频,看到一个很好的演示文稿,展示了 WPF 中的手绘形状。我的问题是这些是否存在于标准发货包中或者我是否必须自己创建它们。
我想我必须创建它们,所以这里出现了“真正的”编程问题:当您想要创建一个“便携式”的“手绘”形状时,您如何开始?我希望能够重复使用尽可能多的矩形、椭圆、直线等代码。
I was looking over old MIX-videos from 2007 and saw a nice presentation showing Hand Drawn Shapes in WPF. My question is if these exist in the standard shipped package or if i have to create these myself.
I imagine that I have to create them, so here comes the "real" programming question: How do you start when you want to create a "hand drawn"-looking shape which is "portable"? I want to be able to re-use as much code as possible for Rectangle, Elipse, Line etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我想这可能就是您正在寻找的内容:手绘形状位于页面底部附近。
I think this may be what you're looking for: Hand drawn shapes is near the bottom of the page.
当我想要绘制自定义形状时,我会使用 Expression Designer、Expression Blend、Adobe Fireworks 或 Illustrator 等工具来设计形状(Fireworks 有一个插件,Illustrator 有一个插件,可以将矢量保存到 XAML)。这解决了在 XAML 中布局的困难部分,并且该形状稍后可以重用。
When I want to draw a custom shape, I use a tool like Expression Designer, Expression Blend, Adobe Fireworks or Illustrator to design the shape (there's a plugin for Fireworks and one for Illustrator that saves vectors out to XAML). This takes care of the hard part of laying things out in XAML, and this shape is reusable later on.
在表达式设计器中绘制形状,然后选择“导出...”作为 XAML。当导出对话框出现时,选择“资源字典”作为文档格式,然后您可以切换到 XAML 选项卡并将代码从对话框复制到 Visual Studio 项目中的资源字典中。现在您拥有了一个 DrawingBrush,您可以使用它来将形状放置在应用程序中的任何位置。
Draw the shape in Expression Designer and then choose "Export..." as XAML. When the export dialog appears, choose "Resource Dictionary" as the document format, then you can switch to the XAML tab and copy the code from the dialog box into a Resource Dictionary in your Visual Studio project. Now you have a DrawingBrush that you can use to place your shapes anywhere in your application.