Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

[PYTANIE] Skiny aplikacji


Rekomendowane odpowiedzi

Opublikowano

Witajcie :) Ostatnio przesiadłem się z VB.NET na C# i pierwszym moim problemem jest brak skinów, w VB.NET sprawa była o tyle prosta że miałem kilka ThemeArchive'ów a tutaj nic :unsure: I mam pytanko, czy znacie jakiś zbiór (darmowych) skinów, lub czy jest jakiś w miarę prosty i szybki sposób na skiny z VB.NET w aplikacjach napisanych w C#? :( Z góry dzięki za pomoc ;)

apple.png

Opublikowano

Jeżeli chodzi Ci o coś takiego

 

<pre class="_prettyXprint _lang-auto _linenums:0">' ##################################################

' # Credits: #

' # #

' # Tedd - Theme #

' # AeonHack - Themebase #

' # xZ3R0xPROJ3CTx - Help and ideas #

' # #

' ##################################################

Imports System.Drawing.Drawing2D

Imports System.ComponentModel

Imports System.Runtime.InteropServices

 

MustInherit Class Theme

Inherits ContainerControl

 

#Region " Initialization "

 

Protected G As Graphics

Sub New()

SetStyle(DirectCast(139270, ControlStyles), True)

End Sub

 

Private ParentIsForm As Boolean

Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs)

Dock = DockStyle.Fill

ParentIsForm = TypeOf Parent Is Form

If ParentIsForm Then

If Not _TransparencyKey = Color.Empty Then ParentForm.TransparencyKey = _TransparencyKey

ParentForm.FormBorderStyle = FormBorderStyle.FixedSingle

End If

MyBase.OnHandleCreated(e)

End Sub

 

Overrides Property Text As String

Get

Return MyBase.Text

End Get

Set(ByVal v As String)

MyBase.Text = v

Invalidate()

End Set

End Property

#End Region

 

#Region " Sizing and Movement "

 

Private _Resizable As Boolean = True

Property Resizable() As Boolean

Get

Return _Resizable

End Get

Set(ByVal value As Boolean)

_Resizable = value

End Set

End Property

 

Private _MoveHeight As Integer = 24

Property MoveHeight() As Integer

Get

Return _MoveHeight

End Get

Set(ByVal v As Integer)

_MoveHeight = v

Header = New Rectangle(7, 7, Width - 14, _MoveHeight - 7)

End Set

End Property

 

Private Flag As IntPtr

Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)

If Not e.Button = MouseButtons.Left Then Return

If ParentIsForm Then If ParentForm.WindowState = FormWindowState.Maximized Then Return

 

If Header.Contains(e.Location) Then

Flag = New IntPtr(2)

ElseIf Current.Position = 0 Or Not _Resizable Then

Return

Else

Flag = New IntPtr(Current.Position)

End If

 

Capture = False

DefWndProc(Message.Create(Parent.Handle, 161, Flag, Nothing))

 

MyBase.OnMouseDown(e)

End Sub

 

Private Structure Pointer

ReadOnly Cursor As Cursor, Position As Byte

Sub New(ByVal c As Cursor, ByVal p As Byte)

Cursor = c

Position = p

End Sub

End Structure

 

Private F1, F2, F3, F4 As Boolean, PTC As Point

Private Function GetPointer() As Pointer

PTC = PointToClient(MousePosition)

F1 = PTC.X < 7

F2 = PTC.X > Width - 7

F3 = PTC.Y < 7

F4 = PTC.Y > Height - 7

 

If F1 And F3 Then Return New Pointer(Cursors.SizeNWSE, 13)

If F1 And F4 Then Return New Pointer(Cursors.SizeNESW, 16)

If F2 And F3 Then Return New Pointer(Cursors.SizeNESW, 14)

If F2 And F4 Then Return New Pointer(Cursors.SizeNWSE, 17)

If F1 Then Return New Pointer(Cursors.SizeWE, 10)

If F2 Then Return New Pointer(Cursors.SizeWE, 11)

If F3 Then Return New Pointer(Cursors.SizeNS, 12)

If F4 Then Return New Pointer(Cursors.SizeNS, 15)

Return New Pointer(Cursors.Default, 0)

End Function

 

Private Current, Pending As Pointer

Private Sub SetCurrent()

Pending = GetPointer()

If Current.Position = Pending.Position Then Return

Current = GetPointer()

Cursor = Current.Cursor

End Sub

 

Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)

If _Resizable Then SetCurrent()

MyBase.OnMouseMove(e)

End Sub

 

Protected Header As Rectangle

Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)

If Width = 0 OrElse Height = 0 Then Return

Header = New Rectangle(7, 7, Width - 14, _MoveHeight - 7)

Invalidate()

MyBase.OnSizeChanged(e)

End Sub

 

#End Region

 

#Region " Convienence "

 

MustOverride Sub PaintHook()

Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)

If Width = 0 OrElse Height = 0 Then Return

G = e.Graphics

PaintHook()

End Sub

 

Private _TransparencyKey As Color

Property TransparencyKey() As Color

Get

Return _TransparencyKey

End Get

Set(ByVal v As Color)

_TransparencyKey = v

Invalidate()

End Set

End Property

 

Private _Image As Image

Property Image() As Image

Get

Return _Image

End Get

Set(ByVal value As Image)

_Image = value

Invalidate()

End Set

End Property

ReadOnly Property ImageWidth() As Integer

Get

If _Image Is Nothing Then Return 0

Return _Image.Width

End Get

End Property

 

Private _Size As Size

Private _Rectangle As Rectangle

Private _Gradient As LinearGradientBrush

Private _Brush As SolidBrush

 

Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)

_Brush = New SolidBrush©

G.FillRectangle(_Brush, rect.X, rect.Y, 1, 1)

G.FillRectangle(_Brush, rect.X + (rect.Width - 1), rect.Y, 1, 1)

G.FillRectangle(_Brush, rect.X, rect.Y + (rect.Height - 1), 1, 1)

G.FillRectangle(_Brush, rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), 1, 1)

End Sub

 

Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)

G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)

G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)

End Sub

 

Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer)

DrawText(a, c, x, 0)

End Sub

Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer, ByVal y As Integer)

If String.IsNullOrEmpty(Text) Then Return

_Size = G.MeasureString(Text, Font).ToSize

_Brush = New SolidBrush©

 

Select Case a

Case HorizontalAlignment.Left

G.DrawString(Text, Font, _Brush, x, _MoveHeight \ 2 - _Size.Height \ 2 + y)

Case HorizontalAlignment.Right

G.DrawString(Text, Font, _Brush, Width - _Size.Width - x, _MoveHeight \ 2 - _Size.Height \ 2 + y)

