我想要得到所有的笔刷,这基本上是伪代码,它将解释我正在尝试做的事情:
For Each B in Brushes
'Something with Brushes
End For笔刷是一种类型,那么我如何才能做到这一点呢?
发布于 2011-06-15 06:08:39
不使用反射:
Dim brushes = [Enum].GetValues(GetType(KnownColor)) _
.Cast(Of KnownColor)() _
.Where(Function(k) k >= KnownColor.Transparent AndAlso k < KnownColor.ButtonFace) _ '//Exclude system colors
.Select(Function(k) New SolidBrush(Color.FromKnownColor(k)))编辑(来自Thomas comment)
获取颜色名称(用于笔刷)
Dim brushColorNames = [Enum].GetValues(GetType(KnownColor)) _
.Cast(Of KnownColor)() _
.Where(Function(k) k >= KnownColor.Transparent AndAlso k < KnownColor.ButtonFace) _ '//Exclude system colors
.Select(Function(k) k.ToString())发布于 2011-06-15 05:32:13
你能做到吗?
dim brush as new Brush() 'needs a proper brush instance, not sure where there is one, so this line won't work
Dim type As Type = GetType(System.Drawing.Brushes)
Dim properties As PropertyInfo() = type.GetProperties(BindingFlags.Static)
For Each [property] As PropertyInfo In properties
Console.WriteLine("{0} = {1}", [property].Name, [property].GetValue(brush, Nothing))
Next发布于 2011-06-15 06:08:11
这取决于你想用画笔做什么。
For Each b in GetType(Brushes).GetProperties
Dim colorName = b.Name ' If you want color names (AliceBlue through YellowGreen)
Dim brushValue = b.GetValue(Nothing, Nothing) ' Gives you a Brush
Dim brushColor = brushValue.Color ' Gives you the hex color of the brush (AliceBlue = #FFF0F8FF)
Nexthttps://stackoverflow.com/questions/6350376
复制相似问题