Option Strict On Imports System.Drawing.Drawing2D Imports System.Threading Class XGroupbox Inherits ContainerControl Sub New() SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint, True) SetStyle(ControlStyles.OptimizedDoubleBuffer, True) BackColor = Color.FromArgb(248, 248, 248) Font = New Font("Arial", 9, FontStyle.Regular) ForeColor = SystemColors.Highlight Size = New Size(140, 140) End Sub Private _BorderColor As Color = Color.FromArgb(211, 211, 211) Public Property BorderColor() As Color Get Return _BorderColor End Get Set(ByVal value As Color) _BorderColor = value Invalidate() End Set End Property Private _BackGroundTopColor As Color = Color.FromArgb(235, 235, 235) Public Property BackGroundTopColor() As Color Get Return _BackGroundTopColor End Get Set(ByVal value As Color) _BackGroundTopColor = value Invalidate() End Set End Property Dim g As Graphics Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) G = e.Graphics : G.SmoothingMode = SmoothingMode.AntiAlias Dim MainRec As New Rectangle(0, 0, Width - 1, Height - 1) g.FillRectangle(New SolidBrush(BackColor), MainRec) g.FillRectangle(New SolidBrush(_BackGroundTopColor), New Rectangle(0, 0, Width - 1, 30)) g.DrawRectangle(New Pen(_BorderColor), MainRec) 'Umrandung g.DrawRectangle(New Pen(_BorderColor), New Rectangle(0, 0, Width - 1, 30)) 'Umrandung Top g.DrawString(Text, Font, New SolidBrush(ForeColor), New Point(CInt((Width - 1) / 2) - CInt(g.MeasureString(Text, Font).Width / 2), 15 - CInt(g.MeasureString(Text, Font).Height / 2))) '(CInt(G.MeasureString(Text, Font).Height / 2)) End Sub End Class Class XTheme Inherits ContainerControl Private G As Graphics Private BC() As Color = {Color.FromArgb(220, 220, 220), Color.FromArgb(210, 210, 210), Color.FromArgb(180, 180, 180)} Private MRecT(0 To 9) As Rectangle Private _Buttons() As String = {"Button1"} Private _TopButtonsVisible As Boolean Private _TopButtonsShadowFontColor As Color = Color.Black Private _TopButtonsShadowColor As Color = Color.FromArgb(160, 160, 160) Private _TopButtonsFontColor As Color = Color.FromArgb(113, 113, 113) Private _TopButtonsBackColor As Color = Color.FromArgb(240, 240, 240) Private _TopButtonsFont As Font = New Font("Arial", 9, FontStyle.Regular) Private ControlButtonSelect As Integer = Nothing Public TopButtonSelect As Integer = -1 Private MalettFont As Font = New Font("Marlett", 10, FontStyle.Regular) Sub New() BackColor = Color.White _Buttons(0) = "Button1" SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint, True) Font = New Font("Arial", 9, FontStyle.Regular) DoubleBuffered = True Dock = DockStyle.Fill _TopButtonsVisible = False End Sub Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs) With ParentForm .FormBorderStyle = FormBorderStyle.None .FindForm.StartPosition = FormStartPosition.CenterScreen End With Dock = DockStyle.Fill MyBase.OnHandleCreated(e) End Sub Public Property TopButtonsVisible As Boolean Get Return _TopButtonsVisible Invalidate() End Get Set(value As Boolean) _TopButtonsVisible = value Invalidate() End Set End Property Public Property TopButtons() As String() Get Return _Buttons Invalidate() End Get Set(ByVal value As String()) _Buttons = value Invalidate() End Set End Property Public Property TopButtonsFont As Font Get Return _TopButtonsFont Invalidate() End Get Set(ByVal value As Font) _TopButtonsFont = value Invalidate() End Set End Property Public Property TopButtonsFontColor As Color Get Return _TopButtonsFontColor Invalidate() End Get Set(ByVal value As Color) _TopButtonsFontColor = value Invalidate() End Set End Property Public Property TopButtonsBackColor As Color Get Return _TopButtonsBackColor Invalidate() End Get Set(ByVal value As Color) _TopButtonsBackColor = value Invalidate() End Set End Property Public Property TopButtonsShadowColor As Color Get Return _TopButtonsShadowColor Invalidate() End Get Set(ByVal value As Color) _TopButtonsShadowColor = value Invalidate() End Set End Property Public Property TopButtonsShadowFontColor As Color Get Return _TopButtonsShadowFontColor Invalidate() End Get Set(ByVal value As Color) _TopButtonsShadowFontColor = value Invalidate() End Set End Property Public _ControlBox As Enum_Items Enum Enum_Items None Close Close_Minimize Close_Help End Enum Public Property ControlBox() As Enum_Items Get Return _ControlBox End Get Set(ByVal value As Enum_Items) _ControlBox = value Invalidate() End Set End Property Protected Sub DrawGradient(ByVal Color1 As Color, ByVal Color2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single) G.FillRectangle(New LinearGradientBrush(New Rectangle(x, y, width, height), Color1, Color2, angle), New Rectangle(x, y, width, height)) End Sub Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) G = e.Graphics : G.SmoothingMode = SmoothingMode.AntiAlias DrawGradient(Color.FromArgb(BC(0).R + 16, BC(0).G + 16, BC(0).B + 16), BC(1), 9, 9, Width - 19, 34, 90S) 'Head Background 2 G.DrawLine(New Pen(BC(2)), New Point(9, 43), New Point(Width - 9, 43)) 'Trennline Head G.FillRectangle(New HatchBrush(HatchStyle.LightUpwardDiagonal, Color.FromArgb(100, BC(2)), Color.Transparent), New Rectangle(9, 9, Width - 19, 34)) 'Head: Rifflung G.FillRectangle(New SolidBrush(Color.FromArgb(100, BC(0).R + 16, BC(0).G + 16, BC(0).B + 16)), New Rectangle(9, 9, Width - 19, 17)) 'Head: Shadow G.DrawString(Text, New Font(Font.Name, Font.Size, Font.Style), New SolidBrush(SystemColors.Highlight), New Point(15, 26 - (CInt(G.MeasureString(Text, Font).Height / 2)))) 'Head: Title DrawGradient(BC(0), BC(1), -1, -1, Width + 1, 10, 90S) 'Form: Oben DrawGradient(BC(0), BC(1), -1, Height - 10, Width + 1, 10, 90S) 'Form: Unten 270S DrawGradient(BC(0), BC(1), -1, -1, 10, Height + 1, 180S) 'Form: Links DrawGradient(BC(0), BC(1), Width - 10, -1, 10, Height + 1, 0S) 'Form: Rechts G.DrawRectangle(New Pen(BC(2)), New Rectangle(9, 9, Width - 19, Height - 19)) 'Form: Innen Umrandung G.DrawLine(New Pen(BC(2)), New Point(9, -1), New Point(9, 9)) 'Form: T:O:L G.DrawLine(New Pen(BC(2)), New Point(Width - 10, -1), New Point(Width - 10, 9)) 'Form: T:O:R G.DrawLine(New Pen(BC(2)), New Point(9, Height - 9), New Point(9, Height + 1)) 'Form: T:U:L G.DrawLine(New Pen(BC(2)), New Point(Width - 10, Height - 9), New Point(Width - 10, Height + 1)) 'Form: T:U:R G.DrawRectangle(New Pen(BC(2)), 0, 0, Width - 1, Height - 1) 'Umrandung Außen If _ControlBox = Enum_Items.Close_Minimize Then G.FillRectangle(New SolidBrush(Color.FromArgb(220, 220, 220)), New Rectangle(Width - 60, 9, 50, 34)) 'Background1: 1 G.FillRectangle(New SolidBrush(Color.FromArgb(210, 210, 210)), New Rectangle(Width - 60, 26, 50, 17)) 'Background1: 2 G.DrawRectangle(New Pen(BC(2)), New Rectangle(Width - 60, 9, 50, 34)) 'B1 Umrandung G.DrawLine(New Pen(BC(2)), New Point(Width - 35, 9), New Point(Width - 35, 43)) 'Trennline If ControlButtonSelect = 1 Then 'Close G.FillRectangle(New SolidBrush(Color.FromArgb(200, 200, 200)), New Rectangle(Width - 35, 9, 25, 34)) 'B1 Background Top G.FillRectangle(New SolidBrush(Color.FromArgb(210, 210, 210)), New Rectangle(Width - 35, 9, 25, 17)) 'B1 Background Bottom G.DrawRectangle(New Pen(SystemColors.Highlight), New Rectangle(Width - 35, 9, 25, 34)) 'B1 Umrandung G.DrawString("r", MalettFont, New SolidBrush(SystemColors.GrayText), Width - 30, 20) 'B1 Close G.DrawString("0", MalettFont, New SolidBrush(SystemColors.Highlight), Width - 54, 20) 'B2 Mini ElseIf ControlButtonSelect = 2 Then 'Mini G.FillRectangle(New SolidBrush(Color.FromArgb(200, 200, 200)), New Rectangle(Width - 60, 9, 25, 34)) 'B2 Background Top G.FillRectangle(New SolidBrush(Color.FromArgb(210, 210, 210)), New Rectangle(Width - 60, 9, 25, 17)) 'B2 Background Bottom G.DrawRectangle(New Pen(SystemColors.Highlight), New Rectangle(Width - 60, 9, 25, 34)) 'B2 Umrandung G.DrawString("r", MalettFont, New SolidBrush(SystemColors.Highlight), Width - 30, 20) 'B1 Close G.DrawString("0", MalettFont, New SolidBrush(SystemColors.GrayText), Width - 54, 20) 'B2 Mini Else G.DrawString("r", MalettFont, New SolidBrush(SystemColors.Highlight), Width - 30, 20) 'B1 Close G.DrawString("0", MalettFont, New SolidBrush(SystemColors.Highlight), Width - 54, 20) 'B2 Mini End If ElseIf _ControlBox = Enum_Items.Close Then G.FillRectangle(New SolidBrush(Color.FromArgb(220, 220, 220)), New Rectangle(Width - 35, 9, 25, 34)) 'Background2: 1 G.FillRectangle(New SolidBrush(Color.FromArgb(210, 210, 210)), New Rectangle(Width - 35, 26, 25, 17)) 'Background2: 2 G.DrawRectangle(New Pen(BC(2)), New Rectangle(Width - 35, 9, 25, 34)) 'B2 Umrandung If ControlButtonSelect = 1 Then 'Close G.FillRectangle(New SolidBrush(Color.FromArgb(200, 200, 200)), New Rectangle(Width - 35, 9, 25, 34)) 'B2 Background Top G.FillRectangle(New SolidBrush(Color.FromArgb(210, 210, 210)), New Rectangle(Width - 35, 9, 25, 17)) 'B2 Background Bottom G.DrawRectangle(New Pen(SystemColors.Highlight), New Rectangle(Width - 35, 9, 25, 34)) 'B1 Umrandung G.DrawString("r", MalettFont, New SolidBrush(SystemColors.GrayText), Width - 30, 20) 'B1 Close Else G.DrawString("r", MalettFont, New SolidBrush(SystemColors.Highlight), Width - 30, 20) 'B1 Close End If ElseIf _ControlBox = Enum_Items.Close_Help Then G.FillRectangle(New SolidBrush(Color.FromArgb(220, 220, 220)), New Rectangle(Width - 60, 9, 50, 34)) 'Background1: 1 G.FillRectangle(New SolidBrush(Color.FromArgb(210, 210, 210)), New Rectangle(Width - 60, 26, 50, 17)) 'Background1: 2 G.DrawRectangle(New Pen(BC(2)), New Rectangle(Width - 60, 9, 50, 34)) 'B1 Umrandung G.DrawLine(New Pen(BC(2)), New Point(Width - 35, 9), New Point(Width - 35, 43)) 'Trennline If ControlButtonSelect = 1 Then 'Close G.FillRectangle(New SolidBrush(Color.FromArgb(200, 200, 200)), New Rectangle(Width - 35, 9, 25, 34)) 'B1 Background Top G.FillRectangle(New SolidBrush(Color.FromArgb(210, 210, 210)), New Rectangle(Width - 35, 9, 25, 17)) 'B1 Background Bottom G.DrawRectangle(New Pen(SystemColors.Highlight), New Rectangle(Width - 35, 9, 25, 34)) 'B1 Umrandung G.DrawString("r", MalettFont, New SolidBrush(SystemColors.GrayText), Width - 30, 20) 'B1 Close G.DrawString("s", MalettFont, New SolidBrush(SystemColors.Highlight), Width - 54, 20) 'B2 Help ElseIf ControlButtonSelect = 2 Then 'Help G.FillRectangle(New SolidBrush(Color.FromArgb(200, 200, 200)), New Rectangle(Width - 60, 9, 25, 34)) 'B2 Background Top G.FillRectangle(New SolidBrush(Color.FromArgb(210, 210, 210)), New Rectangle(Width - 60, 9, 25, 17)) 'B2 Background Bottom G.DrawRectangle(New Pen(SystemColors.Highlight), New Rectangle(Width - 60, 9, 25, 34)) 'B2 Umrandung G.DrawString("r", MalettFont, New SolidBrush(SystemColors.Highlight), Width - 30, 20) 'B1 Close G.DrawString("s", MalettFont, New SolidBrush(SystemColors.GrayText), Width - 54, 20) 'B2 Help Else G.DrawString("r", MalettFont, New SolidBrush(SystemColors.Highlight), Width - 30, 20) 'B1 Close G.DrawString("s", MalettFont, New SolidBrush(SystemColors.Highlight), Width - 54, 20) 'B2 Help End If End If If _TopButtonsVisible = True And Not _Buttons.Count = Nothing And _Buttons.Count <= 10 Then Dim MainRect As Rectangle = Nothing Dim S As Integer = CInt((Width) / (_Buttons.Count) - (18 / _Buttons.Count)) For i As Integer = 0 To _Buttons.Count - 1 If Not i = _Buttons.Count - 1 Then MainRect = New Rectangle((S * i) + 9, 43, S, 30) If Not TopButtonSelect = -1 And TopButtonSelect = i Then G.FillRectangle(New SolidBrush(_TopButtonsShadowColor), MainRect) G.DrawRectangle(New Pen(BC(2)), MainRect) Dim PosX As Integer = CInt((S * (i + 1) - (S / 2)) - (G.MeasureString(CStr(_Buttons.GetValue(i)), _TopButtonsFont).Width / 2)) G.DrawString(CStr(_Buttons.GetValue(i)), _TopButtonsFont, New SolidBrush(_TopButtonsShadowFontColor), New Point(PosX + 9, 58 - (CInt(G.MeasureString(Text, Font).Height / 2)))) ElseIf TopButtonSelect = -1 Or Not TopButtonSelect = i Then G.FillRectangle(New SolidBrush(_TopButtonsBackColor), MainRect) G.DrawRectangle(New Pen(BC(2)), MainRect) Dim PosX As Integer = CInt((S * (i + 1) - (S / 2)) - (G.MeasureString(CStr(_Buttons.GetValue(i)), _TopButtonsFont).Width / 2)) G.DrawString(CStr(_Buttons.GetValue(i)), _TopButtonsFont, New SolidBrush(_TopButtonsFontColor), New Point(PosX + 9, 58 - (CInt(G.MeasureString(Text, Font).Height / 2)))) End If Else Dim S2 As Integer = CInt((Width) / (_Buttons.Count) - (18 / _Buttons.Count)) MainRect = New Rectangle((S2 * i) + 9, 43, Width - (S2 * i) - 19, 30) '193 -1 If Not TopButtonSelect = -1 And TopButtonSelect = i Then G.FillRectangle(New SolidBrush(_TopButtonsShadowColor), MainRect) G.DrawRectangle(New Pen(BC(2)), MainRect) Dim PosX As Integer = CInt((S2 * (i + 1) - (S2 / 2)) - (G.MeasureString(CStr(_Buttons.GetValue(i)), _TopButtonsFont).Width / 2)) G.DrawString(CStr(_Buttons.GetValue(i)), _TopButtonsFont, New SolidBrush(_TopButtonsShadowFontColor), New Point(PosX + 9, 58 - (CInt(G.MeasureString(Text, Font).Height / 2)))) ElseIf TopButtonSelect = -1 Or Not TopButtonSelect = i Then G.FillRectangle(New SolidBrush(_TopButtonsBackColor), MainRect) G.DrawRectangle(New Pen(BC(2)), MainRect) Dim PosX As Integer = CInt((S2 * (i + 1) - (S2 / 2)) - (G.MeasureString(CStr(_Buttons.GetValue(i)), _TopButtonsFont).Width / 2)) G.DrawString(CStr(_Buttons.GetValue(i)), _TopButtonsFont, New SolidBrush(_TopButtonsFontColor), New Point(PosX + 9, 58 - (CInt(G.MeasureString(Text, Font).Height / 2)))) End If End If Next End If 'G.FillRectangle(New SolidBrush(Color.Red), 9, 43, Width - 18, 30) End Sub Protected Overrides Sub OnTextChanged(e As EventArgs) MyBase.OnTextChanged(e) Me.Invalidate() End Sub Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs) If _ControlBox = Enum_Items.Close_Minimize Or _ControlBox = Enum_Items.Close_Help Then If New Rectangle(Width - 35, 9, 25, 34).Contains(e.Location) Then If Not ControlButtonSelect = 1 Then ControlButtonSelect = 1 Me.Refresh() End If ElseIf New Rectangle(Width - 60, 9, 50, 34).Contains(e.Location) Then If Not ControlButtonSelect = 2 Then ControlButtonSelect = 2 Me.Refresh() End If Else If Not ControlButtonSelect = Nothing Then ControlButtonSelect = Nothing Me.Refresh() End If End If ElseIf _ControlBox = Enum_Items.Close Then If New Rectangle(Width - 35, 9, 25, 34).Contains(e.Location) Then If Not ControlButtonSelect = 1 Then ControlButtonSelect = 1 Me.Refresh() End If Else If Not ControlButtonSelect = Nothing Then ControlButtonSelect = Nothing Me.Refresh() End If End If End If If TopButtonsVisible = True Then If New Rectangle((9), 43, Width - 18, 30).Contains(e.Location) Then Dim S As Integer = CInt((Width) / (_Buttons.Count) - (18 / _Buttons.Count)) For i As Integer = 0 To _Buttons.Count - 1 If New Rectangle((S * i) + 9, 43, S, 30).Contains(e.Location) Then If Not TopButtonSelect = i Then TopButtonSelect = i Me.Refresh() End If End If Next Else If Not TopButtonSelect = -1 Then TopButtonSelect = -1 Me.Refresh() End If End If End If MyBase.OnMouseMove(e) End Sub Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs) If New Rectangle(Parent.Location.X + 9, Parent.Location.Y + 9, Width - 18, 30).IntersectsWith(New Rectangle(MousePosition.X, MousePosition.Y, 1, 1)) Then Capture = False Dim M As Message = Message.Create(Parent.Handle, 161, New IntPtr(2), IntPtr.Zero) DefWndProc(M) End If If _ControlBox = Enum_Items.Close_Minimize Or _ControlBox = Enum_Items.Close_Help Then If New Rectangle(Width - 35, 9, 25, 34).Contains(e.Location) Then If TypeOf Parent Is Form Then With DirectCast(Parent, Form) .Close() End With End If ElseIf New Rectangle(Width - 60, 9, 50, 34).Contains(e.Location) Then If _ControlBox = Enum_Items.Close_Minimize Then If TypeOf Parent Is Form Then With DirectCast(Parent, Form) .WindowState = FormWindowState.Minimized End With End If End If End If ElseIf _ControlBox = Enum_Items.Close Then If New Rectangle(Width - 35, 9, 25, 34).Contains(e.Location) Then If TypeOf Parent Is Form Then With DirectCast(Parent, Form) .Close() End With End If End If End If MyBase.OnMouseDown(e) End Sub Protected Overrides Sub OnMouseLeave(e As EventArgs) If Not TopButtonSelect = -1 Then TopButtonSelect = -1 Me.Refresh() End If MyBase.OnMouseLeave(e) End Sub End Class Public Class XButton Inherits ContainerControl Sub New() SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint, True) SetStyle(ControlStyles.OptimizedDoubleBuffer, True) BackColor = Color.FromArgb(248, 248, 248) ForeColor = Color.FromArgb(113, 113, 113) FocusHighlight = True Font = New Font("Arial", 9, FontStyle.Regular) Size = New Size(70, 30) End Sub Private _BorderColor As Color = Color.FromArgb(211, 211, 211) Public Property BorderColor() As Color Get Return _BorderColor End Get Set(ByVal value As Color) Invalidate() End Set End Property Enum HighLightEnum Gray Individual End Enum Private _FocusHighlight As Boolean Public Property FocusHighlight() As Boolean Get Return _FocusHighlight End Get Set(ByVal value As Boolean) _FocusHighlight = value End Set End Property Private _BorderStyle As HighLightEnum Public Property BorderStyle() As HighLightEnum Get Return _BorderStyle End Get Set(ByVal value As HighLightEnum) _BorderStyle = value End Set End Property Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs) MyBase.OnGotFocus(e) Invalidate() End Sub Protected Overrides Sub OnLeave(ByVal e As System.EventArgs) MyBase.OnLeave(e) Invalidate() End Sub Dim WithEvents TxtBox As New Button Protected Overrides Sub OnMouseDown(e As MouseEventArgs) If Focused = False Then SetHighLightColor() End If MyBase.OnMouseDown(e) End Sub Protected Overrides Sub OnMouseClick(e As System.Windows.Forms.MouseEventArgs) MyBase.OnMouseClick(e) End Sub Dim IsEnter As Boolean = False Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs) MyBase.OnMouseEnter(e) If IsEnter = False Then IsEnter = True Invalidate() SafeBackColor = BackColor AnimButton = New Thread(AddressOf EnterAnimation) If AnimButton.IsAlive = False Then With AnimButton .IsBackground = True .Start() End With End If End If End Sub Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs) MyBase.OnMouseLeave(e) If IsEnter = True Then IsEnter = False AnimButton.Abort() BackColor = SafeBackColor Invalidate() End If End Sub Dim SafeBackColor As Color Dim AnimButton As Thread Dim HighLightFocosClick As Thread Private Sub SetHighLightColor() Dim G As Graphics = CreateGraphics() G.DrawRectangle(New Pen(SystemColors.Highlight), New Rectangle(0, 0, Width - 1, Height - 1)) Thread.Sleep(300) Invalidate() End Sub Private Sub EnterAnimation() Dim G As Graphics = CreateGraphics() For i As Integer = 0 To 8 Step CInt(0.85) If IsEnter = True Then Thread.Sleep(50) BackColor = Color.FromArgb(BackColor.R - i + 1, BackColor.G - i + 1, BackColor.B - i + 1) Else Exit For End If Next End Sub Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) Dim G As Graphics = e.Graphics : G.SmoothingMode = SmoothingMode.AntiAlias G.Clear(BackColor) Dim PosX As Integer = CInt((Width / 2) - (G.MeasureString(CStr(Text), Font).Width / 2)) If Focused = False Then If BorderStyle = HighLightEnum.Gray Then G.DrawRectangle(New Pen(Color.FromArgb(211, 211, 211)), New Rectangle(0, 0, Width - 1, Height - 1)) ElseIf BorderStyle = HighLightEnum.Individual Then G.DrawRectangle(New Pen(BorderColor), New Rectangle(0, 0, Width - 1, Height - 1)) End If Else If FocusHighlight = True Then G.DrawRectangle(New Pen(SystemColors.Highlight), New Rectangle(0, 0, Width - 1, Height - 1)) Else If BorderStyle = HighLightEnum.Gray Then G.DrawRectangle(New Pen(Color.FromArgb(211, 211, 211)), New Rectangle(0, 0, Width - 1, Height - 1)) ElseIf BorderStyle = HighLightEnum.Individual Then G.DrawRectangle(New Pen(BorderColor), New Rectangle(0, 0, Width - 1, Height - 1)) End If End If End If G.DrawString(Text, Font, New SolidBrush(ForeColor), New Point(PosX, CInt(Height / 2 - (G.MeasureString(CStr(Text), Font).Height / 2)))) End Sub End Class Public Class XComboBox Inherits ComboBox Private _StartIndex As Integer = 0 Private C1 As Color = Color.FromArgb(113, 113, 113) Private C2 As Color = Color.FromArgb(244, 244, 244) Private _BorderColor As Color = Color.FromArgb(211, 211, 211) Public Property BorderColor() As Color Get Return _BorderColor End Get Set(ByVal value As Color) _BorderColor = value Invalidate() End Set End Property Public Property StartIndex As Integer Get Return _StartIndex End Get Set(ByVal value As Integer) _StartIndex = value If Not SelectedIndex = -1 Then SelectedIndex = value End If Invalidate() End Set End Property Private _FocusHighLight As Boolean Public Property FocusHighLight() As Boolean Get Return _FocusHighLight End Get Set(ByVal value As Boolean) _FocusHighLight = value End Set End Property Sub ReplaceItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Me.DrawItem If Not (e.State And ListViewItemStates.Selected) = 0 Then ' a selected item. e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(248, 248, 248)), e.Bounds) e.Graphics.DrawString(GetItemText(Items(e.Index)), Font, New SolidBrush(SystemColors.Highlight), 10, CInt(e.Bounds.Top + (e.Bounds.Height / 2) / 2 - 2)) e.DrawFocusRectangle() e.Graphics.DrawRectangle(New Pen(Color.FromArgb(211, 211, 211)), New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1)) Else ' unselected item. Dim brush As New SolidBrush(Color.White) Try e.Graphics.FillRectangle(brush, e.Bounds) If Not e.Index = -1 Then e.Graphics.DrawRectangle(New Pen(brush), e.Bounds) e.Graphics.DrawString(GetItemText(Items(e.Index)), Font, New SolidBrush(Color.FromArgb(130, 130, 130)), 10, CInt(e.Bounds.Top + (e.Bounds.Height / 2) / 2 - 2)) End If Finally brush.Dispose() End Try End If End Sub Protected Sub DrawTriangle(ByVal Clr As Color, ByVal FirstPoint As Point, ByVal SecondPoint As Point, ByVal ThirdPoint As Point, ByVal G As Graphics) Dim points As New List(Of Point)() points.Add(FirstPoint) points.Add(SecondPoint) points.Add(ThirdPoint) G.FillPolygon(New SolidBrush(Clr), points.ToArray) End Sub Sub New() SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True) Width = 163 DrawMode = Windows.Forms.DrawMode.OwnerDrawVariable IntegralHeight = False ItemHeight = 24 Font = New Font("Arial", 9, FontStyle.Regular) BackColor = Color.White ForeColor = Color.FromArgb(113, 113, 113) DropDownStyle = ComboBoxStyle.DropDownList End Sub Protected Overrides Sub OnTextChanged(e As System.EventArgs) Invalidate() MyBase.OnTextChanged(e) End Sub Private IsEnter As Boolean = False Protected Overrides Sub OnEnter(ByVal e As System.EventArgs) If FocusHighLight = True Then IsEnter = True Invalidate() End If MyBase.OnEnter(e) End Sub Protected Overrides Sub OnLeave(ByVal e As System.EventArgs) If FocusHighLight = True Then IsEnter = False Invalidate() End If MyBase.OnLeave(e) End Sub 'Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs) ' C2 = Color.FromArgb(233, 233, 233) ' MyBase.OnMouseClick(e) 'End Sub 'Protected Overrides Sub OnMouseUp(e As System.Windows.Forms.MouseEventArgs) ' C2 = Color.FromArgb(244, 244, 244) ' MyBase.OnMouseUp(e) 'End Sub Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) MyBase.OnPaint(e) e.Graphics.SmoothingMode = SmoothingMode.HighQuality e.Graphics.DrawString(Text, Font, Brushes.Gray, New Rectangle(8, 0, Width - 20, Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near}) e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(248, 248, 248)), New Rectangle(Width - 20, 2, 17, Height - 5)) 'Box e.Graphics.DrawRectangle(New Pen(New SolidBrush(_BorderColor)), New Rectangle(Width - 20, 2, 17, Height - 5)) 'Box Innen Umrandung DrawTriangle(SystemColors.Highlight, New Point(Width - 15, 14), New Point(Width - 7, 14), New Point(Width - 11, 19), e.Graphics) 'Pfeil Select Case IsEnter Case False e.Graphics.DrawRectangle(New Pen(New SolidBrush(_BorderColor)), New Rectangle(0, 0, Width - 1, Height - 1)) 'Umrandung Case True e.Graphics.DrawRectangle(New Pen(New SolidBrush(SystemColors.Highlight)), New Rectangle(0, 0, Width - 1, Height - 1)) 'Umrandung End Select End Sub End Class Public Class XTextBox Inherits ContainerControl Dim WithEvents TxtBox As New TextBox Dim G As Graphics Sub New() MyBase.New() SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint, True) SetStyle(ControlStyles.OptimizedDoubleBuffer, True) BackColor = Color.White ForeColor = Color.FromArgb(113, 113, 113) Size = New Size(150, 30) FocusHighLight = True Font = New Font("Arial", 9, FontStyle.Regular) NewTextBox() : Controls.Add(TxtBox) End Sub Private _FocusHighLight As Boolean Public Property FocusHighLight() As Boolean Get Return _FocusHighLight End Get Set(ByVal value As Boolean) _FocusHighLight = value End Set End Property Private _MultiLine As Boolean = False Public Shadows Property MultiLine() As Boolean Get Return _MultiLine End Get Set(ByVal value As Boolean) _MultiLine = value TxtBox.Multiline = value Invalidate() End Set End Property Private _TextAlignment As HorizontalAlignment Public Shadows Property TextAlignment() As HorizontalAlignment Get Return _TextAlignment End Get Set(ByVal value As HorizontalAlignment) _TextAlignment = value TxtBox.TextAlign = value Invalidate() End Set End Property Private _UseSystemPasswordChar As Boolean = False Public Shadows Property UseSystemPasswordChar() As Boolean Get Return _UseSystemPasswordChar End Get Set(ByVal value As Boolean) _UseSystemPasswordChar = value TxtBox.UseSystemPasswordChar = UseSystemPasswordChar Invalidate() End Set End Property Private _MaxLength As Integer = 1000 Public Shadows Property MaxLength() As Integer Get Return _MaxLength End Get Set(ByVal value As Integer) _MaxLength = value TxtBox.MaxLength = MaxLength Invalidate() End Set End Property Private _BorderColor As Color = Color.FromArgb(211, 211, 211) Public Property BorderColor() As Color Get Return _BorderColor End Get Set(ByVal value As Color) _BorderColor = value Invalidate() End Set End Property Private Sub KeyHandel(sender As Object, e As KeyEventArgs) Handles TxtBox.KeyDown MyBase.OnKeyDown(e) End Sub Protected Overrides Sub OnReSize(ByVal e As System.EventArgs) TxtBox.Size = New Size(Width - 21, TxtBox.Height) TxtBox.Location = New Point(10, CInt(Height / 2 - (TxtBox.Size.Height / 2))) Invalidate() End Sub Protected Overrides Sub OnForeColorChanged(ByVal e As System.EventArgs) TxtBox.ForeColor = ForeColor Invalidate() End Sub Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs) TxtBox.Font = Font TxtBox.Location = New Point(10, CInt(Height / 2 - (TxtBox.Size.Height / 2))) Invalidate() End Sub Protected Overrides Sub OnMouseClick(ByVal e As MouseEventArgs) TxtBox.Focus() End Sub Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs) MyBase.OnGotFocus(e) TxtBox.Focus() End Sub Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs) MyBase.OnTextChanged(e) Invalidate() End Sub Sub TextChangeTxtBox() Handles TxtBox.TextChanged Text = TxtBox.Text End Sub Sub TextChange() Handles MyBase.TextChanged TxtBox.Text = Text End Sub Dim IsEnter As Boolean = False Protected Overrides Sub OnEnter(ByVal e As System.EventArgs) MyBase.OnEnter(e) If FocusHighLight = True Then IsEnter = True Invalidate() End If End Sub Protected Overrides Sub OnLeave(ByVal e As System.EventArgs) MyBase.OnLeave(e) If FocusHighLight = True Then IsEnter = False Invalidate() End If End Sub Sub NewTextBox() With TxtBox .Multiline = False .BackColor = BackColor .ForeColor = Color.FromArgb(113, 113, 113) .Text = String.Empty .TextAlign = HorizontalAlignment.Left .BorderStyle = BorderStyle.None .Font = Font .Size = New Size(Width - 21, TxtBox.Height) .Location = New Point(10, 8) .UseSystemPasswordChar = UseSystemPasswordChar End With End Sub Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) G = e.Graphics : G.SmoothingMode = SmoothingMode.AntiAlias G.Clear(BackColor) Select Case IsEnter Case False G.DrawRectangle(New Pen(BorderColor), New Rectangle(0, 0, Width - 1, Height - 1)) Case True G.DrawRectangle(New Pen(SystemColors.Highlight), New Rectangle(0, 0, Width - 1, Height - 1)) End Select End Sub End Class