Case HorizontalAlignment.Center

G.DrawString(Text, Font, _Brush, Width \ 2 - _Size.Width \ 2 + x, _MoveHeight \ 2 - _Size.Height \ 2 + y)

End Select

End Sub

Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer, ByVal y As Integer, ByVal f As Font)

If String.IsNullOrEmpty(Text) Then Return

_Size = G.MeasureString(Text, Font).ToSize

_Brush = New SolidBrush©

 

Select Case a

Case HorizontalAlignment.Left

G.DrawString(Text, f, _Brush, x, _MoveHeight \ 2 - _Size.Height \ 2 + y)

Case HorizontalAlignment.Right

G.DrawString(Text, f, _Brush, Width - _Size.Width - x, _MoveHeight \ 2 - _Size.Height \ 2 + y)

Case HorizontalAlignment.Center

G.DrawString(Text, f, _Brush, Width \ 2 - _Size.Width \ 2 + x, _MoveHeight \ 2 - _Size.Height \ 2 + y)

End Select

End Sub

 

Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer)

DrawIcon(a, x, 0)

End Sub

Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)

If _Image Is Nothing Then Return

Select Case a

Case HorizontalAlignment.Left

G.DrawImage(_Image, x, _MoveHeight \ 2 - _Image.Height \ 2 + y)

Case HorizontalAlignment.Right

G.DrawImage(_Image, Width - _Image.Width - x, _MoveHeight \ 2 - _Image.Height \ 2 + y)

Case HorizontalAlignment.Center

G.DrawImage(_Image, Width \ 2 - _Image.Width \ 2, _MoveHeight \ 2 - _Image.Height \ 2)

End Select

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)

_Rectangle = New Rectangle(x, y, width, height)

_Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)

G.FillRectangle(_Gradient, _Rectangle)

End Sub

 

#End Region

 

End Class

MustInherit Class ThemeControl

Inherits Control

 

#Region " Initialization "

 

Protected G As Graphics, B As Bitmap

Sub New()

SetStyle(DirectCast(139270, ControlStyles), True)

B = New Bitmap(1, 1)

G = Graphics.FromImage( B)

End Sub

 

Sub AllowTransparent()

SetStyle(ControlStyles.Opaque, False)

SetStyle(ControlStyles.SupportsTransparentBackColor, True)

End Sub

 

Overrides Property Text As String

Get

Return MyBase.Text

End Get

Set(ByVal v As String)

MyBase.Text = v

Invalidate()

End Set

End Property

#End Region

 

#Region " Mouse Handling "

 

Protected Enum State As Byte

MouseNone = 0

MouseOver = 1

MouseDown = 2

End Enum

 

Protected MouseState As State

Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)

ChangeMouseState(State.MouseNone)

MyBase.OnMouseLeave(e)

End Sub

Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)

ChangeMouseState(State.MouseOver)

MyBase.OnMouseEnter(e)

End Sub

Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)

ChangeMouseState(State.MouseOver)

MyBase.OnMouseUp(e)

End Sub

Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)

If e.Button = MouseButtons.Left Then ChangeMouseState(State.MouseDown)

MyBase.OnMouseDown(e)

End Sub

 

Private Sub ChangeMouseState(ByVal e As State)

MouseState = e

Invalidate()

End Sub

 

#End Region

 

#Region " Convienence "

 

MustOverride Sub PaintHook()

Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)

If Width = 0 OrElse Height = 0 Then Return

PaintHook()

e.Graphics.DrawImage(B, 0, 0)

End Sub

 

Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)

If Not Width = 0 AndAlso Not Height = 0 Then

B = New Bitmap(Width, Height)

G = Graphics.FromImage( B)

Invalidate()

End If

MyBase.OnSizeChanged(e)

End Sub

 

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)

_Image = value

Invalidate()

End Set

End Property

ReadOnly Property ImageWidth() As Integer

Get

If _Image Is Nothing Then Return 0

Return _Image.Width

End Get

End Property

ReadOnly Property ImageTop() As Integer

Get

If _Image Is Nothing Then Return 0

Return Height \ 2 - _Image.Height \ 2

End Get

End Property

 

Private _Size As Size

Private _Rectangle As Rectangle

Private _Gradient As LinearGradientBrush

Private _Brush As SolidBrush

 

Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)

If _NoRounding Then Return

 

B.SetPixel(rect.X, rect.Y, c)

B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c)

B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c)

B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c)

End Sub

 

Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)

G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)

G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)

End Sub

 

Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer)

DrawText(a, c, x, 0)

End Sub

Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer, ByVal y As Integer)

If String.IsNullOrEmpty(Text) Then Return

_Size = G.MeasureString(Text, Font).ToSize

_Brush = New SolidBrush©

 

Select Case a

Case HorizontalAlignment.Left

G.DrawString(Text, Font, _Brush, x, Height \ 2 - _Size.Height \ 2 + y)

Case HorizontalAlignment.Right

G.DrawString(Text, Font, _Brush, Width - _Size.Width - x, Height \ 2 - _Size.Height \ 2 + y)

Case HorizontalAlignment.Center

G.DrawString(Text, Font, _Brush, Width \ 2 - _Size.Width \ 2 + x, Height \ 2 - _Size.Height \ 2 + y)

End Select

End Sub

 

Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer)

DrawIcon(a, x, 0)

End Sub

Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)

If _Image Is Nothing Then Return

Select Case a

Case HorizontalAlignment.Left

G.DrawImage(_Image, x, Height \ 2 - _Image.Height \ 2 + y)

Case HorizontalAlignment.Right

G.DrawImage(_Image, Width - _Image.Width - x, Height \ 2 - _Image.Height \ 2 + y)

Case HorizontalAlignment.Center

G.DrawImage(_Image, Width \ 2 - _Image.Width \ 2, Height \ 2 - _Image.Height \ 2)

End Select

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)

_Rectangle = New Rectangle(x, y, width, height)

_Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)

G.FillRectangle(_Gradient, _Rectangle)

End Sub

#End Region

 

End Class

MustInherit Class ThemeContainerControl

Inherits ContainerControl

 

#Region " Initialization "

 

Protected G As Graphics, B As Bitmap

Sub New()

SetStyle(DirectCast(139270, ControlStyles), True)

B = New Bitmap(1, 1)

G = Graphics.FromImage( B)

End Sub

 

Sub AllowTransparent()

SetStyle(ControlStyles.Opaque, False)

SetStyle(ControlStyles.SupportsTransparentBackColor, True)

End Sub

 

#End Region

 

#Region " Convienence "

 

MustOverride Sub PaintHook()

Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)

If Width = 0 OrElse Height = 0 Then Return

PaintHook()

e.Graphics.DrawImage(B, 0, 0)

End Sub

 

Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)

