vbAccelerator - Contents of code file: IconHighlight_frmTestIconHighlights.vbPublic Class frmTestIconHighlights
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Private WithEvents iconImageList As System.Windows.Forms.ImageList
Friend WithEvents lblInfo As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.Resources.ResourceManager = New
System.Resources.ResourceManager(GetType(frmTestIconHighlights))
Me.iconImageList = New System.Windows.Forms.ImageList(Me.components)
Me.lblInfo = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'iconImageList
'
Me.iconImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit
Me.iconImageList.ImageSize = New System.Drawing.Size(32, 32)
Me.iconImageList.ImageStream =
CType(resources.GetObject("iconImageList.ImageStream"),
System.Windows.Forms.ImageListStreamer)
Me.iconImageList.TransparentColor = System.Drawing.Color.Transparent
'
'lblInfo
'
Me.lblInfo.Location = New System.Drawing.Point(12, 8)
Me.lblInfo.Name = "lblInfo"
Me.lblInfo.Size = New System.Drawing.Size(456, 48)
Me.lblInfo.TabIndex = 0
Me.lblInfo.Text = "The System.Windows.Forms ImageList does not provide
any method to show the icon s" & _
"elected. However, you can achieve this effect using either the
ComCtl32 API or," & _
" as demonstrated here, using Managed Code."
'
'frmTestIconHighlights
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 14)
Me.ClientSize = New System.Drawing.Size(480, 322)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblInfo})
Me.Font = New System.Drawing.Font("Tahoma", 8.25!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "frmTestIconHighlights"
Me.Text = "ImageList Icon Highlighting with Managed Code"
Me.ResumeLayout(False)
End Sub
#End Region
Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
'
Dim y As Integer = lblInfo.Top + lblInfo.Height + 8
Dim i As Integer
Dim destRect As Rectangle = New Rectangle(32, y,
iconImageList.ImageSize.Width, iconImageList.ImageSize.Height)
For i = 0 To iconImageList.Images.Count - 1
' Draw standard image:
iconImageList.Draw(e.Graphics, destRect.X, destRect.Y, i)
' Draw highlighted image 50%:
destRect.Offset(iconImageList.ImageSize.Width + 16, 0)
HighlightedIconPaint.DrawHighlightedIcon( _
e.Graphics, iconImageList, i, destRect)
' Draw highlighted image 25%:
destRect.Offset(iconImageList.ImageSize.Width + 16, 0)
HighlightedIconPaint.DrawHighlightedIcon( _
e.Graphics, iconImageList, i, destRect, _
Color.FromKnownColor(KnownColor.Highlight), _
64)
' Draw whitened image 50%:
destRect.Offset(iconImageList.ImageSize.Width + 16, 0)
HighlightedIconPaint.DrawHighlightedIcon( _
e.Graphics, iconImageList, i, destRect, _
Color.White)
' Draw whitened image 75%
destRect.Offset(iconImageList.ImageSize.Width + 16, 0)
HighlightedIconPaint.DrawHighlightedIcon( _
e.Graphics, iconImageList, i, destRect, _
Color.White, 192)
' With a high highlightamount the result is almost
' colourised:
destRect.Offset(iconImageList.ImageSize.Width + 16, 0)
HighlightedIconPaint.DrawHighlightedIcon( _
e.Graphics, iconImageList, i, destRect, _
Color.FromKnownColor(KnownColor.ControlDarkDark), 225)
' Using Gamma:
destRect.Offset(iconImageList.ImageSize.Width + 16, 0)
HighlightedIconPaint.DrawHighlightedIcon( _
e.Graphics, iconImageList, i, destRect, _
0.5)
destRect.Offset(iconImageList.ImageSize.Width + 16, 0)
HighlightedIconPaint.DrawHighlightedIcon( _
e.Graphics, iconImageList, i, destRect, _
2.2)
' Shadow fun: here we use a lightened version of
' a control dark saturated icon:
destRect.Offset(iconImageList.ImageSize.Width + 18, 2)
HighlightedIconPaint.DrawHighlightedIcon( _
e.Graphics, iconImageList, i, destRect, _
Color.FromKnownColor(KnownColor.ControlDark), 230, 0.8)
destRect.Offset(-2, -2)
iconImageList.Draw(e.Graphics, destRect.X, destRect.Y, i)
destRect.Offset(0, iconImageList.ImageSize.Height + 4)
destRect.X = 32
Next
' Dogtanian!
End Sub
End Class
|
|