20-07-18, 03:32 PM
الأمر لا يحتاج الى مكتبات يمكنك أن تصنع أدواتك بنفسك
هذا Label يعطيك ما تريد
ضع الكود فى كلاس ثم Build
بعد ذلك يمكنك اضافته لديك كأى كونترول عادى
هذا Label يعطيك ما تريد
كود :
Class MyLabel
Inherits Label
Private HooverBackColor As Color
Private HooverTextColor As Color
Private HooverBorderColor As Color
Private Shape As Drawing2D.GraphicsPath
Sub New()
Font = New System.Drawing.Font("Segoe UI", 8)
ForeColor = Color.FromArgb(142, 142, 142)
BackColor = Color.Transparent
HooverBackColor = Color.LightBlue
HooverTextColor = Color.White
HooverBorderColor = Color.White
End Sub
Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
MyBase.OnMouseEnter(e)
Shape = New Drawing2D.GraphicsPath
With Shape
.AddArc(0, 0, 10, 10, 180, 90)
.AddArc(Width - 11, 0, 10, 10, -90, 90)
.AddArc(Width - 11, Height - 11, 10, 10, 0, 90)
.AddArc(0, Height - 11, 10, 10, 90, 90)
.CloseAllFigures()
End With
Using Bmp As New Bitmap(Width, Height)
Using G = Graphics.FromImage(Bmp)
G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
G.Clear(Color.Transparent) ' Set control background to transparent
Using Backbrush As New SolidBrush(HooverBackColor)
G.FillPath(Backbrush, Shape) ' Draw RTB background
End Using
Using BorderPen As New Pen(HooverBorderColor)
G.DrawPath(BorderPen, Shape) ' Draw border
End Using
Dim F As New Font(Me.Font, FontStyle.Bold)
Dim Format As StringFormat = New StringFormat() With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center}
Using Textbrush As New SolidBrush(HooverTextColor)
G.DrawString(Me.Text, F, Textbrush, ClientRectangle, Format)
End Using
Using GF = Me.CreateGraphics
GF.DrawImage(Bmp.Clone(), 0, 0)
End Using
End Using
End Using
End Sub
Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
MyBase.OnMouseLeave(e)
Me.Refresh()
End Sub
End Classضع الكود فى كلاس ثم Build
بعد ذلك يمكنك اضافته لديك كأى كونترول عادى