If Not Width = 0 AndAlso Not Height = 0 Then

B = New Bitmap(Width, Height)

G = Graphics.FromImage( B)

Invalidate()

End If

MyBase.OnSizeChanged(e)

End Sub

 

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 _Rectangle As Rectangle

Private _Gradient As LinearGradientBrush

 

Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)

If _NoRounding Then Return

B.SetPixel(rect.X, rect.Y, c)

B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c)

B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c)

B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c)

End Sub

 

Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)

G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)

G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)

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)

_Rectangle = New Rectangle(x, y, width, height)

_Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)

G.FillRectangle(_Gradient, _Rectangle)

End Sub

#End Region

 

End Class

 

Class AdobeTheme

Inherits Theme

Enum TextAlign As Integer

Left = 0

Center = 1

Right = 2

End Enum

 

Private TA As TextAlign

Public Property TextAlignment() As TextAlign

Get

Return TA

End Get

Set(ByVal value As TextAlign)

TA = value

Invalidate()

End Set

End Property

 

 

Sub New()

MoveHeight = 19

TransparencyKey = Color.Fuchsia

Me.Resizable = False

BackColor = Color.FromArgb(51, 51, 51)

Me.Font = New Font("Microsoft Sans Serif", 9, FontStyle.Bold)

Me.TextAlignment = Left

End Sub

 

Public Overrides Sub PaintHook()

G.Clear(Color.FromArgb(68, 68, 68))

DrawGradient(Color.FromArgb(51, 51, 51), Color.FromArgb(51, 51, 51), 0, 0, Width, 37, 45S)

G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(31, 31, 31))), 0, 37, Width, 37)

G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(60, 60, 60))), 0, 38, Width, 38)

G.FillRectangle(New SolidBrush(Color.FromArgb(68, 68, 68)), 1, 39, Width - 2, Height - 39 - 2)

Select Case TA

Case 0

DrawText(HorizontalAlignment.Left, Color.FromArgb(120, Color.Black), 12, 18, New Font("Microsoft Sans Serif", 10, FontStyle.Bold))

DrawText(HorizontalAlignment.Left, Color.White, 10, 16, New Font("Microsoft Sans Serif", 10, FontStyle.Bold))

Case 1

DrawText(HorizontalAlignment.Center, Color.FromArgb(120, Color.Black), -1, 18, New Font("Microsoft Sans Serif", 10, FontStyle.Bold))

DrawText(HorizontalAlignment.Center, Color.White, 1, 16, New Font("Microsoft Sans Serif", 10, FontStyle.Bold))

Case 2

DrawText(HorizontalAlignment.Right, Color.FromArgb(120, Color.Black), -1 + CInt(G.MeasureString(Text, Font).Width / 6), 18, New Font("Microsoft Sans Serif", 10, FontStyle.Bold))

DrawText(HorizontalAlignment.Right, Color.White, 1 + CInt(G.MeasureString(Text, Font).Width / 6), 16, New Font("Microsoft Sans Serif", 10, FontStyle.Bold))

End Select

 

G.FillRectangle(New SolidBrush(Color.FromArgb(51, 51, 51)), 1, Height - 37, Width - 2, Height - 2)

G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(31, 31, 31))), 0, Height - 37, Width, Height - 37)

G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(60, 60, 60))), 0, Height - 38, Width, Height - 38)

 

DrawBorders(Pens.Black, Pens.Gray, ClientRectangle)

DrawCorners(Color.Fuchsia, ClientRectangle)

End Sub

End Class

 

Class AdobeButton

Inherits ThemeControl

 

#Region " Properties "

 

Private _Orange As Boolean

Public Property Orange() As Boolean

Get

Return _Orange

End Get

Set(ByVal value As Boolean)

_Orange = value

Invalidate()

End Set

End Property

 

#End Region

 

Sub New()

BackColor = Color.FromArgb(51, 51, 51)

End Sub

 

Overrides Sub PaintHook()

G.Clear(Color.FromArgb(102, 102, 102))

Dim gC As Integer = 15

Dim _text As Color = Color.White

Dim C1, C2, C3, C4 As Color

 

Select Case _Orange

Case True

C1 = Color.FromArgb(255, 209, 51)

C2 = Color.FromArgb(255, 165, 13)

C3 = Color.FromArgb(255, 195, 13)

C4 = Color.FromArgb(255, 163, 0)

_text = Color.White

Case False

C1 = Color.FromArgb(105, 105, 105)

C2 = Color.FromArgb(56, 56, 56)

C3 = Color.FromArgb(73, 73, 73)

C4 = Color.FromArgb(48, 48, 48)

End Select

 

DrawGradient(C1, C2, 0, 0, Width, Height, 90S)

DrawGradient(C3, C4, 1, 1, Width - 2, Height - 2, 90S)

 

Select Case MouseState

Case State.MouseNone

'NULL

Case State.MouseOver

Select Case _Orange

Case True

_text = Color.Black

End Select

gC = 10

Case State.MouseDown

Select Case _Orange

Case True

_text = Color.White

End Select

gC = 5

End Select

 

For i = 1 To 5

G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(Int(255 / ((i * gC))), Color.Black))), New Rectangle(i, i, Width - 1 - (i * 2), Height - 1 - (i * 2)))

Next

 

DrawBorders(Pens.Black, Pens.Transparent, ClientRectangle)

DrawText(HorizontalAlignment.Center, _text, -2, 0)

End Sub

End Class

 

Class AdobeCheck

Inherits ThemeControl

 

#Region " Properties "

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

#End Region

 

Sub New()

'Default properties

Size = New Size(90, 15)

MinimumSize = New Size(16, 16)

MaximumSize = New Size(600, 16)

CheckedState = False

End Sub

 

Public Overrides Sub PaintHook()

G.Clear(Color.FromArgb(68, 68, 68))

 

Select Case CheckedState

Case True

'Fill with blue

DrawGradient(Color.FromArgb(62, 62, 62), Color.FromArgb(38, 38, 38), 0, 0, 15, 15, 90S)

DrawGradient(Color.FromArgb(132, 192, 240), Color.FromArgb(78, 123, 168), 3, 3, 9, 9, 90S)

DrawGradient(Color.FromArgb(98, 159, 220), Color.FromArgb(62, 102, 147), 4, 4, 7, 7, 90S)

Case False

'Fill with gray

DrawGradient(Color.FromArgb(80, 80, 80), Color.FromArgb(60, 60, 60), 0, 0, 15, 15, 90S)

End Select

 

'Draw Box (After Fill so no overflow)

DrawBorders(Pens.Black, Pens.DimGray, New Rectangle(0, 0, 15, 15))

 

'Draw Shadow

