- Portal
- Community
- Forum Rules
- U-Labs Network
Account-Boerse
Downloade ohne Wartezeit und Geschwindigkeitsbeschränkung von Uploaded.net und Share-Online.biz!U-IMG
Schneller Speicherdienst für Bilder, die in Forenbeiträge eingefügt oder an Freunde gesendet werden können.
Thema: Design Warnungen
-
28.06.2012, 18:30 #1
Design Warnungen
Ich glaube VB will mich heute echt verarschen.
Bevor ich mein Projekt gespeichert habe lief alles wunderbar, keine Fehler. Jetzt öffne ich meine Projektmappe und habe über 1800 Warnungen.
Habe eins von den Designs von iToxic benutzt von den "PureCodes", und nach dem Projekt neu laden übelst viele Warnungen.
BILD ANZEIGEN [Warum wird das Bild nicht angezeigt?]
Habe die Klasse auch mal neu bearbeitet und den ganzen Code neu eingefügt aber nützt auch nichts.
Wieso kommen nach dem neuen Öffnen der Projektmappe plötzlich so viele Warnungen?
Verdammte Scheiße -.-
Ich habe die 39 Formen alle neu gemacht weil ich ja irgendeinen Fehler mit NET Framework hatte und jetzt wieder ein Fehler -.-
1. Fehler:
Warnung 1 Die Klasse ThemeContainer151 kann entworfen werden, ist aber nicht die erste Klasse in der Datei. Visual Studio erfordert, dass Designer die erste Klasse in der Datei verwenden. Verschieben Sie den Klassencode, sodass die Klasse an erste Stelle in der Datei rückt, und versuchen Sie, den Designer erneut zu laden. 0 0Geändert von x BoooM x (28.06.2012 um 19:07 Uhr)
-
28.06.2012, 21:36 #2Projektleitung
- Registriert seit
- 15.11.2011
- Beiträge
- 8.018
- Blog Entries
- 5
Thanked 9.387 Times in 3.225 PostsAW: Design Warnungen
Wahrscheinlich fehlt da irgendwo nur eine Lib oder ein Import-Verweis.
Wenn daraus ein paar Klassen genutzt werden haste sofort an jeder Stelle wo auf eine Instanz daraus zugegriffen wird einen Fehler, da die Instanz durch die fehlende Klasse invalid ist.
Musst halt gucken wie das Ding aufgebaut is, welche externen Libs genutzt werden und welche davon in den Projektverweisen fehlen.
Und wenn du in nem Projekt 39 WinForms hast programmierst du garantiert alles andere als Objektorientiert.
Ich kann mir nicht vorstellen dass der Großteil davon notwendig ist wenn man ordentlich objektorientiert programmiert.
-
28.06.2012, 21:39 #3
AW: Design Warnungen
Die Formen sind alle notwendig.
Der 1. Fehler heißt ja:
Warnung 1 Die Klasse ThemeContainer151 kann entworfen werden, ist aber nicht die erste Klasse in der Datei. Visual Studio erfordert, dass Designer die erste Klasse in der Datei verwenden. Verschieben Sie den Klassencode, sodass die Klasse an erste Stelle in der Datei rückt, und versuchen Sie, den Designer erneut zu laden. 0 0
Da hat mir jemand dazu gesagt:
Du hast in einer Datei 2 Klassen, die 2. Klasse will im Designer dargestellt werden, was nicht geht.
Wenn die 1. Klasse ebenfalls im Designer dargestellt werden will ==> mach 2 Files draus.
Wenn nicht ==> pack die 1. Klasse unter die 2.
Ich checke das nicht was der meint? Kann das die Lösung sein?
Designcode:
http://pastebin.com/u3LdC8a6Geändert von x BoooM x (28.06.2012 um 21:41 Uhr)
-
28.06.2012, 22:14 #4
AW: Design Warnungen
Der Fehler sagt doch alles aus, du hast in einer Datei 2 Klassen
class x {}
class y {}
Jetzt ist y aber die designerklasse, und .NET erwartet diese Klasse an erster Stelle in der Datei, also gehst du hin und machst schlicht
class y {}
class x {}
daraus. Wenn du das nicht verstehst, solltest du dich lieber nochmal den Grundlagen zuwenden.
-
28.06.2012, 22:37 #5
AW: Design Warnungen
Wo fängt die 2. Klasse an die nach oben soll? <.<
-
28.06.2012, 22:39 #6U-Labs Legende
- Registriert seit
- 26.10.2011
- Beiträge
- 1.196
- Blog Entries
- 2
Thanked 1.598 Times in 726 PostsAW: Design Warnungen
bei
class
?
-
28.06.2012, 22:40 #7
AW: Design Warnungen
Da kommt nicht nur 1x Class vor in dem Code..
-
28.06.2012, 22:46 #8
AW: Design Warnungen
Der Code ist in 2 Teile aufgeteilt.
Einmal das Theme selbst:
Spoiler:
Code:Imports System.Drawing.Drawing2D Imports System, System.IO, System.Collections.Generic Imports System.Drawing Imports System.ComponentModel, System.Windows.Forms 'Theme Class AdvantiumTheme Inherits ThemeContainer151 Sub New() TransparencyKey = Color.Fuchsia MoveHeight = 35 SetColor("BackColor", Color.FromArgb(40, 40, 40)) SetColor("BorderInner", Color.FromArgb(65, 65, 65)) SetColor("BorderColor", Color.Black) SetColor("TextColor", Color.LawnGreen) End Sub Dim C1, BC, BA, T1 As Color Protected Overrides Sub ColorHook() C1 = GetColor("BackColor") BC = GetColor("BorderColor") BA = GetColor("BorderInner") T1 = GetColor("TextColor") End Sub Protected Overrides Sub PaintHook() G.Clear(C1) DrawGradient(Color.FromArgb(20, 20, 20), Color.FromArgb(40, 40, 40), New Rectangle(0, 0, Width, 35), 90S) Dim T As New HatchBrush(HatchStyle.Percent10, Color.FromArgb(25, 25, 25), Color.FromArgb(35, 35, 35)) G.FillRectangle(T, New Rectangle(11, 25, Width - 23, Height - 36)) G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(22, 22, 22))), New Rectangle(11, 25, Width - 23, Height - 36)) G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(40, 40, 40))), New Rectangle(12, 26, Width - 25, Height - 38)) DrawCorners(Color.FromArgb(40, 40, 40), New Rectangle(11, 25, Width - 22, Height - 35)) DrawBorders(New Pen(New SolidBrush(BA)), 1) DrawBorders(New Pen(New SolidBrush(BC))) DrawCorners(TransparencyKey) DrawText(New SolidBrush(T1), HorizontalAlignment.Left, 15, -3) End Sub End Class 'Button Class AdvantiumButton Inherits ThemeControl151 Sub New() SetColor("BackColor", Color.FromArgb(40, 40, 40)) SetColor("TextColor", Color.LawnGreen) End Sub Dim C1, T1 As Color Protected Overrides Sub ColorHook() C1 = GetColor("BackColor") T1 = GetColor("TextColor") End Sub Protected Overrides Sub PaintHook() G.Clear(C1) Select Case State Case 0 'None DrawGradient(Color.FromArgb(50, 50, 50), Color.FromArgb(42, 42, 42), ClientRectangle, 90S) Cursor = Cursors.Arrow Case 1 'Down DrawGradient(Color.FromArgb(50, 50, 50), Color.FromArgb(42, 42, 42), ClientRectangle, 90S) Cursor = Cursors.Hand Case 2 'Over DrawGradient(Color.FromArgb(42, 42, 42), Color.FromArgb(50, 50, 50), ClientRectangle, 90S) Cursor = Cursors.Hand End Select DrawBorders(New Pen(New SolidBrush(Color.FromArgb(59, 59, 59))), 1) DrawBorders(New Pen(New SolidBrush(Color.FromArgb(25, 25, 25)))) DrawCorners(Color.FromArgb(35, 35, 35)) DrawText(New SolidBrush(T1), HorizontalAlignment.Center, 0, 0) End Sub End Class 'Top Button Class AdvantiumTopButton Inherits ThemeControl151 Sub New() SetColor("BackColor", Color.FromArgb(40, 40, 40)) SetColor("TextColor", Color.LawnGreen) Size = New Size(28, 26) End Sub Dim C1, T1 As Color Protected Overrides Sub ColorHook() C1 = GetColor("BackColor") T1 = GetColor("TextColor") End Sub Protected Overrides Sub PaintHook() G.Clear(C1) Select Case State Case 0 'None DrawGradient(Color.FromArgb(38, 38, 38), Color.FromArgb(30, 30, 30), ClientRectangle, 90S) Cursor = Cursors.Arrow Case 1 'Down DrawGradient(Color.FromArgb(50, 50, 50), Color.FromArgb(42, 42, 42), ClientRectangle, 90S) Cursor = Cursors.Hand Case 2 'Over DrawGradient(Color.FromArgb(42, 42, 42), Color.FromArgb(50, 50, 50), ClientRectangle, 90S) Cursor = Cursors.Hand End Select DrawBorders(New Pen(New SolidBrush(Color.FromArgb(65, 65, 65))), New Rectangle(1, 0, Width - 2, Height)) DrawBorders(New Pen(New SolidBrush(Color.FromArgb(22, 22, 22)))) G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(22, 22, 22))), 2, Height - 1, Width - 3, Height - 1) G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(65, 65, 65))), 0, 1, Width - 1, 1) G.DrawLine(New Pen(New SolidBrush(Color.Black)), 0, 0, Width, 0) End Sub End Class 'CheckBox Class AdvantiumCheck Inherits ThemeControl151 Private _CheckedState As Boolean Public Property CheckedState() As Boolean Get Return _CheckedState End Get Set(ByVal v As Boolean) _CheckedState = v Invalidate() End Set End Property Sub New() Size = New Size(100, 15) MinimumSize = New Size(16, 16) MaximumSize = New Size(600, 16) CheckedState = False SetColor("CheckBorderOut", Color.FromArgb(25, 25, 25)) SetColor("CheckBorderIn", Color.FromArgb(59, 59, 59)) SetColor("TextColor", Color.LawnGreen) SetColor("CheckBack1", Color.FromArgb(132, 192, 240)) SetColor("CheckBack2", Color.LawnGreen) SetColor("CheckFore1", Color.LawnGreen) SetColor("CheckFore2", Color.FromArgb(42, 242, 77)) SetColor("ColorUncheck", Color.FromArgb(35, 35, 35)) SetColor("BackColor", Color.FromArgb(35, 35, 35)) End Sub Dim C1, C2, C3, C4, C5, C6, P1, P2, B1 As Color Protected Overrides Sub ColorHook() C1 = GetColor("CheckBack1") C2 = GetColor("CheckBack2") C3 = GetColor("CheckFore1") C4 = GetColor("CheckFore2") C5 = GetColor("ColorUncheck") C6 = GetColor("BackColor") P1 = GetColor("CheckBorderOut") P2 = GetColor("CheckBorderIn") B1 = GetColor("TextColor") End Sub Protected Overrides Sub PaintHook() G.Clear(C6) Select Case CheckedState Case True DrawGradient(C1, C2, 3, 3, 9, 9, 90S) DrawGradient(C3, C4, 4, 4, 7, 7, 90S) Case False DrawGradient(C5, C5, 0, 0, 15, 15, 90S) End Select G.DrawRectangle(New Pen(New SolidBrush(P1)), 0, 0, 14, 14) G.DrawRectangle(New Pen(New SolidBrush(P2)), 1, 1, 12, 12) DrawText(New SolidBrush(B1), 17, 0) DrawCorners(C6, New Rectangle(0, 0, 13, 13)) End Sub Sub changeCheck() Handles Me.Click Select Case CheckedState Case True CheckedState = False Case False CheckedState = True End Select End Sub End Class
Und einmal der ThemeContainer151:
Spoiler:
Code:'------------------ 'Creator: aeonhack 'Site: elitevs.net 'Created: 8/2/2011 'Changed: 8/31/2011 'Version: 1.5.1 '------------------ Enum MouseState As Byte None = 0 Over = 1 Down = 2 Block = 3 End Enum Class Bloom Private _Name As String Property Name() As String Get Return _Name End Get Set(ByVal value As String) _Name = value End Set End Property Private _Value As Color Property Value() As Color Get Return _Value End Get Set(ByVal value As Color) _Value = value End Set End Property Sub New() End Sub Sub New(ByVal name As String, ByVal value As Color) _Name = name _Value = value End Sub End Class MustInherit Class ThemeContainer151 Inherits ContainerControl Protected G As Graphics Sub New() SetStyle(DirectCast(139270, ControlStyles), True) _ImageSize = Size.Empty MeasureBitmap = New Bitmap(1, 1) MeasureGraphics = Graphics.FromImage(MeasureBitmap) Font = New Font("Verdana", 8S) InvalidateCustimization() End Sub Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified) If Not _LockWidth = 0 Then width = _LockWidth If Not _LockHeight = 0 Then height = _LockHeight MyBase.SetBoundsCore(x, y, width, height, specified) End Sub Private Header As Rectangle Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs) MyBase.OnSizeChanged(e) If _Movable AndAlso Not _ControlMode Then Header = New Rectangle(7, 7, Width - 14, _MoveHeight - 7) Invalidate() End Sub Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs) If Width = 0 OrElse Height = 0 Then Return G = e.Graphics PaintHook() End Sub Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs) InitializeMessages() InvalidateCustimization() ColorHook() _IsParentForm = TypeOf Parent Is Form If Not _ControlMode Then Dock = DockStyle.Fill If Not _LockWidth = 0 Then Width = _LockWidth If Not _LockHeight = 0 Then Height = _LockHeight If Not BackColorWait = Nothing Then BackColor = BackColorWait If _IsParentForm AndAlso Not _ControlMode Then ParentForm.FormBorderStyle = _BorderStyle ParentForm.TransparencyKey = _TransparencyKey End If OnCreation() MyBase.OnHandleCreated(e) End Sub Protected Overridable Sub OnCreation() End Sub #Region " Sizing and Movement " Protected State As MouseState Private Sub SetState(ByVal current As MouseState) State = current Invalidate() End Sub Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs) If _Sizable AndAlso Not _ControlMode Then InvalidateMouse() MyBase.OnMouseMove(e) End Sub Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs) If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block) MyBase.OnEnabledChanged(e) End Sub Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs) SetState(MouseState.Over) MyBase.OnMouseEnter(e) End Sub Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs) SetState(MouseState.Over) MyBase.OnMouseUp(e) End Sub Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs) SetState(MouseState.None) If _Sizable AndAlso Not _ControlMode AndAlso GetChildAtPoint(PointToClient(MousePosition)) IsNot Nothing Then Cursor = Cursors.Default Previous = 0 End If MyBase.OnMouseLeave(e) End Sub Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs) MyBase.OnMouseDown(e) If Not e.Button = Windows.Forms.MouseButtons.Left Then Return SetState(MouseState.Down) If _IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized OrElse _ControlMode Then Return If _Movable AndAlso Header.Contains(e.Location) Then Capture = False DefWndProc(Messages(0)) ElseIf _Sizable AndAlso Not Previous = 0 Then Capture = False DefWndProc(Messages(Previous)) End If End Sub Private GetIndexPoint As Point Private B1, B2, B3, B4 As Boolean Private Function GetIndex() As Integer GetIndexPoint = PointToClient(MousePosition) B1 = GetIndexPoint.X < 7 B2 = GetIndexPoint.X > Width - 7 B3 = GetIndexPoint.Y < 7 B4 = GetIndexPoint.Y > Height - 7 If B1 AndAlso B3 Then Return 4 If B1 AndAlso B4 Then Return 7 If B2 AndAlso B3 Then Return 5 If B2 AndAlso B4 Then Return 8 If B1 Then Return 1 If B2 Then Return 2 If B3 Then Return 3 If B4 Then Return 6 Return 0 End Function Private Current, Previous As Integer Private Sub InvalidateMouse() Current = GetIndex() If Current = Previous Then Return Previous = Current Select Case Previous Case 0 Cursor = Cursors.Default Case 1, 2 Cursor = Cursors.SizeWE Case 3, 6 Cursor = Cursors.SizeNS Case 4, 8 Cursor = Cursors.SizeNWSE Case 5, 7 Cursor = Cursors.SizeNESW End Select End Sub Private Messages(8) As Message Private Sub InitializeMessages() Messages(0) = Message.Create(Parent.Handle, 161, New IntPtr(2), IntPtr.Zero) For I As Integer = 1 To 8 Messages(I) = Message.Create(Parent.Handle, 161, New IntPtr(I + 9), IntPtr.Zero) Next End Sub #End Region #Region " Property Overrides " Private BackColorWait As Color Overrides Property BackColor() As Color Get Return MyBase.BackColor End Get Set(ByVal value As Color) If IsHandleCreated Then If Not _ControlMode Then Parent.BackColor = value MyBase.BackColor = value Else BackColorWait = value End If End Set End Property <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _ Overrides Property ForeColor() As Color Get Return Color.Empty End Get Set(ByVal value As Color) End Set End Property <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _ Overrides Property BackgroundImage() As Image Get Return Nothing End Get Set(ByVal value As Image) End Set End Property <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _ Overrides Property BackgroundImageLayout() As ImageLayout Get Return ImageLayout.None End Get Set(ByVal value As ImageLayout) End Set End Property Overrides Property Text() As String Get Return MyBase.Text End Get Set(ByVal value As String) MyBase.Text = value Invalidate() End Set End Property Overrides Property Font() As Font Get Return MyBase.Font End Get Set(ByVal value As Font) MyBase.Font = value Invalidate() End Set End Property #End Region #Region " Properties " Private _Movable As Boolean = True Property Movable() As Boolean Get Return _Movable End Get Set(ByVal value As Boolean) _Movable = value End Set End Property Private _Sizable As Boolean = True Property Sizable() As Boolean Get Return _Sizable End Get Set(ByVal value As Boolean) _Sizable = value End Set End Property Private _MoveHeight As Integer = 24 Protected Property MoveHeight() As Integer Get Return _MoveHeight End Get Set(ByVal v As Integer) If v < 8 Then Return Header = New Rectangle(7, 7, Width - 14, v - 7) _MoveHeight = v Invalidate() End Set End Property Private _ControlMode As Boolean Protected Property ControlMode() As Boolean Get Return _ControlMode End Get Set(ByVal v As Boolean) _ControlMode = v End Set End Property Private _TransparencyKey As Color Property TransparencyKey() As Color Get If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.TransparencyKey Else Return _TransparencyKey End Get Set(ByVal value As Color) If _IsParentForm AndAlso Not _ControlMode Then ParentForm.TransparencyKey = value _TransparencyKey = value End Set End Property Private _BorderStyle As FormBorderStyle Property BorderStyle() As FormBorderStyle Get If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.FormBorderStyle Else Return _BorderStyle End Get Set(ByVal value As FormBorderStyle) If _IsParentForm AndAlso Not _ControlMode Then ParentForm.FormBorderStyle = value _BorderStyle = value End Set End Property Private _NoRounding As Boolean Property NoRounding() As Boolean Get Return _NoRounding End Get Set(ByVal v As Boolean) _NoRounding = v Invalidate() End Set End Property Private _Image As Image Property Image() As Image Get Return _Image End Get Set(ByVal value As Image) If value Is Nothing Then _ImageSize = Size.Empty Else _ImageSize = value.Size End If _Image = value Invalidate() End Set End Property Private _ImageSize As Size Protected ReadOnly Property ImageSize() As Size Get Return _ImageSize End Get End Property Private _IsParentForm As Boolean Protected ReadOnly Property IsParentForm As Boolean Get Return _IsParentForm End Get End Property Private _LockWidth As Integer Protected Property LockWidth() As Integer Get Return _LockWidth End Get Set(ByVal value As Integer) _LockWidth = value If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth End Set End Property Private _LockHeight As Integer Protected Property LockHeight() As Integer Get Return _LockHeight End Get Set(ByVal value As Integer) _LockHeight = value If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight End Set End Property Private Items As New Dictionary(Of String, Color) <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _ Property Colors() As Bloom() Get Dim T As New List(Of Bloom) Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator While E.MoveNext T.Add(New Bloom(E.Current.Key, E.Current.Value)) End While Return T.ToArray End Get Set(ByVal value As Bloom()) For Each B As Bloom In value If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value Next InvalidateCustimization() ColorHook() Invalidate() End Set End Property Private _Customization As String Property Customization() As String Get Return _Customization End Get Set(ByVal value As String) If value = _Customization Then Return Dim Data As Byte() Dim Items As Bloom() = Colors Try Data = Convert.FromBase64String(value) For I As Integer = 0 To Items.Length - 1 Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4)) Next Catch Return End Try _Customization = value Colors = Items ColorHook() Invalidate() End Set End Property #End Region #Region " Property Helpers " Protected Function GetColor(ByVal name As String) As Color Return Items(name) End Function Protected Sub SetColor(ByVal name As String, ByVal color As Color) If Items.ContainsKey(name) Then Items(name) = color Else Items.Add(name, color) End Sub Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte) SetColor(name, Color.FromArgb(r, g, b)) End Sub Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte) SetColor(name, Color.FromArgb(a, r, g, b)) End Sub Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal color As Color) SetColor(name, color.FromArgb(a, color)) End Sub Private Sub InvalidateCustimization() Dim M As New MemoryStream(Items.Count * 4) For Each B As Bloom In Colors M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4) Next M.Close() _Customization = Convert.ToBase64String(M.ToArray) End Sub #End Region #Region " User Hooks " Protected MustOverride Sub ColorHook() Protected MustOverride Sub PaintHook() #End Region #Region " Center Overloads " Private CenterReturn As Point Protected Function Center(ByVal r1 As Rectangle, ByVal s1 As Size) As Point CenterReturn = New Point((r1.Width \ 2 - s1.Width \ 2) + r1.X, (r1.Height \ 2 - s1.Height \ 2) + r1.Y) Return CenterReturn End Function Protected Function Center(ByVal r1 As Rectangle, ByVal r2 As Rectangle) As Point Return Center(r1, r2.Size) End Function Protected Function Center(ByVal w1 As Integer, ByVal h1 As Integer, ByVal w2 As Integer, ByVal h2 As Integer) As Point CenterReturn = New Point(w1 \ 2 - w2 \ 2, h1 \ 2 - h2 \ 2) Return CenterReturn End Function Protected Function Center(ByVal s1 As Size, ByVal s2 As Size) As Point Return Center(s1.Width, s1.Height, s2.Width, s2.Height) End Function Protected Function Center(ByVal r1 As Rectangle) As Point Return Center(ClientRectangle.Width, ClientRectangle.Height, r1.Width, r1.Height) End Function Protected Function Center(ByVal s1 As Size) As Point Return Center(Width, Height, s1.Width, s1.Height) End Function Protected Function Center(ByVal w1 As Integer, ByVal h1 As Integer) As Point Return Center(Width, Height, w1, h1) End Function #End Region #Region " Measure Overloads " Private MeasureBitmap As Bitmap Private MeasureGraphics As Graphics Protected Function Measure(ByVal text As String) As Size Return MeasureGraphics.MeasureString(text, Font, Width).ToSize End Function Protected Function Measure() As Size Return MeasureGraphics.MeasureString(Text, Font).ToSize End Function #End Region #Region " DrawCorners Overloads " 'TODO: Optimize by checking brush color Private DrawCornersBrush As SolidBrush Protected Sub DrawCorners(ByVal c1 As Color) DrawCorners(c1, 0, 0, Width, Height) End Sub Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle) DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height) End Sub Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) If _NoRounding Then Return DrawCornersBrush = New SolidBrush(c1) G.FillRectangle(DrawCornersBrush, x, y, 1, 1) G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1) G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1) G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1) End Sub #End Region #Region " DrawBorders Overloads " 'TODO: Remove triple overload? Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer) DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2)) End Sub Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer) DrawBorders(p1, 0, 0, Width, Height, offset) End Sub Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer) DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset) End Sub Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) G.DrawRectangle(p1, x, y, width - 1, height - 1) End Sub Protected Sub DrawBorders(ByVal p1 As Pen) DrawBorders(p1, 0, 0, Width, Height) End Sub Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle) DrawBorders(p1, r.X, r.Y, r.Width, r.Height) End Sub #End Region #Region " DrawText Overloads " 'TODO: Remove triple overloads? Private DrawTextPoint As Point Private DrawTextSize As Size Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer) DrawText(b1, Text, a, x, y) End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point) DrawText(b1, Text, p1.X, p1.Y) End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer) DrawText(b1, Text, x, y) End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer) If text.Length = 0 Then Return DrawTextSize = Measure(text) DrawTextPoint = New Point(Width \ 2 - DrawTextSize.Width \ 2, MoveHeight \ 2 - DrawTextSize.Height \ 2) Select Case a Case HorizontalAlignment.Left DrawText(b1, text, x, DrawTextPoint.Y + y) Case HorizontalAlignment.Center DrawText(b1, text, DrawTextPoint.X + x, DrawTextPoint.Y + y) Case HorizontalAlignment.Right DrawText(b1, text, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y) End Select End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal p1 As Point) DrawText(b1, text, p1.X, p1.Y) End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal x As Integer, ByVal y As Integer) If text.Length = 0 Then Return G.DrawString(text, Font, b1, x, y) End Sub #End Region #Region " DrawImage Overloads " 'TODO: Remove triple overloads? Private DrawImagePoint As Point Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer) DrawImage(_Image, a, x, y) End Sub Protected Sub DrawImage(ByVal p1 As Point) DrawImage(_Image, p1.X, p1.Y) End Sub Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer) DrawImage(_Image, x, y) End Sub Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer) If image Is Nothing Then Return DrawImagePoint = New Point(Width \ 2 - image.Width \ 2, MoveHeight \ 2 - image.Height \ 2) Select Case a Case HorizontalAlignment.Left DrawImage(image, x, DrawImagePoint.Y + y) Case HorizontalAlignment.Center DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y) Case HorizontalAlignment.Right DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y) End Select End Sub Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point) DrawImage(image, p1.X, p1.Y) End Sub Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer) If image Is Nothing Then Return G.DrawImage(image, x, y, image.Width, image.Height) End Sub #End Region #Region " DrawGradient Overloads " 'TODO: Remove triple overload? Private DrawGradientBrush As LinearGradientBrush Private DrawGradientRectangle As Rectangle Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) DrawGradient(blend, x, y, width, height, 90S) End Sub Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) DrawGradient(c1, c2, x, y, width, height, 90S) End Sub Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single) DrawGradientRectangle = New Rectangle(x, y, width, height) DrawGradient(blend, DrawGradientRectangle, angle) End Sub Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single) DrawGradientRectangle = New Rectangle(x, y, width, height) DrawGradient(c1, c2, DrawGradientRectangle, angle) End Sub Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single) DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle) DrawGradientBrush.InterpolationColors = blend G.FillRectangle(DrawGradientBrush, r) End Sub Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single) DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle) G.FillRectangle(DrawGradientBrush, r) End Sub #End Region End Class MustInherit Class ThemeControl151 Inherits Control Protected G As Graphics, B As Bitmap Sub New() SetStyle(DirectCast(139270, ControlStyles), True) _ImageSize = Size.Empty MeasureBitmap = New Bitmap(1, 1) MeasureGraphics = Graphics.FromImage(MeasureBitmap) Font = New Font("Verdana", 8S) InvalidateCustimization() End Sub Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified) If Not _LockWidth = 0 Then width = _LockWidth If Not _LockHeight = 0 Then height = _LockHeight MyBase.SetBoundsCore(x, y, width, height, specified) End Sub Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs) If _Transparent AndAlso Not (Width = 0 OrElse Height = 0) Then B = New Bitmap(Width, Height) G = Graphics.FromImage(B) End If Invalidate() MyBase.OnSizeChanged(e) End Sub Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs) If Width = 0 OrElse Height = 0 Then Return If _Transparent Then PaintHook() e.Graphics.DrawImage(B, 0, 0) Else G = e.Graphics PaintHook() End If End Sub Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs) InvalidateCustimization() ColorHook() If Not _LockWidth = 0 Then Width = _LockWidth If Not _LockHeight = 0 Then Height = _LockHeight If Not BackColorWait = Nothing Then BackColor = BackColorWait OnCreation() MyBase.OnHandleCreated(e) End Sub Protected Overridable Sub OnCreation() End Sub #Region " State Handling " Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs) SetState(MouseState.Over) MyBase.OnMouseEnter(e) End Sub Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs) SetState(MouseState.Over) MyBase.OnMouseUp(e) End Sub Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs) If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down) MyBase.OnMouseDown(e) End Sub Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs) SetState(MouseState.None) MyBase.OnMouseLeave(e) End Sub Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs) If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block) MyBase.OnEnabledChanged(e) End Sub Protected State As MouseState Private Sub SetState(ByVal current As MouseState) State = current Invalidate() End Sub #End Region #Region " Property Overrides " Private BackColorWait As Color Overrides Property BackColor() As Color Get Return MyBase.BackColor End Get Set(ByVal value As Color) If IsHandleCreated Then MyBase.BackColor = value Else BackColorWait = value End If End Set End Property <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _ Overrides Property ForeColor() As Color Get Return Color.Empty End Get Set(ByVal value As Color) End Set End Property <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _ Overrides Property BackgroundImage() As Image Get Return Nothing End Get Set(ByVal value As Image) End Set End Property <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _ Overrides Property BackgroundImageLayout() As ImageLayout Get Return ImageLayout.None End Get Set(ByVal value As ImageLayout) End Set End Property Overrides Property Text() As String Get Return MyBase.Text End Get Set(ByVal value As String) MyBase.Text = value Invalidate() End Set End Property Overrides Property Font() As Font Get Return MyBase.Font End Get Set(ByVal value As Font) MyBase.Font = value Invalidate() End Set End Property #End Region #Region " Properties " Private _NoRounding As Boolean Property NoRounding() As Boolean Get Return _NoRounding End Get Set(ByVal v As Boolean) _NoRounding = v Invalidate() End Set End Property Private _Image As Image Property Image() As Image Get Return _Image End Get Set(ByVal value As Image) If value Is Nothing Then _ImageSize = Size.Empty Else _ImageSize = value.Size End If _Image = value Invalidate() End Set End Property Private _ImageSize As Size Protected ReadOnly Property ImageSize() As Size Get Return _ImageSize End Get End Property Private _LockWidth As Integer Protected Property LockWidth() As Integer Get Return _LockWidth End Get Set(ByVal value As Integer) _LockWidth = value If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth End Set End Property Private _LockHeight As Integer Protected Property LockHeight() As Integer Get Return _LockHeight End Get Set(ByVal value As Integer) _LockHeight = value If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight End Set End Property Private _Transparent As Boolean Property Transparent() As Boolean Get Return _Transparent End Get Set(ByVal value As Boolean) If Not value AndAlso Not BackColor.A = 255 Then Throw New Exception("Unable to change value to false while a transparent BackColor is in use.") End If SetStyle(ControlStyles.Opaque, Not value) SetStyle(ControlStyles.SupportsTransparentBackColor, value) If value Then InvalidateBitmap() Else B = Nothing _Transparent = value Invalidate() End Set End Property Private Items As New Dictionary(Of String, Color) <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _ Property Colors() As Bloom() Get Dim T As New List(Of Bloom) Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator While E.MoveNext T.Add(New Bloom(E.Current.Key, E.Current.Value)) End While Return T.ToArray End Get Set(ByVal value As Bloom()) For Each B As Bloom In value If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value Next InvalidateCustimization() ColorHook() Invalidate() End Set End Property Private _Customization As String Property Customization() As String Get Return _Customization End Get Set(ByVal value As String) If value = _Customization Then Return Dim Data As Byte() Dim Items As Bloom() = Colors Try Data = Convert.FromBase64String(value) For I As Integer = 0 To Items.Length - 1 Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4)) Next Catch Return End Try _Customization = value Colors = Items ColorHook() Invalidate() End Set End Property #End Region #Region " Property Helpers " Private Sub InvalidateBitmap() If Width = 0 OrElse Height = 0 Then Return B = New Bitmap(Width, Height) G = Graphics.FromImage(B) End Sub Protected Function GetColor(ByVal name As String) As Color Return Items(name) End Function Protected Sub SetColor(ByVal name As String, ByVal color As Color) If Items.ContainsKey(name) Then Items(name) = color Else Items.Add(name, color) End Sub Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte) SetColor(name, Color.FromArgb(r, g, b)) End Sub Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte) SetColor(name, Color.FromArgb(a, r, g, b)) End Sub Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal color As Color) SetColor(name, color.FromArgb(a, color)) End Sub Private Sub InvalidateCustimization() Dim M As New MemoryStream(Items.Count * 4) For Each B As Bloom In Colors M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4) Next M.Close() _Customization = Convert.ToBase64String(M.ToArray) End Sub #End Region #Region " User Hooks " Protected MustOverride Sub ColorHook() Protected MustOverride Sub PaintHook() #End Region #Region " Center Overloads " Private CenterReturn As Point Protected Function Center(ByVal r1 As Rectangle, ByVal s1 As Size) As Point CenterReturn = New Point((r1.Width \ 2 - s1.Width \ 2) + r1.X, (r1.Height \ 2 - s1.Height \ 2) + r1.Y) Return CenterReturn End Function Protected Function Center(ByVal r1 As Rectangle, ByVal r2 As Rectangle) As Point Return Center(r1, r2.Size) End Function Protected Function Center(ByVal w1 As Integer, ByVal h1 As Integer, ByVal w2 As Integer, ByVal h2 As Integer) As Point CenterReturn = New Point(w1 \ 2 - w2 \ 2, h1 \ 2 - h2 \ 2) Return CenterReturn End Function Protected Function Center(ByVal s1 As Size, ByVal s2 As Size) As Point Return Center(s1.Width, s1.Height, s2.Width, s2.Height) End Function Protected Function Center(ByVal r1 As Rectangle) As Point Return Center(ClientRectangle.Width, ClientRectangle.Height, r1.Width, r1.Height) End Function Protected Function Center(ByVal s1 As Size) As Point Return Center(Width, Height, s1.Width, s1.Height) End Function Protected Function Center(ByVal w1 As Integer, ByVal h1 As Integer) As Point Return Center(Width, Height, w1, h1) End Function #End Region #Region " Measure Overloads " Private MeasureBitmap As Bitmap Private MeasureGraphics As Graphics Protected Function Measure(ByVal text As String) As Size Return MeasureGraphics.MeasureString(text, Font, Width).ToSize End Function Protected Function Measure() As Size Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize End Function #End Region #Region " DrawCorners Overloads " 'TODO: Optimize by checking brush color Private DrawCornersBrush As SolidBrush Protected Sub DrawCorners(ByVal c1 As Color) DrawCorners(c1, 0, 0, Width, Height) End Sub Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle) DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height) End Sub Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) If _NoRounding Then Return If _Transparent Then B.SetPixel(x, y, c1) B.SetPixel(x + (width - 1), y, c1) B.SetPixel(x, y + (height - 1), c1) B.SetPixel(x + (width - 1), y + (height - 1), c1) Else DrawCornersBrush = New SolidBrush(c1) G.FillRectangle(DrawCornersBrush, x, y, 1, 1) G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1) G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1) G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1) End If End Sub #End Region #Region " DrawBorders Overloads " 'TODO: Remove triple overload? Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer) DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2)) End Sub Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer) DrawBorders(p1, 0, 0, Width, Height, offset) End Sub Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer) DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset) End Sub Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) G.DrawRectangle(p1, x, y, width - 1, height - 1) End Sub Protected Sub DrawBorders(ByVal p1 As Pen) DrawBorders(p1, 0, 0, Width, Height) End Sub Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle) DrawBorders(p1, r.X, r.Y, r.Width, r.Height) End Sub #End Region #Region " DrawText Overloads " 'TODO: Remove triple overloads? Private DrawTextPoint As Point Private DrawTextSize As Size Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer) DrawText(b1, Text, a, x, y) End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point) DrawText(b1, Text, p1.X, p1.Y) End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer) DrawText(b1, Text, x, y) End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer) If text.Length = 0 Then Return DrawTextSize = Measure(text) DrawTextPoint = Center(DrawTextSize) Select Case a Case HorizontalAlignment.Left DrawText(b1, text, x, DrawTextPoint.Y + y) Case HorizontalAlignment.Center DrawText(b1, text, DrawTextPoint.X + x, DrawTextPoint.Y + y) Case HorizontalAlignment.Right DrawText(b1, text, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y) End Select End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal p1 As Point) DrawText(b1, text, p1.X, p1.Y) End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal x As Integer, ByVal y As Integer) If text.Length = 0 Then Return G.DrawString(text, Font, b1, x, y) End Sub #End Region #Region " DrawImage Overloads " 'TODO: Remove triple overloads? Private DrawImagePoint As Point Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer) DrawImage(_Image, a, x, y) End Sub Protected Sub DrawImage(ByVal p1 As Point) DrawImage(_Image, p1.X, p1.Y) End Sub Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer) DrawImage(_Image, x, y) End Sub Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer) If image Is Nothing Then Return DrawImagePoint = Center(image.Size) Select Case a Case HorizontalAlignment.Left DrawImage(image, x, DrawImagePoint.Y + y) Case HorizontalAlignment.Center DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y) Case HorizontalAlignment.Right DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y) End Select End Sub Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point) DrawImage(image, p1.X, p1.Y) End Sub Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer) If image Is Nothing Then Return G.DrawImage(image, x, y, image.Width, image.Height) End Sub #End Region #Region " DrawGradient Overloads " 'TODO: Remove triple overload? Private DrawGradientBrush As LinearGradientBrush Private DrawGradientRectangle As Rectangle Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) DrawGradient(blend, x, y, width, height, 90S) End Sub Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) DrawGradient(c1, c2, x, y, width, height, 90S) End Sub Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single) DrawGradientRectangle = New Rectangle(x, y, width, height) DrawGradient(blend, DrawGradientRectangle, angle) End Sub Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single) DrawGradientRectangle = New Rectangle(x, y, width, height) DrawGradient(c1, c2, DrawGradientRectangle, angle) End Sub Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single) DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle) DrawGradientBrush.InterpolationColors = blend G.FillRectangle(DrawGradientBrush, r) End Sub Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single) DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle) G.FillRectangle(DrawGradientBrush, r) End Sub #End Region End Class
-
28.06.2012, 22:48 #9
AW: Design Warnungen
Muss der ThemenContainer an 1. Stelle also unter die Imports?
Bzw. unter 'Theme ?
-
29.06.2012, 01:01 #10
AW: Design Warnungen
Hab dir mal alles so zusammen geschoben, dass dort keine Meldungen mehr ausgegeben werden dürften.
Ersetz diesen Code mit deinem, dann sollte das passen!
Spoiler:
Code:Imports System.Drawing.Drawing2D Imports System, System.IO, System.Collections.Generic Imports System.Drawing Imports System.ComponentModel, System.Windows.Forms #Region "THEMEBASE" MustInherit Class ThemeControl151 Inherits Control Protected G As Graphics, B As Bitmap Sub New() SetStyle(DirectCast(139270, ControlStyles), True) _ImageSize = Size.Empty MeasureBitmap = New Bitmap(1, 1) MeasureGraphics = Graphics.FromImage(MeasureBitmap) Font = New Font("Verdana", 8S) InvalidateCustimization() End Sub Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified) If Not _LockWidth = 0 Then width = _LockWidth If Not _LockHeight = 0 Then height = _LockHeight MyBase.SetBoundsCore(x, y, width, height, specified) End Sub Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs) If _Transparent AndAlso Not (Width = 0 OrElse Height = 0) Then B = New Bitmap(Width, Height) G = Graphics.FromImage(B) End If Invalidate() MyBase.OnSizeChanged(e) End Sub Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs) If Width = 0 OrElse Height = 0 Then Return If _Transparent Then PaintHook() e.Graphics.DrawImage(B, 0, 0) Else G = e.Graphics PaintHook() End If End Sub Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs) InvalidateCustimization() ColorHook() If Not _LockWidth = 0 Then Width = _LockWidth If Not _LockHeight = 0 Then Height = _LockHeight If Not BackColorWait = Nothing Then BackColor = BackColorWait OnCreation() MyBase.OnHandleCreated(e) End Sub Protected Overridable Sub OnCreation() End Sub #Region " State Handling " Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs) SetState(MouseState.Over) MyBase.OnMouseEnter(e) End Sub Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs) SetState(MouseState.Over) MyBase.OnMouseUp(e) End Sub Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs) If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down) MyBase.OnMouseDown(e) End Sub Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs) SetState(MouseState.None) MyBase.OnMouseLeave(e) End Sub Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs) If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block) MyBase.OnEnabledChanged(e) End Sub Protected State As MouseState Private Sub SetState(ByVal current As MouseState) State = current Invalidate() End Sub #End Region #Region " Property Overrides " Private BackColorWait As Color Overrides Property BackColor() As Color Get Return MyBase.BackColor End Get Set(ByVal value As Color) If IsHandleCreated Then MyBase.BackColor = value Else BackColorWait = value End If End Set End Property <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _ Overrides Property ForeColor() As Color Get Return Color.Empty End Get Set(ByVal value As Color) End Set End Property <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _ Overrides Property BackgroundImage() As Image Get Return Nothing End Get Set(ByVal value As Image) End Set End Property <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _ Overrides Property BackgroundImageLayout() As ImageLayout Get Return ImageLayout.None End Get Set(ByVal value As ImageLayout) End Set End Property Overrides Property Text() As String Get Return MyBase.Text End Get Set(ByVal value As String) MyBase.Text = value Invalidate() End Set End Property Overrides Property Font() As Font Get Return MyBase.Font End Get Set(ByVal value As Font) MyBase.Font = value Invalidate() End Set End Property #End Region #Region " Properties " Private _NoRounding As Boolean Property NoRounding() As Boolean Get Return _NoRounding End Get Set(ByVal v As Boolean) _NoRounding = v Invalidate() End Set End Property Private _Image As Image Property Image() As Image Get Return _Image End Get Set(ByVal value As Image) If value Is Nothing Then _ImageSize = Size.Empty Else _ImageSize = value.Size End If _Image = value Invalidate() End Set End Property Private _ImageSize As Size Protected ReadOnly Property ImageSize() As Size Get Return _ImageSize End Get End Property Private _LockWidth As Integer Protected Property LockWidth() As Integer Get Return _LockWidth End Get Set(ByVal value As Integer) _LockWidth = value If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth End Set End Property Private _LockHeight As Integer Protected Property LockHeight() As Integer Get Return _LockHeight End Get Set(ByVal value As Integer) _LockHeight = value If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight End Set End Property Private _Transparent As Boolean Property Transparent() As Boolean Get Return _Transparent End Get Set(ByVal value As Boolean) If Not value AndAlso Not BackColor.A = 255 Then Throw New Exception("Unable to change value to false while a transparent BackColor is in use.") End If SetStyle(ControlStyles.Opaque, Not value) SetStyle(ControlStyles.SupportsTransparentBackColor, value) If value Then InvalidateBitmap() Else B = Nothing _Transparent = value Invalidate() End Set End Property Private Items As New Dictionary(Of String, Color) <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _ Property Colors() As Bloom() Get Dim T As New List(Of Bloom) Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator While E.MoveNext T.Add(New Bloom(E.Current.Key, E.Current.Value)) End While Return T.ToArray End Get Set(ByVal value As Bloom()) For Each B As Bloom In value If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value Next InvalidateCustimization() ColorHook() Invalidate() End Set End Property Private _Customization As String Property Customization() As String Get Return _Customization End Get Set(ByVal value As String) If value = _Customization Then Return Dim Data As Byte() Dim Items As Bloom() = Colors Try Data = Convert.FromBase64String(value) For I As Integer = 0 To Items.Length - 1 Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4)) Next Catch Return End Try _Customization = value Colors = Items ColorHook() Invalidate() End Set End Property #End Region #Region " Property Helpers " Private Sub InvalidateBitmap() If Width = 0 OrElse Height = 0 Then Return B = New Bitmap(Width, Height) G = Graphics.FromImage(B) End Sub Protected Function GetColor(ByVal name As String) As Color Return Items(name) End Function Protected Sub SetColor(ByVal name As String, ByVal color As Color) If Items.ContainsKey(name) Then Items(name) = color Else Items.Add(name, color) End Sub Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte) SetColor(name, Color.FromArgb(r, g, b)) End Sub Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte) SetColor(name, Color.FromArgb(a, r, g, b)) End Sub Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal color As Color) SetColor(name, color.FromArgb(a, color)) End Sub Private Sub InvalidateCustimization() Dim M As New MemoryStream(Items.Count * 4) For Each B As Bloom In Colors M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4) Next M.Close() _Customization = Convert.ToBase64String(M.ToArray) End Sub #End Region #Region " User Hooks " Protected MustOverride Sub ColorHook() Protected MustOverride Sub PaintHook() #End Region #Region " Center Overloads " Private CenterReturn As Point Protected Function Center(ByVal r1 As Rectangle, ByVal s1 As Size) As Point CenterReturn = New Point((r1.Width \ 2 - s1.Width \ 2) + r1.X, (r1.Height \ 2 - s1.Height \ 2) + r1.Y) Return CenterReturn End Function Protected Function Center(ByVal r1 As Rectangle, ByVal r2 As Rectangle) As Point Return Center(r1, r2.Size) End Function Protected Function Center(ByVal w1 As Integer, ByVal h1 As Integer, ByVal w2 As Integer, ByVal h2 As Integer) As Point CenterReturn = New Point(w1 \ 2 - w2 \ 2, h1 \ 2 - h2 \ 2) Return CenterReturn End Function Protected Function Center(ByVal s1 As Size, ByVal s2 As Size) As Point Return Center(s1.Width, s1.Height, s2.Width, s2.Height) End Function Protected Function Center(ByVal r1 As Rectangle) As Point Return Center(ClientRectangle.Width, ClientRectangle.Height, r1.Width, r1.Height) End Function Protected Function Center(ByVal s1 As Size) As Point Return Center(Width, Height, s1.Width, s1.Height) End Function Protected Function Center(ByVal w1 As Integer, ByVal h1 As Integer) As Point Return Center(Width, Height, w1, h1) End Function #End Region #Region " Measure Overloads " Private MeasureBitmap As Bitmap Private MeasureGraphics As Graphics Protected Function Measure(ByVal text As String) As Size Return MeasureGraphics.MeasureString(text, Font, Width).ToSize End Function Protected Function Measure() As Size Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize End Function #End Region #Region " DrawCorners Overloads " 'TODO: Optimize by checking brush color Private DrawCornersBrush As SolidBrush Protected Sub DrawCorners(ByVal c1 As Color) DrawCorners(c1, 0, 0, Width, Height) End Sub Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle) DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height) End Sub Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) If _NoRounding Then Return If _Transparent Then B.SetPixel(x, y, c1) B.SetPixel(x + (width - 1), y, c1) B.SetPixel(x, y + (height - 1), c1) B.SetPixel(x + (width - 1), y + (height - 1), c1) Else DrawCornersBrush = New SolidBrush(c1) G.FillRectangle(DrawCornersBrush, x, y, 1, 1) G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1) G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1) G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1) End If End Sub #End Region #Region " DrawBorders Overloads " 'TODO: Remove triple overload? Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer) DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2)) End Sub Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer) DrawBorders(p1, 0, 0, Width, Height, offset) End Sub Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer) DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset) End Sub Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) G.DrawRectangle(p1, x, y, width - 1, height - 1) End Sub Protected Sub DrawBorders(ByVal p1 As Pen) DrawBorders(p1, 0, 0, Width, Height) End Sub Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle) DrawBorders(p1, r.X, r.Y, r.Width, r.Height) End Sub #End Region #Region " DrawText Overloads " 'TODO: Remove triple overloads? Private DrawTextPoint As Point Private DrawTextSize As Size Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer) DrawText(b1, Text, a, x, y) End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point) DrawText(b1, Text, p1.X, p1.Y) End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer) DrawText(b1, Text, x, y) End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer) If text.Length = 0 Then Return DrawTextSize = Measure(text) DrawTextPoint = Center(DrawTextSize) Select Case a Case HorizontalAlignment.Left DrawText(b1, text, x, DrawTextPoint.Y + y) Case HorizontalAlignment.Center DrawText(b1, text, DrawTextPoint.X + x, DrawTextPoint.Y + y) Case HorizontalAlignment.Right DrawText(b1, text, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y) End Select End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal p1 As Point) DrawText(b1, text, p1.X, p1.Y) End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal x As Integer, ByVal y As Integer) If text.Length = 0 Then Return G.DrawString(text, Font, b1, x, y) End Sub #End Region #Region " DrawImage Overloads " 'TODO: Remove triple overloads? Private DrawImagePoint As Point Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer) DrawImage(_Image, a, x, y) End Sub Protected Sub DrawImage(ByVal p1 As Point) DrawImage(_Image, p1.X, p1.Y) End Sub Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer) DrawImage(_Image, x, y) End Sub Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer) If image Is Nothing Then Return DrawImagePoint = Center(image.Size) Select Case a Case HorizontalAlignment.Left DrawImage(image, x, DrawImagePoint.Y + y) Case HorizontalAlignment.Center DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y) Case HorizontalAlignment.Right DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y) End Select End Sub Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point) DrawImage(image, p1.X, p1.Y) End Sub Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer) If image Is Nothing Then Return G.DrawImage(image, x, y, image.Width, image.Height) End Sub #End Region #Region " DrawGradient Overloads " 'TODO: Remove triple overload? Private DrawGradientBrush As LinearGradientBrush Private DrawGradientRectangle As Rectangle Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) DrawGradient(blend, x, y, width, height, 90S) End Sub Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) DrawGradient(c1, c2, x, y, width, height, 90S) End Sub Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single) DrawGradientRectangle = New Rectangle(x, y, width, height) DrawGradient(blend, DrawGradientRectangle, angle) End Sub Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single) DrawGradientRectangle = New Rectangle(x, y, width, height) DrawGradient(c1, c2, DrawGradientRectangle, angle) End Sub Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single) DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle) DrawGradientBrush.InterpolationColors = blend G.FillRectangle(DrawGradientBrush, r) End Sub Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single) DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle) G.FillRectangle(DrawGradientBrush, r) End Sub #End Region End Class Enum MouseState As Byte None = 0 Over = 1 Down = 2 Block = 3 End Enum Class Bloom Private _Name As String Property Name() As String Get Return _Name End Get Set(ByVal value As String) _Name = value End Set End Property Private _Value As Color Property Value() As Color Get Return _Value End Get Set(ByVal value As Color) _Value = value End Set End Property Sub New() End Sub Sub New(ByVal name As String, ByVal value As Color) _Name = name _Value = value End Sub End Class MustInherit Class ThemeContainer151 Inherits ContainerControl Protected G As Graphics Sub New() SetStyle(DirectCast(139270, ControlStyles), True) _ImageSize = Size.Empty MeasureBitmap = New Bitmap(1, 1) MeasureGraphics = Graphics.FromImage(MeasureBitmap) Font = New Font("Verdana", 8S) InvalidateCustimization() End Sub Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified) If Not _LockWidth = 0 Then width = _LockWidth If Not _LockHeight = 0 Then height = _LockHeight MyBase.SetBoundsCore(x, y, width, height, specified) End Sub Private Header As Rectangle Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs) MyBase.OnSizeChanged(e) If _Movable AndAlso Not _ControlMode Then Header = New Rectangle(7, 7, Width - 14, _MoveHeight - 7) Invalidate() End Sub Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs) If Width = 0 OrElse Height = 0 Then Return G = e.Graphics PaintHook() End Sub Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs) InitializeMessages() InvalidateCustimization() ColorHook() _IsParentForm = TypeOf Parent Is Form If Not _ControlMode Then Dock = DockStyle.Fill If Not _LockWidth = 0 Then Width = _LockWidth If Not _LockHeight = 0 Then Height = _LockHeight If Not BackColorWait = Nothing Then BackColor = BackColorWait If _IsParentForm AndAlso Not _ControlMode Then ParentForm.FormBorderStyle = _BorderStyle ParentForm.TransparencyKey = _TransparencyKey End If OnCreation() MyBase.OnHandleCreated(e) End Sub Protected Overridable Sub OnCreation() End Sub #Region " Sizing and Movement " Protected State As MouseState Private Sub SetState(ByVal current As MouseState) State = current Invalidate() End Sub Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs) If _Sizable AndAlso Not _ControlMode Then InvalidateMouse() MyBase.OnMouseMove(e) End Sub Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs) If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block) MyBase.OnEnabledChanged(e) End Sub Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs) SetState(MouseState.Over) MyBase.OnMouseEnter(e) End Sub Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs) SetState(MouseState.Over) MyBase.OnMouseUp(e) End Sub Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs) SetState(MouseState.None) If _Sizable AndAlso Not _ControlMode AndAlso GetChildAtPoint(PointToClient(MousePosition)) IsNot Nothing Then Cursor = Cursors.Default Previous = 0 End If MyBase.OnMouseLeave(e) End Sub Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs) MyBase.OnMouseDown(e) If Not e.Button = Windows.Forms.MouseButtons.Left Then Return SetState(MouseState.Down) If _IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized OrElse _ControlMode Then Return If _Movable AndAlso Header.Contains(e.Location) Then Capture = False DefWndProc(Messages(0)) ElseIf _Sizable AndAlso Not Previous = 0 Then Capture = False DefWndProc(Messages(Previous)) End If End Sub Private GetIndexPoint As Point Private B1, B2, B3, B4 As Boolean Private Function GetIndex() As Integer GetIndexPoint = PointToClient(MousePosition) B1 = GetIndexPoint.X < 7 B2 = GetIndexPoint.X > Width - 7 B3 = GetIndexPoint.Y < 7 B4 = GetIndexPoint.Y > Height - 7 If B1 AndAlso B3 Then Return 4 If B1 AndAlso B4 Then Return 7 If B2 AndAlso B3 Then Return 5 If B2 AndAlso B4 Then Return 8 If B1 Then Return 1 If B2 Then Return 2 If B3 Then Return 3 If B4 Then Return 6 Return 0 End Function Private Current, Previous As Integer Private Sub InvalidateMouse() Current = GetIndex() If Current = Previous Then Return Previous = Current Select Case Previous Case 0 Cursor = Cursors.Default Case 1, 2 Cursor = Cursors.SizeWE Case 3, 6 Cursor = Cursors.SizeNS Case 4, 8 Cursor = Cursors.SizeNWSE Case 5, 7 Cursor = Cursors.SizeNESW End Select End Sub Private Messages(8) As Message Private Sub InitializeMessages() Messages(0) = Message.Create(Parent.Handle, 161, New IntPtr(2), IntPtr.Zero) For I As Integer = 1 To 8 Messages(I) = Message.Create(Parent.Handle, 161, New IntPtr(I + 9), IntPtr.Zero) Next End Sub #End Region #Region " Property Overrides " Private BackColorWait As Color Overrides Property BackColor() As Color Get Return MyBase.BackColor End Get Set(ByVal value As Color) If IsHandleCreated Then If Not _ControlMode Then Parent.BackColor = value MyBase.BackColor = value Else BackColorWait = value End If End Set End Property <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _ Overrides Property ForeColor() As Color Get Return Color.Empty End Get Set(ByVal value As Color) End Set End Property <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _ Overrides Property BackgroundImage() As Image Get Return Nothing End Get Set(ByVal value As Image) End Set End Property <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _ Overrides Property BackgroundImageLayout() As ImageLayout Get Return ImageLayout.None End Get Set(ByVal value As ImageLayout) End Set End Property Overrides Property Text() As String Get Return MyBase.Text End Get Set(ByVal value As String) MyBase.Text = value Invalidate() End Set End Property Overrides Property Font() As Font Get Return MyBase.Font End Get Set(ByVal value As Font) MyBase.Font = value Invalidate() End Set End Property #End Region #Region " Properties " Private _Movable As Boolean = True Property Movable() As Boolean Get Return _Movable End Get Set(ByVal value As Boolean) _Movable = value End Set End Property Private _Sizable As Boolean = True Property Sizable() As Boolean Get Return _Sizable End Get Set(ByVal value As Boolean) _Sizable = value End Set End Property Private _MoveHeight As Integer = 24 Protected Property MoveHeight() As Integer Get Return _MoveHeight End Get Set(ByVal v As Integer) If v < 8 Then Return Header = New Rectangle(7, 7, Width - 14, v - 7) _MoveHeight = v Invalidate() End Set End Property Private _ControlMode As Boolean Protected Property ControlMode() As Boolean Get Return _ControlMode End Get Set(ByVal v As Boolean) _ControlMode = v End Set End Property Private _TransparencyKey As Color Property TransparencyKey() As Color Get If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.TransparencyKey Else Return _TransparencyKey End Get Set(ByVal value As Color) If _IsParentForm AndAlso Not _ControlMode Then ParentForm.TransparencyKey = value _TransparencyKey = value End Set End Property Private _BorderStyle As FormBorderStyle Property BorderStyle() As FormBorderStyle Get If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.FormBorderStyle Else Return _BorderStyle End Get Set(ByVal value As FormBorderStyle) If _IsParentForm AndAlso Not _ControlMode Then ParentForm.FormBorderStyle = value _BorderStyle = value End Set End Property Private _NoRounding As Boolean Property NoRounding() As Boolean Get Return _NoRounding End Get Set(ByVal v As Boolean) _NoRounding = v Invalidate() End Set End Property Private _Image As Image Property Image() As Image Get Return _Image End Get Set(ByVal value As Image) If value Is Nothing Then _ImageSize = Size.Empty Else _ImageSize = value.Size End If _Image = value Invalidate() End Set End Property Private _ImageSize As Size Protected ReadOnly Property ImageSize() As Size Get Return _ImageSize End Get End Property Private _IsParentForm As Boolean Protected ReadOnly Property IsParentForm As Boolean Get Return _IsParentForm End Get End Property Private _LockWidth As Integer Protected Property LockWidth() As Integer Get Return _LockWidth End Get Set(ByVal value As Integer) _LockWidth = value If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth End Set End Property Private _LockHeight As Integer Protected Property LockHeight() As Integer Get Return _LockHeight End Get Set(ByVal value As Integer) _LockHeight = value If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight End Set End Property Private Items As New Dictionary(Of String, Color) <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _ Property Colors() As Bloom() Get Dim T As New List(Of Bloom) Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator While E.MoveNext T.Add(New Bloom(E.Current.Key, E.Current.Value)) End While Return T.ToArray End Get Set(ByVal value As Bloom()) For Each B As Bloom In value If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value Next InvalidateCustimization() ColorHook() Invalidate() End Set End Property Private _Customization As String Property Customization() As String Get Return _Customization End Get Set(ByVal value As String) If value = _Customization Then Return Dim Data As Byte() Dim Items As Bloom() = Colors Try Data = Convert.FromBase64String(value) For I As Integer = 0 To Items.Length - 1 Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4)) Next Catch Return End Try _Customization = value Colors = Items ColorHook() Invalidate() End Set End Property #End Region #Region " Property Helpers " Protected Function GetColor(ByVal name As String) As Color Return Items(name) End Function Protected Sub SetColor(ByVal name As String, ByVal color As Color) If Items.ContainsKey(name) Then Items(name) = color Else Items.Add(name, color) End Sub Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte) SetColor(name, Color.FromArgb(r, g, b)) End Sub Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte) SetColor(name, Color.FromArgb(a, r, g, b)) End Sub Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal color As Color) SetColor(name, color.FromArgb(a, color)) End Sub Private Sub InvalidateCustimization() Dim M As New MemoryStream(Items.Count * 4) For Each B As Bloom In Colors M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4) Next M.Close() _Customization = Convert.ToBase64String(M.ToArray) End Sub #End Region #Region " User Hooks " Protected MustOverride Sub ColorHook() Protected MustOverride Sub PaintHook() #End Region #Region " Center Overloads " Private CenterReturn As Point Protected Function Center(ByVal r1 As Rectangle, ByVal s1 As Size) As Point CenterReturn = New Point((r1.Width \ 2 - s1.Width \ 2) + r1.X, (r1.Height \ 2 - s1.Height \ 2) + r1.Y) Return CenterReturn End Function Protected Function Center(ByVal r1 As Rectangle, ByVal r2 As Rectangle) As Point Return Center(r1, r2.Size) End Function Protected Function Center(ByVal w1 As Integer, ByVal h1 As Integer, ByVal w2 As Integer, ByVal h2 As Integer) As Point CenterReturn = New Point(w1 \ 2 - w2 \ 2, h1 \ 2 - h2 \ 2) Return CenterReturn End Function Protected Function Center(ByVal s1 As Size, ByVal s2 As Size) As Point Return Center(s1.Width, s1.Height, s2.Width, s2.Height) End Function Protected Function Center(ByVal r1 As Rectangle) As Point Return Center(ClientRectangle.Width, ClientRectangle.Height, r1.Width, r1.Height) End Function Protected Function Center(ByVal s1 As Size) As Point Return Center(Width, Height, s1.Width, s1.Height) End Function Protected Function Center(ByVal w1 As Integer, ByVal h1 As Integer) As Point Return Center(Width, Height, w1, h1) End Function #End Region #Region " Measure Overloads " Private MeasureBitmap As Bitmap Private MeasureGraphics As Graphics Protected Function Measure(ByVal text As String) As Size Return MeasureGraphics.MeasureString(text, Font, Width).ToSize End Function Protected Function Measure() As Size Return MeasureGraphics.MeasureString(Text, Font).ToSize End Function #End Region #Region " DrawCorners Overloads " 'TODO: Optimize by checking brush color Private DrawCornersBrush As SolidBrush Protected Sub DrawCorners(ByVal c1 As Color) DrawCorners(c1, 0, 0, Width, Height) End Sub Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle) DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height) End Sub Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) If _NoRounding Then Return DrawCornersBrush = New SolidBrush(c1) G.FillRectangle(DrawCornersBrush, x, y, 1, 1) G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1) G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1) G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1) End Sub #End Region #Region " DrawBorders Overloads " 'TODO: Remove triple overload? Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer) DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2)) End Sub Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer) DrawBorders(p1, 0, 0, Width, Height, offset) End Sub Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer) DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset) End Sub Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) G.DrawRectangle(p1, x, y, width - 1, height - 1) End Sub Protected Sub DrawBorders(ByVal p1 As Pen) DrawBorders(p1, 0, 0, Width, Height) End Sub Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle) DrawBorders(p1, r.X, r.Y, r.Width, r.Height) End Sub #End Region #Region " DrawText Overloads " 'TODO: Remove triple overloads? Private DrawTextPoint As Point Private DrawTextSize As Size Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer) DrawText(b1, Text, a, x, y) End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point) DrawText(b1, Text, p1.X, p1.Y) End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer) DrawText(b1, Text, x, y) End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer) If text.Length = 0 Then Return DrawTextSize = Measure(text) DrawTextPoint = New Point(Width \ 2 - DrawTextSize.Width \ 2, MoveHeight \ 2 - DrawTextSize.Height \ 2) Select Case a Case HorizontalAlignment.Left DrawText(b1, text, x, DrawTextPoint.Y + y) Case HorizontalAlignment.Center DrawText(b1, text, DrawTextPoint.X + x, DrawTextPoint.Y + y) Case HorizontalAlignment.Right DrawText(b1, text, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y) End Select End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal p1 As Point) DrawText(b1, text, p1.X, p1.Y) End Sub Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal x As Integer, ByVal y As Integer) If text.Length = 0 Then Return G.DrawString(text, Font, b1, x, y) End Sub #End Region #Region " DrawImage Overloads " 'TODO: Remove triple overloads? Private DrawImagePoint As Point Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer) DrawImage(_Image, a, x, y) End Sub Protected Sub DrawImage(ByVal p1 As Point) DrawImage(_Image, p1.X, p1.Y) End Sub Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer) DrawImage(_Image, x, y) End Sub Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer) If image Is Nothing Then Return DrawImagePoint = New Point(Width \ 2 - image.Width \ 2, MoveHeight \ 2 - image.Height \ 2) Select Case a Case HorizontalAlignment.Left DrawImage(image, x, DrawImagePoint.Y + y) Case HorizontalAlignment.Center DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y) Case HorizontalAlignment.Right DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y) End Select End Sub Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point) DrawImage(image, p1.X, p1.Y) End Sub Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer) If image Is Nothing Then Return G.DrawImage(image, x, y, image.Width, image.Height) End Sub #End Region #Region " DrawGradient Overloads " 'TODO: Remove triple overload? Private DrawGradientBrush As LinearGradientBrush Private DrawGradientRectangle As Rectangle Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) DrawGradient(blend, x, y, width, height, 90S) End Sub Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) DrawGradient(c1, c2, x, y, width, height, 90S) End Sub Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single) DrawGradientRectangle = New Rectangle(x, y, width, height) DrawGradient(blend, DrawGradientRectangle, angle) End Sub Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single) DrawGradientRectangle = New Rectangle(x, y, width, height) DrawGradient(c1, c2, DrawGradientRectangle, angle) End Sub Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single) DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle) DrawGradientBrush.InterpolationColors = blend G.FillRectangle(DrawGradientBrush, r) End Sub Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single) DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle) G.FillRectangle(DrawGradientBrush, r) End Sub #End Region End Class #End Region #Region "THEME" Class AdvantiumTheme Inherits ThemeContainer151 Sub New() TransparencyKey = Color.Fuchsia MoveHeight = 35 SetColor("BackColor", Color.FromArgb(40, 40, 40)) SetColor("BorderInner", Color.FromArgb(65, 65, 65)) SetColor("BorderColor", Color.Black) SetColor("TextColor", Color.LawnGreen) End Sub Dim C1, BC, BA, T1 As Color Protected Overrides Sub ColorHook() C1 = GetColor("BackColor") BC = GetColor("BorderColor") BA = GetColor("BorderInner") T1 = GetColor("TextColor") End Sub Protected Overrides Sub PaintHook() G.Clear(C1) DrawGradient(Color.FromArgb(20, 20, 20), Color.FromArgb(40, 40, 40), New Rectangle(0, 0, Width, 35), 90S) Dim T As New HatchBrush(HatchStyle.Percent10, Color.FromArgb(25, 25, 25), Color.FromArgb(35, 35, 35)) G.FillRectangle(T, New Rectangle(11, 25, Width - 23, Height - 36)) G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(22, 22, 22))), New Rectangle(11, 25, Width - 23, Height - 36)) G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(40, 40, 40))), New Rectangle(12, 26, Width - 25, Height - 38)) DrawCorners(Color.FromArgb(40, 40, 40), New Rectangle(11, 25, Width - 22, Height - 35)) DrawBorders(New Pen(New SolidBrush(BA)), 1) DrawBorders(New Pen(New SolidBrush(BC))) DrawCorners(TransparencyKey) DrawText(New SolidBrush(T1), HorizontalAlignment.Left, 15, -3) End Sub End Class 'Button Class AdvantiumButton Inherits ThemeControl151 Sub New() SetColor("BackColor", Color.FromArgb(40, 40, 40)) SetColor("TextColor", Color.LawnGreen) End Sub Dim C1, T1 As Color Protected Overrides Sub ColorHook() C1 = GetColor("BackColor") T1 = GetColor("TextColor") End Sub Protected Overrides Sub PaintHook() G.Clear(C1) Select Case State Case 0 'None DrawGradient(Color.FromArgb(50, 50, 50), Color.FromArgb(42, 42, 42), ClientRectangle, 90S) Cursor = Cursors.Arrow Case 1 'Down DrawGradient(Color.FromArgb(50, 50, 50), Color.FromArgb(42, 42, 42), ClientRectangle, 90S) Cursor = Cursors.Hand Case 2 'Over DrawGradient(Color.FromArgb(42, 42, 42), Color.FromArgb(50, 50, 50), ClientRectangle, 90S) Cursor = Cursors.Hand End Select DrawBorders(New Pen(New SolidBrush(Color.FromArgb(59, 59, 59))), 1) DrawBorders(New Pen(New SolidBrush(Color.FromArgb(25, 25, 25)))) DrawCorners(Color.FromArgb(35, 35, 35)) DrawText(New SolidBrush(T1), HorizontalAlignment.Center, 0, 0) End Sub End Class 'Top Button Class AdvantiumTopButton Inherits ThemeControl151 Sub New() SetColor("BackColor", Color.FromArgb(40, 40, 40)) SetColor("TextColor", Color.LawnGreen) Size = New Size(28, 26) End Sub Dim C1, T1 As Color Protected Overrides Sub ColorHook() C1 = GetColor("BackColor") T1 = GetColor("TextColor") End Sub Protected Overrides Sub PaintHook() G.Clear(C1) Select Case State Case 0 'None DrawGradient(Color.FromArgb(38, 38, 38), Color.FromArgb(30, 30, 30), ClientRectangle, 90S) Cursor = Cursors.Arrow Case 1 'Down DrawGradient(Color.FromArgb(50, 50, 50), Color.FromArgb(42, 42, 42), ClientRectangle, 90S) Cursor = Cursors.Hand Case 2 'Over DrawGradient(Color.FromArgb(42, 42, 42), Color.FromArgb(50, 50, 50), ClientRectangle, 90S) Cursor = Cursors.Hand End Select DrawBorders(New Pen(New SolidBrush(Color.FromArgb(65, 65, 65))), New Rectangle(1, 0, Width - 2, Height)) DrawBorders(New Pen(New SolidBrush(Color.FromArgb(22, 22, 22)))) G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(22, 22, 22))), 2, Height - 1, Width - 3, Height - 1) G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(65, 65, 65))), 0, 1, Width - 1, 1) G.DrawLine(New Pen(New SolidBrush(Color.Black)), 0, 0, Width, 0) End Sub End Class 'CheckBox Class AdvantiumCheck Inherits ThemeControl151 Private _CheckedState As Boolean Public Property CheckedState() As Boolean Get Return _CheckedState End Get Set(ByVal v As Boolean) _CheckedState = v Invalidate() End Set End Property Sub New() Size = New Size(100, 15) MinimumSize = New Size(16, 16) MaximumSize = New Size(600, 16) CheckedState = False SetColor("CheckBorderOut", Color.FromArgb(25, 25, 25)) SetColor("CheckBorderIn", Color.FromArgb(59, 59, 59)) SetColor("TextColor", Color.LawnGreen) SetColor("CheckBack1", Color.FromArgb(132, 192, 240)) SetColor("CheckBack2", Color.LawnGreen) SetColor("CheckFore1", Color.LawnGreen) SetColor("CheckFore2", Color.FromArgb(42, 242, 77)) SetColor("ColorUncheck", Color.FromArgb(35, 35, 35)) SetColor("BackColor", Color.FromArgb(35, 35, 35)) End Sub Dim C1, C2, C3, C4, C5, C6, P1, P2, B1 As Color Protected Overrides Sub ColorHook() C1 = GetColor("CheckBack1") C2 = GetColor("CheckBack2") C3 = GetColor("CheckFore1") C4 = GetColor("CheckFore2") C5 = GetColor("ColorUncheck") C6 = GetColor("BackColor") P1 = GetColor("CheckBorderOut") P2 = GetColor("CheckBorderIn") B1 = GetColor("TextColor") End Sub Protected Overrides Sub PaintHook() G.Clear(C6) Select Case CheckedState Case True DrawGradient(C1, C2, 3, 3, 9, 9, 90S) DrawGradient(C3, C4, 4, 4, 7, 7, 90S) Case False DrawGradient(C5, C5, 0, 0, 15, 15, 90S) End Select G.DrawRectangle(New Pen(New SolidBrush(P1)), 0, 0, 14, 14) G.DrawRectangle(New Pen(New SolidBrush(P2)), 1, 1, 12, 12) DrawText(New SolidBrush(B1), 17, 0) DrawCorners(C6, New Rectangle(0, 0, 13, 13)) End Sub Sub changeCheck() Handles Me.Click Select Case CheckedState Case True CheckedState = False Case False CheckedState = True End Select End Sub End Class #End Region
Gehe zu:
.Net
Nach oben
- Bereiche
- Benutzerkontrollzentrum
- Private Nachrichten
- Abonnements
- Wer ist online
- Foren durchsuchen
- Forum-Startseite
- Foren
- U-Labs Intern
- Talk, Talk, Talk!
- News-Bereich
- Multimedia
- Technikecke
- Programmierung
- Gaming Area
- Knuddels und die Szene
Ähnliche Themen
-
UH Design
Von Shane im Forum ShowroomAntworten: 33Letzter Beitrag: 16.06.2012, 17:54 -
[Design] Simple Design
Von Comu im Forum ShowroomAntworten: 6Letzter Beitrag: 04.03.2012, 16:18 -
[Design] Simple Design
Von Comu im Forum ShowroomAntworten: 7Letzter Beitrag: 04.03.2012, 13:12 -
Design von cs 1.6
Von sL1tchK0ss im Forum Counter StrikeAntworten: 2Letzter Beitrag: 07.02.2012, 23:55 -
[S] Windows Design
Von Boone im Forum WindowsAntworten: 8Letzter Beitrag: 13.12.2011, 00:35
Diese Seite nutzt Cookies, um das Nutzererlebnis zu verbessern. Klicken Sie hier, um das Cookie-Tracking zu deaktivieren.
Alle Zeitangaben in WEZ +2. Es ist jetzt 23:25 Uhr.