1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
Option Strict On
Option Explicit On
Imports System.Runtime.InteropServices
Public Class LabelForDany
Inherits Label
#Region "declaration"
Private cShadowForeColor As Color = Color.WhiteSmoke
#End Region
#Region "Graphique"
Public Property ShadowForeColor() As Color
Get
Return cShadowForeColor
End Get
Set(ByVal value As Color)
cShadowForeColor = value
End Set
End Property
Protected Overrides Sub OnPaint( _
ByVal e As PaintEventArgs)
Dim bufferImage As Bitmap
bufferImage = New Bitmap(Bounds.Width, Bounds.Width)
Dim gd As Graphics = Graphics.FromImage(bufferImage)
gd.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
gd.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
PaintParentBackground(gd)
Dim intShadowOffset As Integer = CInt(Font.Size / 10)
gd.DrawString(Text, Font, New SolidBrush(ShadowForeColor), New Point(intShadowOffset, intShadowOffset))
gd.DrawString(Text, Font, New SolidBrush(ForeColor), New Point(0, 0))
gd.Dispose()
e.Graphics.DrawImage(bufferImage, 0, 0)
bufferImage.Dispose()
End Sub
Private Sub PaintParentBackground(ByVal g As Graphics)
If Not Me.Parent Is Nothing Then
Dim rect As Rectangle = New Rectangle(Left, Top, Width, Height)
g.TranslateTransform(-rect.X, -rect.Y)
Dim pea As PaintEventArgs = New PaintEventArgs(g, rect)
pea.Graphics.SetClip(rect)
InvokePaintBackground(Parent, pea)
g.TranslateTransform(rect.X, rect.Y)
Else
g.FillRectangle(SystemBrushes.Control, ClientRectangle)
End If
End Sub
Protected Overrides Sub OnPaintBackground( _
ByVal pevent As PaintEventArgs)
' rien
End Sub
#End Region
End Class |
Partager