DrawText(HorizontalAlignment.Left, Color.Black, 18, 1)

 

'Draw Text

DrawText(HorizontalAlignment.Left, Color.White, 17, 0)

End Sub

 

Sub changeCheck() Handles Me.Click

Select Case CheckedState

Case True

CheckedState = False

Case False

CheckedState = True

End Select

End Sub

End Class

 

Class AdobeProgressBar

Inherits ThemeControl

Private _Maximum As Integer

Public Property Maximum() As Integer

Get

Return _Maximum

End Get

Set(ByVal v As Integer)

Select Case v

Case Is < _Value

_Value = v

End Select

_Maximum = v

Invalidate()

End Set

End Property

Private _Value As Integer

Public Property Value() As Integer

Get

Return _Value

End Get

Set(ByVal v As Integer)

Select Case v

Case Is > _Maximum

v = _Maximum

End Select

_Value = v

Invalidate()

End Set

End Property

Overrides Sub PaintHook()

G.Clear(Color.FromArgb(51, 51, 51))

'Fill

Select Case _Value

Case Is > 6

DrawGradient(Color.FromArgb(132, 192, 240), Color.FromArgb(78, 123, 168), 3, 3, CInt(_Value / _Maximum * Width) - 6, Height - 6, 90S)

DrawGradient(Color.FromArgb(98, 159, 220), Color.FromArgb(62, 102, 147), 4, 4, CInt(_Value / _Maximum * Width) - 8, Height - 8, 90S)

Case Is > 1

DrawGradient(Color.FromArgb(132, 192, 240), Color.FromArgb(78, 123, 168), 3, 3, CInt(_Value / _Maximum * Width), Height - 6, 90S)

DrawGradient(Color.FromArgb(98, 159, 220), Color.FromArgb(62, 102, 147), 4, 4, CInt(_Value / _Maximum * Width) - 2, Height - 8, 90S)

End Select

 

'Borders

G.DrawRectangle(Pens.Black, 0, 0, Width - 1, Height - 1)

G.DrawRectangle(Pens.Gray, 1, 1, Width - 3, Height - 3)

End Sub

Public Sub Increment(ByVal Amount As Integer)

If Me.Value + Amount > Maximum Then

Me.Value = Maximum

Else

Me.Value += Amount

End If

End Sub

End Class</pre>

 

To możesz przepisać to do C# lub załączyć jak bibliotekę do projektu.

Opublikowano

Daj kod.

 

 

Łap, to jest jeden z tych co wyżej:

 

abstract class Theme : ContainerControl
{

    #region " Initialization "

    protected Bitmap B;
    protected Graphics G;
    public Theme()
    {
        SetStyle((ControlStyles)8198, true);
        B = new Bitmap(1, 1);
        G = Graphics.FromImage(;
    }

    private bool ParentIsForm;
    protected override void OnHandleCreated(EventArgs e)
    {
        Dock = DockStyle.Fill;
        ParentIsForm = Parent is Form;
        if (ParentIsForm)
            ParentForm.FormBorderStyle = FormBorderStyle.None;
        base.OnHandleCreated(e);
    }

    #endregion

    #region " Sizing and Movement "

    private bool _Resizable = true;
    public bool Resizable
    {
        get { return _Resizable; }
        set { _Resizable = value; }
    }

    private int _MoveHeight = 24;
    public int MoveHeight
    {
        get { return _MoveHeight; }
        set
        {
            _MoveHeight = value;
            Header = new Rectangle(7, 7, Width - 14, _MoveHeight);
        }
    }

    private IntPtr Flag;
    protected override void OnMouseDown(MouseEventArgs e)
    {
        if (!(e.Button == MouseButtons.Left))
            return;
        if (ParentIsForm)
            if (ParentForm.WindowState == FormWindowState.Maximized)
                return;

        if (Header.Contains(e.Location))
        {
            Flag = new IntPtr(2);
        }
        else if (Current.Position == 0 | !_Resizable)
        {
            return;
        }
        else
        {
            Flag = new IntPtr(Current.Position);
        }

        Capture = false;
        Message msg = Message.Create(Parent.Handle, 161, Flag, IntPtr.Zero);
        DefWndProc(ref msg);

        base.OnMouseDown(e);
    }

    private struct Pointer
    {
        public readonly Cursor Cursor;
        public readonly byte Position;
        public Pointer(Cursor c, byte p)
        {
            Cursor = c;
            Position = p;
        }
    }

    private bool F1;
    private bool F2;
    private bool F3;
    private bool F4;
    private Point PTC;
    private Pointer GetPointer()
    {
        PTC = PointToClient(MousePosition);
        F1 = PTC.X < 7;
        F2 = PTC.X > Width - 7;
        F3 = PTC.Y < 7;
        F4 = PTC.Y > Height - 7;

        if (F1 & F3)
            return new Pointer(Cursors.SizeNWSE, 13);
        if (F1 & F4)
            return new Pointer(Cursors.SizeNESW, 16);
        if (F2 & F3)
            return new Pointer(Cursors.SizeNESW, 14);
        if (F2 & F4)
            return new Pointer(Cursors.SizeNWSE, 17);
        if (F1)
            return new Pointer(Cursors.SizeWE, 10);
        if (F2)
            return new Pointer(Cursors.SizeWE, 11);
        if (F3)
            return new Pointer(Cursors.SizeNS, 12);
        if (F4)
            return new Pointer(Cursors.SizeNS, 15);
        return new Pointer(Cursors.Default, 0);
    }

    private Pointer Current;
    private Pointer Pending;
    private void SetCurrent()
    {
        Pending = GetPointer();
        if (Current.Position == Pending.Position)
            return;
        Current = GetPointer();
        Cursor = Current.Cursor;
    }

    protected override void OnMouseMove(MouseEventArgs e)
    {
        if (_Resizable)
            SetCurrent();
        base.OnMouseMove(e);
    }

    protected Rectangle Header;
    protected override void OnSizeChanged(EventArgs e)
    {
        Header = new Rectangle(7, 7, Width - 14, _MoveHeight);
        G.Dispose();
        B.Dispose();
        B = new Bitmap(Width, Height);
        G = Graphics.FromImage(;
        Invalidate();
        base.OnSizeChanged(e);
    }

    #endregion

    #region " Convienence "

    public void SetTransparent(Color c)
    {
        if (ParentIsForm)
            ParentForm.TransparencyKey = c;
    }

    protected override abstract void OnPaint(PaintEventArgs e);

    public void DrawCorners(Color c, Rectangle rect)
    {
        B.SetPixel(rect.X, rect.Y, c);
        B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c);
        B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c);
        B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c);
    }

    public void DrawBorders(Pen p1, Pen p2, Rectangle rect)
    {
        G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1);
        G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3);
    }

    private Size TextSize;
    public void DrawText(HorizontalAlignment a, Brush b, int offset = 0)
    {
        if (string.IsNullOrEmpty(Text))
            return;
        TextSize = G.MeasureString(Text, Font).ToSize();

        switch (a)
        {
            case HorizontalAlignment.Left:
                G.DrawString(Text, Font, b, 5 + offset, _MoveHeight / 2 - TextSize.Height / 2 + 7);
                break;
            case HorizontalAlignment.Right:
                G.DrawString(Text, Font, b, Width - 5 - TextSize.Width - offset, _MoveHeight / 2 - TextSize.Height / 2 + 7);
                break;
            case HorizontalAlignment.Center:
                G.DrawString(Text, Font, b, Width / 2 - TextSize.Width / 2, _MoveHeight / 2 - TextSize.Height / 2 + 7);
                break;
        }
    }

    public int ImageWidth
    {
        get
        {
            if (_Image == null)
                return 0;
            return _Image.Width;
        }
    }

    private Image _Image;
    public Image Image
    {
        get { return _Image; }
        set
        {
            _Image = value;
            Invalidate();
        }
    }

    public void DrawIcon(HorizontalAlignment a, int offset = 0)
    {
        if (_Image == null)
            return;
        switch (a)
        {
            case HorizontalAlignment.Left:
                G.DrawImage(_Image, 5 + offset, _MoveHeight / 2 - _Image.Height / 2 + 7);
                break;
            case HorizontalAlignment.Right:
                G.DrawImage(_Image, Width - 5 - TextSize.Width - offset, _MoveHeight / 2 - TextSize.Height / 2 + 7);
                break;
            case HorizontalAlignment.Center:
                G.DrawImage(_Image, Width / 2 - TextSize.Width / 2, _MoveHeight / 2 - TextSize.Height / 2 + 7);
                break;
        }
    }
    #endregion

}
abstract class ThemeControl : Control
{

