本文整理汇总了VB.NET中System.Drawing.Color.FromName方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Color.FromName方法的具体用法?VB.NET Color.FromName怎么用?VB.NET Color.FromName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Color
的用法示例。
在下文中一共展示了Color.FromName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: ShowPropertiesOfSlateBlue
Private Sub ShowPropertiesOfSlateBlue(ByVal e As PaintEventArgs)
Dim slateBlue As Color = Color.FromName("SlateBlue")
Dim g As Byte = slateBlue.G
Dim b As Byte = slateBlue.B
Dim r As Byte = slateBlue.R
Dim a As Byte = slateBlue.A
Dim text As String = _
String.Format("Slate Blue has these ARGB values: Alpha:{0}, " _
& "red:{1}, green: {2}, blue {3}", New Object() {a, r, g, b})
e.Graphics.DrawString(text, New Font(Me.Font, FontStyle.Italic), _
New SolidBrush(slateBlue), _
New RectangleF(New PointF(0.0F, 0.0F), _
Size.op_Implicit(Me.Size)))
End Sub
示例2: ColorCreation
' 导入命名空间
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class ColorCreation
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
public class Form1
Inherits System.Windows.Forms.Form
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim g As Graphics = Me.CreateGraphics()
Dim redColor As Color = Color.FromArgb(120, 255, 0, 0)
Dim blueColor As Color = Color.FromName("Blue")
Dim greenColor As Color = Color.FromKnownColor(KnownColor.Green)
Dim tstColor As Color = Color.Empty
If greenColor.IsEmpty Then
tstColor = Color.DarkGoldenrod
End If
Dim redBrush As New SolidBrush(redColor)
Dim blueBrush As New SolidBrush(blueColor)
Dim greenBrush As New SolidBrush(greenColor)
Dim greenPen As New Pen(greenBrush, 4)
g.FillEllipse(redBrush, 10, 10, 50, 50)
g.FillRectangle(blueBrush, 60, 10, 50, 50)
g.DrawLine(greenPen, 20, 60, 200, 60)
Console.WriteLine("Color Name :" + blueColor.Name + ", A:" + blueColor.A.ToString() + ", R:" + blueColor.R.ToString() + ", B:" + blueColor.B.ToString() + ", G:" + blueColor.G.ToString())
redBrush.Dispose()
blueBrush.Dispose()
greenBrush.Dispose()
greenPen.Dispose()
g.Dispose()
End Sub
Public Sub New()
MyBase.New()
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
End Sub
End Class