有没有“笔”?补充“画笔”的类和“颜色”在 WPF 中?
确实没有一个叫做 Pens
的东西,但是找不到它就太奇怪了。是真的没有,还是我眼瞎了?
(我只是在寻找一个方便的类 - 例如,Colors.Red
和 Brushes.Red
就在那里,但对于钢笔来说,最短的似乎是 new笔(画笔.红色,1)
)
There isn't one called Pens
, that's for sure, but it's too odd not to find it. Is it really absent, or am I being blind?
(I'm just looking for a convenience class - for example, Colors.Red
and Brushes.Red
is there, but for pens the shortest appears to be new Pen(Brushes.Red, 1)
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有关联的
Pens
类,因为Pen
是由Brush
和Thickness
而不仅仅是一个属性。如果您需要一套标准笔(基于一定的厚度),那么您将必须创建自己的笔。另一种方法是创建一个代码生成器来提供适当的笔。
下面是一个为每个默认
Brush
添加一个Pen
的类示例:There is not the associated
Pens
class because aPen
is identified by both aBrush
and aThickness
rather than just one property.If you have a need for a set of standard pens (based on some thickness) then you will have to create your own. Another approach would be to create a code generator to supply the appropriate pens.
Here is an example of a class which adds a
Pen
for each defaultBrush
:没有
Pens
类,因为它是多余的。(尽管你是对的:Colors
和画笔
也有些多余。)为什么?好吧,想想笔是什么:它的属性可以通过笔画(或:粗细)和颜色(或:画笔)来描述。因此,有一个画笔构造函数(Brush, double)。
There is no
Pens
class since it would be redundant. (Although you're right:Colors
andBrushes
are somewhat redundant, too.)Why? Well, just think about waht a pen is: its properties can be described by a stroke with (or: thickness) and a color (or: brush). Therefore, there is a Pen Constructor(Brush, double).