    #region " Initialization "

    protected Bitmap B;
    protected Graphics G;
    public ThemeControl()
    {
        SetStyle((ControlStyles)8198, true);
        B = new Bitmap(1, 1);
        G = Graphics.FromImage(;
    }

    public void AllowTransparent()
    {
        SetStyle(ControlStyles.Opaque, false);
        SetStyle((ControlStyles)141314, true);
    }

    #endregion

    #region " Mouse Handling "

    public enum State : byte
    {
        MouseNone = 0,
        MouseOver = 1,
        MouseDown = 2
    }

    protected State MouseState;
    protected override void OnMouseLeave(EventArgs e)
    {
        ChangeMouseState(State.MouseNone);
        base.OnMouseLeave(e);
    }
    protected override void OnMouseEnter(EventArgs e)
    {
        ChangeMouseState(State.MouseOver);
        base.OnMouseEnter(e);
    }
    protected override void OnMouseUp(MouseEventArgs e)
    {
        ChangeMouseState(State.MouseOver);
        base.OnMouseUp(e);
    }
    protected override void OnMouseDown(MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Left)
            ChangeMouseState(State.MouseDown);
        base.OnMouseDown(e);
    }

    private void ChangeMouseState(State e)
    {
        MouseState = e;
        Invalidate();
    }

    #endregion

    #region " Sizing "

    protected override void OnSizeChanged(EventArgs e)
    {
        G.Dispose();
        B.Dispose();
        B = new Bitmap(Width, Height);
        G = Graphics.FromImage(;
        Invalidate();
        base.OnSizeChanged(e);
    }

    #endregion

    #region " Convienence "

    protected override abstract void OnPaint(PaintEventArgs e);

    public void DrawCorners(Color c, Rectangle rect)
    {
        B.SetPixel(rect.X, rect.Y, c);
        B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c);
        B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c);
        B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c);
    }

    public void DrawBorders(Pen p1, Pen p2, Rectangle rect)
    {
        G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1);
        G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3);
    }

    private Size TextSize;
    public void DrawText(HorizontalAlignment a, Brush b, int offset = 0)
    {
        if (string.IsNullOrEmpty(Text))
            return;
        TextSize = G.MeasureString(Text, Font).ToSize();

        switch (a)
        {
            case HorizontalAlignment.Left:
                G.DrawString(Text, Font, b, 5 + offset, Height / 2 - TextSize.Height / 2);
                break;
            case HorizontalAlignment.Right:
                G.DrawString(Text, Font, b, Width - 5 - TextSize.Width - offset, Height / 2 - TextSize.Height / 2);
                break;
            case HorizontalAlignment.Center:
                G.DrawString(Text, Font, b, Width / 2 - TextSize.Width / 2, Height / 2 - TextSize.Height / 2);
                break;
        }
    }

    public int ImageWidth
    {
        get
        {
            if (_Image == null)
                return 0;
            return _Image.Width;
        }
    }

    private Image _Image;
    public Image Image
    {
        get { return _Image; }
        set
        {
            _Image = value;
            Invalidate();
        }
    }

    public void DrawIcon(HorizontalAlignment a, int offset = 0)
    {
        if (_Image == null)
            return;
        switch (a)
        {
            case HorizontalAlignment.Left:
                G.DrawImage(_Image, Width / 10 + offset, Height / 2 - _Image.Height / 2);
                break;
            case HorizontalAlignment.Right:
                G.DrawImage(_Image, Width - (Width / 10) - TextSize.Width - offset, Height / 2 - TextSize.Height / 2);
                break;
            case HorizontalAlignment.Center:
                G.DrawImage(_Image, Width / 2 - TextSize.Width / 2, Height / 2 - TextSize.Height / 2);
                break;
        }
    }

    #endregion

}

class GTheme : Theme
{

    public GTheme()
    {
        MoveHeight = 28;
        ForeColor = Color.FromArgb(100, 100, 100);
        SetTransparent(Color.Fuchsia);

        C1 = Color.FromArgb(41, 41, 41);
        C2 = Color.FromArgb(25, 25, 25);

        P1 = new Pen(Color.FromArgb(58, 58, 58));
        P2 = new Pen(C2);
    }

    private Color C1;
    private Color C2;
    private Pen P1;
    private Pen P2;
    private LinearGradientBrush B1;

    private Rectangle R1;
    protected override void OnPaint(PaintEventArgs e)
    {
        G.Clear(C1);

        R1 = new Rectangle(0, 0, Width, 28);
        B1 = new LinearGradientBrush(R1, C2, C1, LinearGradientMode.Vertical);
        G.FillRectangle(B1, R1);

        G.DrawLine(P2, 0, 28, Width, 28);
        G.DrawLine(P1, 0, 29, Width, 29);

        DrawText(HorizontalAlignment.Left, new SolidBrush(ForeColor), ImageWidth);
        DrawIcon(HorizontalAlignment.Left);

        DrawBorders(Pens.Black, P1, ClientRectangle);
        DrawCorners(Color.Fuchsia, ClientRectangle);

        e.Graphics.DrawImage(B, 0, 0);
    }
}
class GButton : ThemeControl
{

