- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我想遍历 System.Drawing.Color 结构并使用它来初始化笔列表。
我是这样试的,但是字段类型不合适:
colorList = new List<System.Drawing.Pen>();
foreach (var field in typeof(System.Drawing.Color).GetFields())
{
if (field.FieldType.Name == "Color" && field.Name != null)
{
colorList.Add(new System.Drawing.Pen(field, (float)1));
}
}
请帮帮我。
最佳答案
除了 Color.Empty
,它们是属性,而不是字段:
var colorList = new List<System.Drawing.Pen>();
foreach (var prop in typeof(System.Drawing.Color).GetProperties(BindingFlags.Public | BindingFlags.Static))
{
if (prop.PropertyType == typeof(System.Drawing.Color))
{
colorList.Add(new System.Drawing.Pen((System.Drawing.Color)prop.GetValue(null), 1f));
}
}
这会生成具有 141 种颜色的 Pen
以及我正在运行的版本,应该对应于 Color Properties 中的列表.它不返回 Empty
,尽管它确实有 Transparent
。此外,我将 (float)1
更改为 1f
。 f
告诉编译器这是一个 float
文字,比将 1
转换为 float
更简洁。
关于c# - 遍历 System.Drawing.Color 结构并使用它来创建 System.Drawing.Pen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19575872/
因此,每当您在 Codepen 上创建笔时,它都会为您的笔分配一个屏幕截图,作为缩略图在您的仪表板中代表该笔。 但我面临的问题是,当我更新笔(或更改其外观)时,与笔关联的缩略图也应该更新,但情况并
有没有人完成了从 wpf Pen 到 gdi+ one 的完整转换? 乍一看并不复杂:使用带有相应画笔的构造函数。但是有很多 小 细节:不同的画笔(wpf 中有 5 个,gdi+ 中有 5 个,具有不
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
首先,我将Pendrive设置为可启动,然后将其格式化为FAT32,然后将歌曲输入其中,然后将其插入汽车中的mp3播放器中播放歌曲,但即使有端口,mp3播放器也无法播放歌曲很好,mp3可用于另一个pe
此代码不适用于编辑器和浏览器。但它确实适用于编码测试表格 Pen。我真的很困惑。 关键是当宽度减小到 980 像素以下时,简单地将菜单从水平排列更改为垂直排列。 /*media*/ @media sc
我不知道为什么? *, *::before, *::after { -moz-box-sizing: border-box; box-sizing: border-box;
我创建了一个新的 Pen 对象: Private NewPen As New Pen(New SolidBrush(Color.FromArgb(12,52,220))) 当我现在调用 NewPen.
我有一个表单,我在其中使用 Pen 对象绘制一些线条。 我想知道我是应该使用一个共享对象 Pen,还是每条线使用一个对象 Pen。 更好用:(所有线路共享一个对象) Pen green; green
我试图(简单地)画一些沿着椭圆路径旋转的线,并认为我有一个很好的简单方法来做到这一点。不幸的是,我的解决方案似乎有一些问题: void EllipseDisplayControl::OnPaint(P
系统图: 我找到了一个 post (没有答案)这很好地解释了我的问题。 我无法控制转换图形的笔宽度。要么是 1 像素,要么是 50 左右。我不能在两者之间设置任何东西。一切看起来都不错,除了我想将笔宽
我想使用 Pen 类(class)在我本地的代码俱乐部教授一些基本的几何。我可以用 Squeak 做到这一点,但是 Pharo 呢? p := Pen new. p go: 100. 我记得读过 Pe
我有一个 Shape 类,其中包含 public Pen outlinePen; 我尝试做的是序列化形状列表,但我只有类型 'System.Drawing.Pen' in Assembly 'Sys
我正在开发一个使用了 OTG 笔式驱动器的应用程序,因此从 OTG 笔式驱动器读取数据这样的概念,但所有用户都可能不是同一个设备。 我已经在 5-6 台设备上进行了测试,这些设备给我提供了不同的 US
如何确定设备是否具有 S Pen? 请注意,我在三星 S3 上使用 SDrawLibrary.isSupportedModel() 它返回 true 我们都知道 S3 没有 S Pen。 任何花言巧语
m.pen = Pens.Red; //No error m.pen.EndCap = System.Drawing.Drawing2D.LineCap.Square; //error
我想画粗线和细线。粗线应位于理论线内。所以我将笔对齐设置如下。 Pen blackPen = new Pen(Color.FromArgb(255, 0, 0, 0), 1); Pen greenPe
我是新来的,所以我希望我的消息能被清楚地编辑... 我试图在这里向您展示一张非常解释性的图片,但不允许新用户发布图片。好吧,换句话说:当打印在纸上或 PDF 时,我画了 3 条恰好 10 厘米的线。但
我关注 the doc here在绘图时捕获 Pixelbook 笔上按下的按钮,但永远不会抛出 TOOL_TYPE_ERASER 事件。当我尝试打印日志时,我看不出按住和松开按钮有什么区别: onT
当我画这样的东西时(这里只是随机画): public partial class MainWindow : Window { public MainWindow() {
我一直在尝试修改 StrokeStyle为 TDirect2DCanvas.Pen在 C++Builder 中。 documentation说这个关于属性(property): Determines
我是一名优秀的程序员,十分优秀!