Tema visual studio
NarvaezG1Trabajo26 de Febrero de 2016
20.937 Palabras (84 Páginas)264 Visitas
Imports System.Drawing.Drawing2D, System.ComponentModel
''' <summary>
''' Flat UI Theme
''' Coder: iSynthesis (HF)
''' Version: 1.0.1
''' Date Created: 16/06/2013
''' Date Changed: 18/06/2013
''' UID: 374648
''' </summary>
''' <remarks></remarks>
Module Helpers
#Region " Variables"
Friend G As Graphics, B As Bitmap
Friend _FlatColor As Color = Color.FromArgb(35, 168, 109)
Friend NearSF As New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Near}
Friend CenterSF As New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center}
#End Region
#Region " Functions"
Public Function RoundRec(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
Dim P As GraphicsPath = New GraphicsPath()
Dim ArcRectangleWidth As Integer = Curve * 2
P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
Return P
End Function
'-- Credit: AeonHack
Public Function DrawArrow(ByVal x As Integer, ByVal y As Integer, ByVal flip As Boolean) As GraphicsPath
Dim GP As New GraphicsPath()
Dim W As Integer = 12
Dim H As Integer = 6
If flip Then
GP.AddLine(x + 1, y, x + W + 1, y)
GP.AddLine(x + W, y, x + H, y + H - 1)
Else
GP.AddLine(x, y + H, x + W, y + H)
GP.AddLine(x + W, y + H, x + H, y)
End If
GP.CloseFigure()
Return GP
End Function
#End Region
End Module
#Region " Mouse States"
Enum MouseState As Byte
None = 0
Over = 1
Down = 2
Block = 3
End Enum
#End Region
Class FormSkin : Inherits ContainerControl
#Region " Variables"
Private W, H As Integer
Private Cap As Boolean = False
Private _HeaderMaximize As Boolean = False
Private MousePoint As New Point(0, 0)
Private MoveHeight = 50
#End Region
#Region " Properties"
#Region " Colors"
<Category("Colors")> _
Public Property HeaderColor() As Color
Get
Return _HeaderColor
End Get
Set(ByVal value As Color)
_HeaderColor = value
End Set
End Property
<Category("Colors")> _
Public Property BaseColor() As Color
Get
Return _BaseColor
End Get
Set(ByVal value As Color)
_BaseColor = value
End Set
End Property
<Category("Colors")> _
Public Property BorderColor() As Color
Get
Return _BorderColor
End Get
Set(ByVal value As Color)
_BorderColor = value
End Set
End Property
<Category("Colors")> _
Public Property FlatColor() As Color
Get
Return _FlatColor
End Get
Set(ByVal value As Color)
_FlatColor = value
End Set
End Property
#End Region
<Category("Options")>
Public Property HeaderMaximize As Boolean
Get
Return _HeaderMaximize
End Get
Set(ByVal value As Boolean)
_HeaderMaximize = value
End Set
End Property
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
MyBase.OnMouseDown(e)
If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
Cap = True
MousePoint = e.Location
End If
End Sub
Private Sub FormSkin_MouseDoubleClick(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Me.MouseDoubleClick
If HeaderMaximize Then
If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
If FindForm.WindowState = FormWindowState.Normal Then
FindForm.WindowState = FormWindowState.Maximized : FindForm.****************************()
ElseIf FindForm.WindowState = FormWindowState.Maximized Then
FindForm.WindowState = FormWindowState.Normal : FindForm.****************************()
End If
End If
End If
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
MyBase.OnMouseUp(e) : Cap = False
End Sub
Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
MyBase.OnMouseMove(e)
If Cap Then
Parent.Location = MousePosition - MousePoint
End If
End Sub
Protected Overrides Sub OnCreateControl()
MyBase.OnCreateControl()
ParentForm.FormBorderStyle = FormBorderStyle.None
ParentForm.AllowTransparency = False
ParentForm.TransparencyKey = Color.Fuchsia
ParentForm.FindForm.StartPosition = FormStartPosition.CenterScreen
Dock = DockStyle.Fill
Invalidate()
End Sub
#End Region
#Region " Colors"
Private _HeaderColor As Color = Color.FromArgb(45, 47, 49)
Private _BaseColor As Color = Color.FromArgb(60, 70, 73)
Private _BorderColor As Color = Color.FromArgb(53, 58, 60)
Private TextColor As Color = Color.FromArgb(234, 234, 234)
#End Region
Sub New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
DoubleBuffered = True
BackColor = Color.White
Font = New Font("Segoe UI", 12)
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
W = Width : H = Height
Dim Base As New Rectangle(0, 0, W, H), Header As New Rectangle(0, 0, W, 50)
With G
.SmoothingMode = 2
.PixelOffsetMode = 2
.TextRenderingHint = 5
.Clear(BackColor)
'-- Base
.FillRectangle(New SolidBrush(_BaseColor), Base)
'-- Header
.FillRectangle(New SolidBrush(_HeaderColor), Header)
'-- Logo
.FillRectangle(New SolidBrush(Color.FromArgb(243, 243, 243)), New Rectangle(8, 16, 4, 18))
.FillRectangle(New SolidBrush(_FlatColor), 16, 16, 4, 18)
.DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(26, 15, W, H), NearSF)
'-- Border
.DrawRectangle(New Pen(_BorderColor), Base)
End With
MyBase.OnPaint(e)
G.Dispose()
e.Graphics.InterpolationMode = 7
e.Graphics.DrawImageUnscaled(B, 0, 0)
B.Dispose()
End Sub
End Class
Class FlatClose : Inherits Control
#Region " Variables"
Private State As MouseState = MouseState.None
Private x As Integer
#End Region
#Region " Properties"
#Region " Mouse States"
...