    private Pen P1;
    private Pen P2;
    private LinearGradientBrush B1;
    private Color C1;
    private Color C2;

    private Rectangle R1;
    public GButton()
    {
        AllowTransparent();
        BackColor = Color.FromArgb(41, 41, 41);
        ForeColor = Color.FromArgb(100, 100, 100);

        P1 = new Pen(Color.FromArgb(25, 25, 25));
        P2 = new Pen(Color.FromArgb(11, Color.White));

        C1 = Color.FromArgb(41, 41, 41);
        C2 = Color.FromArgb(51, 51, 51);
    }

    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        if (MouseState == State.MouseDown)
        {
            B1 = new LinearGradientBrush(ClientRectangle, C1, C2, LinearGradientMode.Vertical);
        }
        else
        {
            B1 = new LinearGradientBrush(ClientRectangle, C2, C1, LinearGradientMode.Vertical);
        }

        G.FillRectangle(B1, ClientRectangle);

        DrawText(HorizontalAlignment.Center, new SolidBrush(ForeColor));
        DrawIcon(HorizontalAlignment.Left);

        DrawBorders(P1, P2, ClientRectangle);
        DrawCorners(BackColor, ClientRectangle);

        e.Graphics.DrawImage(B, 0, 0);
    }
}
class Seperator : ThemeControl
{

    public Seperator()
    {
        AllowTransparent();
        BackColor = Color.Transparent;
    }

    private Orientation _Direction;
    public Orientation Direction
    {
        get { return _Direction; }
        set
        {
            _Direction = value;
            Invalidate();
        }
    }

    private Color _Color1 = Color.FromArgb(90, Color.Black);
    public Color Color1
    {
        get { return _Color1; }
        set
        {
            _Color1 = value;
            Invalidate();
        }
    }

    private Color _Color2 = Color.FromArgb(14, Color.White);
    public Color Color2
    {
        get { return _Color2; }
        set
        {
            _Color2 = value;
            Invalidate();
        }
    }

    private Rectangle R1;
    private LinearGradientBrush B1;

    private int Rotation;
    protected override void OnPaint(PaintEventArgs e)
    {
        G.Clear(BackColor);

        if (_Direction == Orientation.Horizontal)
        {
            G.DrawLine(new Pen(_Color1), 0, Height / 2, Width, Height / 2);
            G.DrawLine(new Pen(_Color2), 0, Height / 2 + 1, Width, Height / 2 + 1);
        }
        else
        {
            G.DrawLine(new Pen(_Color1), Width / 2, 0, Width / 2, Height);
            G.DrawLine(new Pen(_Color2), Width / 2 + 1, 0, Width / 2 + 1, Height);
        }

        e.Graphics.DrawImage(B, 0, 0);
    }
}

apple.png

