本文整理汇总了VB.NET中System.Drawing.Color.ToArgb方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Color.ToArgb方法的具体用法?VB.NET Color.ToArgb怎么用?VB.NET Color.ToArgb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Color 的用法示例。
在下文中一共展示了Color.ToArgb方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: colorMatches
Public Sub ToArgbToStringExample1(ByVal e As PaintEventArgs)
Dim g As Graphics = e.Graphics
' Color structure used for temporary storage.
Dim someColor As Color = Color.FromArgb(0)
' Array to store KnownColor values that match the criteria.
Dim colorMatches(167) As KnownColor
' Number of matches found.
Dim count As Integer = 0
' Iterate through KnownColor enums to find all corresponding colors
' that have a non-zero green component and zero-valued red
' component and that are not system colors.
Dim enumValue As KnownColor
For enumValue = 0 To KnownColor.YellowGreen
someColor = Color.FromKnownColor(enumValue)
If someColor.G <> 0 And someColor.R = 0 And _
Not someColor.IsSystemColor Then
colorMatches(count) = enumValue
count += 1
End If
Next enumValue
Dim myBrush1 As New SolidBrush(someColor)
Dim myFont As New Font("Arial", 9)
Dim x As Integer = 40
Dim y As Integer = 40
' Iterate through the matches found and display each color that
' corresponds with the enum value in the array. Also display the
' name of the KnownColor and the ARGB components.
Dim i As Integer
For i = 0 To count - 1
' Display the color.
someColor = Color.FromKnownColor(colorMatches(i))
myBrush1.Color = someColor
g.FillRectangle(myBrush1, x, y, 50, 30)
' Display KnownColor name and four component values. To display
' component values: Use the ToArgb method to get the 32-bit
' ARGB value of someColor (created from a KnownColor). Create
' a Color structure from the 32-bit ARGB value and set someColor
' equal to this new Color structure. Then use the ToString method
' to convert it to a string.
g.DrawString(someColor.ToString(), myFont, Brushes.Black, _
x + 55, y)
someColor = Color.FromArgb(someColor.ToArgb())
g.DrawString(someColor.ToString(), myFont, Brushes.Black, _
x + 55, y + 15)
y += 40
Next i
End Sub
开发者ID:VB.NET开发者,项目名称:System.Drawing,代码行数:54,代码来源:Color.ToArgb
注:本文中的System.Drawing.Color.ToArgb方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论