Opublikowano

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace Style.MojaAplikacja
{
    abstract class Theme : ContainerControl
    {

        #region " Initialization "

        protected Bitmap B;
        protected Graphics G;
        public Theme()
        {
            SetStyle((ControlStyles)8198, true);
            B = new Bitmap(1, 1);
            G = Graphics.FromImage(;
        }

        private bool ParentIsForm;
        protected override void OnHandleCreated(EventArgs e)
        {
            Dock = DockStyle.Fill;
            ParentIsForm = Parent is Form;
            if (ParentIsForm)
                ParentForm.FormBorderStyle = FormBorderStyle.None;
            base.OnHandleCreated(e);
        }

        #endregion

        #region " Sizing and Movement "

        private bool _Resizable = true;
        public bool Resizable
        {
            get { return _Resizable; }
            set { _Resizable = value; }
        }

        private int _MoveHeight = 24;
        public int MoveHeight
        {
            get { return _MoveHeight; }
            set
            {
                _MoveHeight = value;
                Header = new Rectangle(7, 7, Width - 14, _MoveHeight);
            }
        }

        private IntPtr Flag;
        protected override void OnMouseDown(MouseEventArgs e)
        {
            if (!(e.Button == MouseButtons.Left))
                return;
            if (ParentIsForm)
                if (ParentForm.WindowState == FormWindowState.Maximized)
                    return;

            if (Header.Contains(e.Location))
            {
                Flag = new IntPtr(2);
            }
            else if (Current.Position == 0 | !_Resizable)
            {
                return;
            }
            else
            {
                Flag = new IntPtr(Current.Position);
            }

            Capture = false;
            Message msg = Message.Create(Parent.Handle, 161, Flag, IntPtr.Zero);
            DefWndProc(ref msg);

            base.OnMouseDown(e);
        }

        private struct Pointer
        {
            public readonly Cursor Cursor;
            public readonly byte Position;
            public Pointer(Cursor c, byte p)
            {
                Cursor = c;
                Position = p;
            }
        }

        private bool F1;
        private bool F2;
        private bool F3;
        private bool F4;
        private Point PTC;
        private Pointer GetPointer()
        {
            PTC = PointToClient(MousePosition);
            F1 = PTC.X < 7;
            F2 = PTC.X > Width - 7;
            F3 = PTC.Y < 7;
            F4 = PTC.Y > Height - 7;

            if (F1 & F3)
                return new Pointer(Cursors.SizeNWSE, 13);
            if (F1 & F4)
                return new Pointer(Cursors.SizeNESW, 16);
            if (F2 & F3)
                return new Pointer(Cursors.SizeNESW, 14);
            if (F2 & F4)
                return new Pointer(Cursors.SizeNWSE, 17);
            if (F1)
                return new Pointer(Cursors.SizeWE, 10);
            if (F2)
                return new Pointer(Cursors.SizeWE, 11);
            if (F3)
                return new Pointer(Cursors.SizeNS, 12);
            if (F4)
                return new Pointer(Cursors.SizeNS, 15);
            return new Pointer(Cursors.Default, 0);
        }

        private Pointer Current;
        private Pointer Pending;
        private void SetCurrent()
        {
            Pending = GetPointer();
            if (Current.Position == Pending.Position)
                return;
            Current = GetPointer();
            Cursor = Current.Cursor;
        }

        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (_Resizable)
                SetCurrent();
            base.OnMouseMove(e);
        }

        protected Rectangle Header;
        protected override void OnSizeChanged(EventArgs e)
        {
            Header = new Rectangle(7, 7, Width - 14, _MoveHeight);
            G.Dispose();
            B.Dispose();
            B = new Bitmap(Width, Height);
            G = Graphics.FromImage(;
            Invalidate();
            base.OnSizeChanged(e);
        }

        #endregion

        #region " Convienence "

        public void SetTransparent(Color c)
        {
            if (ParentIsForm)
                ParentForm.TransparencyKey = c;
        }

        protected override abstract void OnPaint(PaintEventArgs e);

        public void DrawCorners(Color c, Rectangle rect)
        {
            B.SetPixel(rect.X, rect.Y, c);
            B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c);
            B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c);
            B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c);
        }

        public void DrawBorders(Pen p1, Pen p2, Rectangle rect)
        {
            G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1);
            G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3);
        }

        private Size TextSize;
        public void DrawText(HorizontalAlignment a, Brush b, int offset = 0)
        {
            if (string.IsNullOrEmpty(Text))
                return;
            TextSize = G.MeasureString(Text, Font).ToSize();

            switch (a)
            {
                case HorizontalAlignment.Left:
                    G.DrawString(Text, Font, b, 5 + offset, _MoveHeight / 2 - TextSize.Height / 2 + 7);
                    break;
                case HorizontalAlignment.Right:
                    G.DrawString(Text, Font, b, Width - 5 - TextSize.Width - offset, _MoveHeight / 2 - TextSize.Height / 2 + 7);
                    break;
                case HorizontalAlignment.Center:
                    G.DrawString(Text, Font, b, Width / 2 - TextSize.Width / 2, _MoveHeight / 2 - TextSize.Height / 2 + 7);
                    break;
            }
        }

        public int ImageWidth
        {
            get
            {
                if (_Image == null)
                    return 0;
                return _Image.Width;
            }
        }

        private Image _Image;
        public Image Image
        {
            get { return _Image; }
            set
            {
                _Image = value;
                Invalidate();
            }
        }

        public void DrawIcon(HorizontalAlignment a, int offset = 0)
        {
            if (_Image == null)
                return;
            switch (a)
            {
                case HorizontalAlignment.Left:
                    G.DrawImage(_Image, 5 + offset, _MoveHeight / 2 - _Image.Height / 2 + 7);
                    break;
                case HorizontalAlignment.Right:
                    G.DrawImage(_Image, Width - 5 - TextSize.Width - offset, _MoveHeight / 2 - TextSize.Height / 2 + 7);
                    break;
                case HorizontalAlignment.Center:
                    G.DrawImage(_Image, Width / 2 - TextSize.Width / 2, _MoveHeight / 2 - TextSize.Height / 2 + 7);
                    break;
            }
        }
        #endregion

    }
    abstract class ThemeControl : Control
    {

        #region " Initialization "

        protected Bitmap B;
        protected Graphics G;
        public ThemeControl()
        {
            SetStyle((ControlStyles)8198, true);
            B = new Bitmap(1, 1);
            G = Graphics.FromImage(;
        }

        public void AllowTransparent()
        {
            SetStyle(ControlStyles.Opaque, false);
            SetStyle((ControlStyles)141314, true);
        }

        #endregion

        #region " Mouse Handling "

        public enum State : byte
        {
            MouseNone = 0,
            MouseOver = 1,
            MouseDown = 2
        }

        protected State MouseState;
        protected override void OnMouseLeave(EventArgs e)
        {
            ChangeMouseState(State.MouseNone);
            base.OnMouseLeave(e);
        }
        protected override void OnMouseEnter(EventArgs e)
        {
            ChangeMouseState(State.MouseOver);
            base.OnMouseEnter(e);
        }
        protected override void OnMouseUp(MouseEventArgs e)
        {
            ChangeMouseState(State.MouseOver);
            base.OnMouseUp(e);
        }
        protected override void OnMouseDown(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
                ChangeMouseState(State.MouseDown);
            base.OnMouseDown(e);
        }

        private void ChangeMouseState(State e)
        {
            MouseState = e;
            Invalidate();
        }

        #endregion

        #region " Sizing "

        protected override void OnSizeChanged(EventArgs e)
        {
            G.Dispose();
            B.Dispose();
            B = new Bitmap(Width, Height);
            G = Graphics.FromImage(;
            Invalidate();
            base.OnSizeChanged(e);
        }

        #endregion

        #region " Convienence "

        protected override abstract void OnPaint(PaintEventArgs e);

        public void DrawCorners(Color c, Rectangle rect)
        {
            B.SetPixel(rect.X, rect.Y, c);
            B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c);
            B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c);
            B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c);
        }

        public void DrawBorders(Pen p1, Pen p2, Rectangle rect)
        {
            G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1);
            G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3);
        }

        private Size TextSize;
        public void DrawText(HorizontalAlignment a, Brush b, int offset = 0)
        {
            if (string.IsNullOrEmpty(Text))
                return;
            TextSize = G.MeasureString(Text, Font).ToSize();

            switch (a)
            {
                case HorizontalAlignment.Left:
                    G.DrawString(Text, Font, b, 5 + offset, Height / 2 - TextSize.Height / 2);
                    break;
                case HorizontalAlignment.Right:
                    G.DrawString(Text, Font, b, Width - 5 - TextSize.Width - offset, Height / 2 - TextSize.Height / 2);
                    break;
                case HorizontalAlignment.Center:
                    G.DrawString(Text, Font, b, Width / 2 - TextSize.Width / 2, Height / 2 - TextSize.Height / 2);
                    break;
            }
        }

        public int ImageWidth
        {
            get
            {
                if (_Image == null)
                    return 0;
                return _Image.Width;
            }
        }

        private Image _Image;
        public Image Image
        {
            get { return _Image; }
            set
            {
                _Image = value;
                Invalidate();
            }
        }

        public void DrawIcon(HorizontalAlignment a, int offset = 0)
        {
            if (_Image == null)
                return;
            switch (a)
            {
                case HorizontalAlignment.Left:
                    G.DrawImage(_Image, Width / 10 + offset, Height / 2 - _Image.Height / 2);
                    break;
                case HorizontalAlignment.Right:
                    G.DrawImage(_Image, Width - (Width / 10) - TextSize.Width - offset, Height / 2 - TextSize.Height / 2);
                    break;
                case HorizontalAlignment.Center:
                    G.DrawImage(_Image, Width / 2 - TextSize.Width / 2, Height / 2 - TextSize.Height / 2);
                    break;
            }
        }

        #endregion

    }

    class GTheme : Theme
    {

        public GTheme()
        {
            MoveHeight = 28;
            ForeColor = Color.FromArgb(100, 100, 100);
            SetTransparent(Color.Fuchsia);

            C1 = Color.FromArgb(41, 41, 41);
            C2 = Color.FromArgb(25, 25, 25);

            P1 = new Pen(Color.FromArgb(58, 58, 58));
            P2 = new Pen(C2);
        }

        private Color C1;
        private Color C2;
        private Pen P1;
        private Pen P2;
        private LinearGradientBrush B1;

        private Rectangle R1;
        protected override void OnPaint(PaintEventArgs e)
        {
            G.Clear(C1);

            R1 = new Rectangle(0, 0, Width, 28);
            B1 = new LinearGradientBrush(R1, C2, C1, LinearGradientMode.Vertical);
            G.FillRectangle(B1, R1);

            G.DrawLine(P2, 0, 28, Width, 28);
            G.DrawLine(P1, 0, 29, Width, 29);

            DrawText(HorizontalAlignment.Left, new SolidBrush(ForeColor), ImageWidth);
            DrawIcon(HorizontalAlignment.Left);

            DrawBorders(Pens.Black, P1, ClientRectangle);
            DrawCorners(Color.Fuchsia, ClientRectangle);

            e.Graphics.DrawImage(B, 0, 0);
        }
    }
    class GButton : ThemeControl
    {

        private Pen P1;
        private Pen P2;
        private LinearGradientBrush B1;
        private Color C1;
        private Color C2;

        private Rectangle R1;
        public GButton()
        {
            AllowTransparent();
            BackColor = Color.FromArgb(41, 41, 41);
            ForeColor = Color.FromArgb(100, 100, 100);

            P1 = new Pen(Color.FromArgb(25, 25, 25));
            P2 = new Pen(Color.FromArgb(11, Color.White));

            C1 = Color.FromArgb(41, 41, 41);
            C2 = Color.FromArgb(51, 51, 51);
        }

        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            if (MouseState == State.MouseDown)
            {
                B1 = new LinearGradientBrush(ClientRectangle, C1, C2, LinearGradientMode.Vertical);
            }
            else
            {
                B1 = new LinearGradientBrush(ClientRectangle, C2, C1, LinearGradientMode.Vertical);
            }

            G.FillRectangle(B1, ClientRectangle);

            DrawText(HorizontalAlignment.Center, new SolidBrush(ForeColor));
            DrawIcon(HorizontalAlignment.Left);

            DrawBorders(P1, P2, ClientRectangle);
            DrawCorners(BackColor, ClientRectangle);

            e.Graphics.DrawImage(B, 0, 0);
        }
    }
    class Seperator : ThemeControl
    {

        public Seperator()
        {
            AllowTransparent();
            BackColor = Color.Transparent;
        }

        private Orientation _Direction;
        public Orientation Direction
        {
            get { return _Direction; }
            set
            {
                _Direction = value;
                Invalidate();
            }
        }

        private Color _Color1 = Color.FromArgb(90, Color.Black);
        public Color Color1
        {
            get { return _Color1; }
            set
            {
                _Color1 = value;
                Invalidate();
            }
        }

        private Color _Color2 = Color.FromArgb(14, Color.White);
        public Color Color2
        {
            get { return _Color2; }
            set
            {
                _Color2 = value;
                Invalidate();
            }
        }

        private Rectangle R1;
        private LinearGradientBrush B1;

        private int Rotation;
        protected override void OnPaint(PaintEventArgs e)
        {
            G.Clear(BackColor);

            if (_Direction == Orientation.Horizontal)
            {
                G.DrawLine(new Pen(_Color1), 0, Height / 2, Width, Height / 2);
                G.DrawLine(new Pen(_Color2), 0, Height / 2 + 1, Width, Height / 2 + 1);
            }
            else
            {
                G.DrawLine(new Pen(_Color1), Width / 2, 0, Width / 2, Height);
                G.DrawLine(new Pen(_Color2), Width / 2 + 1, 0, Width / 2 + 1, Height);
            }

            e.Graphics.DrawImage(B, 0, 0);
        }
    }
}

 

Kompiluje się bez problemu.

Opublikowano

o.O Faktycznie, boże nie wiem co ja porobiłem wcześniej :mellow: Masz może jeszcze jakieś style lub strony gdzie je znajdę? ;)

apple.png

Opublikowano

o.O Faktycznie, boże nie wiem co ja porobiłem wcześniej :mellow: Masz może jeszcze jakieś style lub strony gdzie je znajdę? ;)

Cóż, takie coś w Windows Forms mija się z celem. Ta technologia ma swoje lata, a jeżeli chcesz tworzyć ładnie wyglądające aplikacje zainteresuj się Windows Presentation Foundation.
Opublikowano

Cóż, takie coś w Windows Forms mija się z celem. Ta technologia ma swoje lata, a jeżeli chcesz tworzyć ładnie wyglądające aplikacje zainteresuj się Windows Presentation Foundation.

 

Wczoraj czytałem sporo o tym, nie ukrywam - jestem początkujący i nie wiem jak się do tego zabrać :mellow:

apple.png

Opublikowano

Z tego co wiem to mało kto wiedział jak się do tego zabrać po odpaleniu wpf.

Po prostu baw się i eksperymentuj a sklecisz coś ciekawego ;)

Fajne efekty zyskujesz dzięki dodawaniu atrybutów do kontrolek (edycja kodu xaml)

Opublikowano

Z tego co wiem to mało kto wiedział jak się do tego zabrać po odpaleniu wpf.

Po prostu baw się i eksperymentuj a sklecisz coś ciekawego ;)

Fajne efekty zyskujesz dzięki dodawaniu atrybutów do kontrolek (edycja kodu xaml)

 

Czarna magia :)

 

 

Mam do was osobne pytanko, nie wiem co się dzisiaj poj***** ale nie działa mi ani launcher który skompilowałem wczoraj, ani nowy dzisiejszy <_< Nie mam pojęcia to może być, oto zdjęcie:

1363951927-U881582.png

 

Wczoraj wszystko wszystko działało, dziś nic :mellow:

apple.png

Opublikowano

 

Czarna magia :)

 

 

Mam do was osobne pytanko, nie wiem co się dzisiaj poj***** ale nie działa mi ani launcher który skompilowałem wczoraj, ani nowy dzisiejszy <_< Nie mam pojęcia to może być, oto zdjęcie:

1363951927-U881582.png

 

Wczoraj wszystko wszystko działało, dziś nic :mellow:

Nie odinstalowałeś Javy?
Opublikowano

Nie odinstalowałeś Javy?

 

No właśnie nie, ale problem już rozwiązałem. Nie wiem jakim cudem się tak podziało, problemem był bark slasha przed .minecraft, dzień wcześniej bez żadnych zmian wszystko działało <_<

apple.png

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...