Advertisement
Guest User

By_Hummet

a guest
Jan 6th, 2014
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.16 KB | None | 0 0
  1. Imports System.Drawing.Drawing2D
  2.  
  3. Class GreenTheme
  4. Inherits Control
  5.  
  6. Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  7. Dock = DockStyle.Fill
  8. If TypeOf Parent Is Form Then
  9. With DirectCast(Parent, Form)
  10. .FormBorderStyle = 0
  11. .BackColor = C1
  12. .ForeColor = Color.FromArgb(12, 12, 12)
  13. End With
  14. End If
  15. MyBase.OnHandleCreated(e)
  16. End Sub
  17. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  18. If New Rectangle(Parent.Location.X, Parent.Location.Y, Width, 22).IntersectsWith(New Rectangle(MousePosition.X, MousePosition.Y, 1, 1)) Then
  19. Capture = False
  20. Dim M As Message = Message.Create(Parent.Handle, 161, New IntPtr(2), IntPtr.Zero)
  21. DefWndProc(M)
  22. End If
  23. MyBase.OnMouseDown(e)
  24. End Sub
  25.  
  26. Dim G As Graphics, B As Bitmap, R1, R2 As Rectangle
  27. Dim C1, C2, C3, C4 As Color, P1, P2, P3 As Pen, B1 As SolidBrush, B2, B3 As LinearGradientBrush
  28.  
  29. Sub New()
  30.  
  31. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint, True)
  32. C1 = Color.FromArgb(41, 57, 34) 'Background
  33. C2 = Color.FromArgb(190, 255, 159) 'Highlight
  34. C3 = Color.FromArgb(22, 22, 22) 'Shadow
  35. C4 = Color.FromArgb(20, 107, 18)
  36. P1 = New Pen(C4) 'Border
  37. P2 = New Pen(C1)
  38. P3 = New Pen(C2)
  39. B1 = New SolidBrush(C2)
  40. Font = New Font("Verdana", 7.0F, FontStyle.Bold)
  41.  
  42. End Sub
  43.  
  44. Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  45. If Height > 0 Then
  46. R1 = New Rectangle(0, 2, Width, 18)
  47. R2 = New Rectangle(0, 21, Width, 10)
  48. B2 = New LinearGradientBrush(R1, C1, C3, 90.0F)
  49. B3 = New LinearGradientBrush(R2, Color.FromArgb(70, 0, 0, 0), Color.Transparent, 90.0F)
  50. Invalidate()
  51. End If
  52. MyBase.OnSizeChanged(e)
  53. End Sub
  54.  
  55. Protected Overrides Sub OnPaintBackground(ByVal pevent As PaintEventArgs)
  56. End Sub
  57.  
  58. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  59. B = New Bitmap(Width, Height)
  60. G = Graphics.FromImage(B)
  61.  
  62. G.Clear(C1)
  63.  
  64. For I As Integer = 0 To Width + 17 Step 4
  65. G.DrawLine(P1, I, 21, I - 17, 37)
  66. G.DrawLine(P1, I - 1, 21, I - 16, 37)
  67. Next
  68. G.FillRectangle(B3, R2)
  69.  
  70. G.FillRectangle(B2, R1)
  71. G.DrawString(Text, Font, B1, 5, 5)
  72.  
  73. G.DrawRectangle(P2, 1, 1, Width - 3, 19)
  74. G.DrawRectangle(P3, 1, 39, Width - 3, Height - 41)
  75.  
  76. G.DrawRectangle(P1, 0, 0, Width - 1, Height - 1)
  77. G.DrawLine(P1, 0, 21, Width, 21)
  78. G.DrawLine(P1, 0, 38, Width, 38)
  79.  
  80. e.Graphics.DrawImage(B, 0, 0)
  81. G.Dispose()
  82. B.Dispose()
  83. End Sub
  84.  
  85. End Class
  86. Class GreenButton
  87. Inherits Control
  88.  
  89. Dim B As Bitmap, G As Graphics, R1 As Rectangle
  90. Dim C1, C2, C3, C4 As Color, P1, P2, P3, P4 As Pen, B1, B2, B5 As Brush, B3, B4 As LinearGradientBrush
  91.  
  92. Sub New()
  93. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint, True)
  94.  
  95. C1 = Color.FromArgb(41, 57, 34) 'Background
  96. C2 = Color.FromArgb(49, 49, 49) 'Highlight
  97. C3 = Color.FromArgb(39, 39, 39) 'Lesser Highlight
  98. C4 = Color.FromArgb(60, Color.Black)
  99. P1 = New Pen(Color.FromArgb(22, 22, 22)) 'Shadow
  100. P2 = New Pen(Color.FromArgb(20, Color.White))
  101. P3 = New Pen(Color.FromArgb(10, Color.White))
  102. P4 = New Pen(Color.FromArgb(30, Color.Black))
  103. B1 = New SolidBrush(C1)
  104. B2 = New SolidBrush(C3)
  105. B5 = New SolidBrush(Color.FromArgb(201, 205, 37)) 'Text Color
  106. Font = New Font("Verdana", 8.0F)
  107. End Sub
  108.  
  109. Private State As Integer
  110. Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  111. State = 0
  112. Invalidate()
  113. End Sub
  114. Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  115. State = 1
  116. Invalidate()
  117. End Sub
  118. Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  119. State = 1
  120. Invalidate()
  121. End Sub
  122. Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  123. State = 2
  124. Invalidate()
  125. End Sub
  126.  
  127. Protected Overrides Sub OnResize(ByVal e As EventArgs)
  128. R1 = New Rectangle(2, 2, Width - 4, 4)
  129. B3 = New LinearGradientBrush(ClientRectangle, C3, C2, 90.0F)
  130. B4 = New LinearGradientBrush(R1, C4, Color.Transparent, 90.0F)
  131. Invalidate()
  132. End Sub
  133.  
  134. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  135. B = New Bitmap(Width, Height)
  136. G = Graphics.FromImage(B)
  137.  
  138. G.FillRectangle(B3, ClientRectangle)
  139.  
  140. Select Case State
  141. Case 0 'Up
  142. G.FillRectangle(B1, 1, 1, Width - 2, Height - 2)
  143. G.DrawLine(P2, 2, 2, Width - 3, 2)
  144. G.DrawLine(P3, 2, Height - 3, Width - 3, Height - 3)
  145. Case 1 'Over
  146. G.FillRectangle(B2, 1, 1, Width - 2, Height - 2)
  147. G.DrawLine(P2, 2, 2, Width - 3, 2)
  148. G.DrawLine(P3, 2, Height - 3, Width - 3, Height - 3)
  149. Case 2 'Down
  150. G.FillRectangle(B2, 1, 1, Width - 2, Height - 2)
  151. G.FillRectangle(B4, R1)
  152. G.DrawLine(P4, 2, 2, 2, Height - 3)
  153. End Select
  154.  
  155. Dim S As SizeF = G.MeasureString(Text, Font)
  156. G.DrawString(Text, Font, B5, Convert.ToInt32(Width / 2 - S.Width / 2), Convert.ToInt32(Height / 2 - S.Height / 2))
  157.  
  158. G.DrawRectangle(P1, 1, 1, Width - 3, Height - 3)
  159.  
  160. e.Graphics.DrawImage(B, 0, 0)
  161. G.Dispose()
  162. B.Dispose()
  163. End Sub
  164.  
  165. Protected Overrides Sub OnPaintBackground(ByVal e As PaintEventArgs)
  166. End Sub
  167.  
  168. End Class
  169. Class GreenProgressBar
  170. Inherits Control
  171.  
  172. #Region " Properties "
  173. Private _Maximum As Double = 100
  174. Public Property Maximum() As Double
  175. Get
  176. Return _Maximum
  177. End Get
  178. Set(ByVal v As Double)
  179. _Maximum = v
  180. Progress = _Current / v * 100
  181. Invalidate()
  182. End Set
  183. End Property
  184. Private _Current As Double
  185. Public Property Current() As Double
  186. Get
  187. Return _Current
  188. End Get
  189. Set(ByVal v As Double)
  190. _Current = v
  191. Progress = v / _Maximum * 100
  192. Invalidate()
  193. End Set
  194. End Property
  195. Private _Progress As Integer
  196. Public Property Progress() As Double
  197. Get
  198. Return _Progress
  199. End Get
  200. Set(ByVal v As Double)
  201. If v < 0 Then v = 0 Else If v > 100 Then v = 100
  202. _Progress = Convert.ToInt32(v)
  203. _Current = v * 0.01 * _Maximum
  204. If Width > 0 Then UpdateProgress()
  205. Invalidate()
  206. End Set
  207. End Property
  208.  
  209. Dim C2 As Color = Color.FromArgb(0, 128, 0) 'Dark Color
  210. Public Property Color1() As Color
  211. Get
  212. Return C2
  213. End Get
  214. Set(ByVal v As Color)
  215. C2 = v
  216. UpdateColors()
  217. Invalidate()
  218. End Set
  219. End Property
  220. Dim C3 As Color = Color.FromArgb(0, 255, 0) 'Light color
  221. Public Property Color2() As Color
  222. Get
  223. Return C3
  224. End Get
  225. Set(ByVal v As Color)
  226. C3 = v
  227. UpdateColors()
  228. Invalidate()
  229. End Set
  230. End Property
  231.  
  232. #End Region
  233.  
  234. Protected Overrides Sub OnPaintBackground(ByVal pevent As PaintEventArgs)
  235. End Sub
  236.  
  237. Dim G As Graphics, B As Bitmap, R1, R2 As Rectangle, X As ColorBlend
  238. Dim C1 As Color, P1, P2, P3 As Pen, B1, B2 As LinearGradientBrush, B3 As SolidBrush
  239. Sub New()
  240.  
  241. C1 = Color.FromArgb(0, 24, 0) 'Background
  242. P1 = New Pen(Color.FromArgb(70, Color.White), 2)
  243. P2 = New Pen(C2)
  244. P3 = New Pen(Color.FromArgb(65, 122, 49)) 'Highlight
  245. B3 = New SolidBrush(Color.FromArgb(100, Color.White))
  246. X = New ColorBlend(4)
  247. X.Colors = {C2, C3, C3, C2}
  248. X.Positions = {0.0F, 0.1F, 0.9F, 1.0F}
  249. R2 = New Rectangle(2, 2, 2, 2)
  250. B2 = New LinearGradientBrush(R2, Nothing, Nothing, 180.0F)
  251. B2.InterpolationColors = X
  252.  
  253. End Sub
  254.  
  255. Sub UpdateColors()
  256. P2.Color = C2
  257. X.Colors = {C2, C3, C3, C2}
  258. B2.InterpolationColors = X
  259. End Sub
  260.  
  261. Protected Overrides Sub OnSizeChanged(ByVal e As System.EventArgs)
  262. R1 = New Rectangle(0, 1, Width, 4)
  263. B1 = New LinearGradientBrush(R1, Color.FromArgb(60, Color.Black), Color.Transparent, 90.0F)
  264. UpdateProgress()
  265. Invalidate()
  266. MyBase.OnSizeChanged(e)
  267. End Sub
  268.  
  269. Sub UpdateProgress()
  270. If _Progress = 0 Then Return
  271. R2 = New Rectangle(2, 2, Convert.ToInt32((Width - 4) * (_Progress * 0.01)), Height - 4)
  272. B2 = New LinearGradientBrush(R2, Nothing, Nothing, 180.0F)
  273. B2.InterpolationColors = X
  274. End Sub
  275.  
  276. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  277. B = New Bitmap(Width, Height)
  278. G = Graphics.FromImage(B)
  279.  
  280. G.Clear(C1)
  281.  
  282. G.FillRectangle(B1, R1)
  283.  
  284. If _Progress > 0 Then
  285. G.FillRectangle(B2, R2)
  286.  
  287. G.FillRectangle(B3, 2, 3, R2.Width, 4)
  288. G.DrawRectangle(P1, 4, 4, R2.Width - 4, Height - 8)
  289.  
  290. G.DrawRectangle(P2, 2, 2, R2.Width - 1, Height - 5)
  291. End If
  292.  
  293. G.DrawRectangle(P3, 0, 0, Width - 1, Height - 1)
  294.  
  295. e.Graphics.DrawImage(B, 0, 0)
  296. G.Dispose()
  297. B.Dispose()
  298. End Sub
  299.  
  300. End Class
  301. Class GreenSeperator
  302. Inherits Control
  303.  
  304. Private _Orientation As Orientation
  305. Public Property Orientation() As Orientation
  306. Get
  307. Return _Orientation
  308. End Get
  309. Set(ByVal v As Orientation)
  310. _Orientation = v
  311. UpdateOffset()
  312. Invalidate()
  313. End Set
  314. End Property
  315.  
  316. Dim G As Graphics, B As Bitmap, I As Integer
  317. Dim C1 As Color, P1, P2 As Pen
  318. Sub New()
  319. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint, True)
  320. C1 = Color.FromArgb(41, 57, 34) 'Background
  321. P1 = New Pen(Color.FromArgb(22, 22, 22)) 'Shadow
  322. P2 = New Pen(Color.FromArgb(0, 120, 0)) 'Highlight
  323. End Sub
  324.  
  325. Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  326. UpdateOffset()
  327. MyBase.OnSizeChanged(e)
  328. End Sub
  329.  
  330. Sub UpdateOffset()
  331. I = Convert.ToInt32(If(_Orientation = 0, Height / 2 - 1, Width / 2 - 1))
  332. End Sub
  333.  
  334. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  335. B = New Bitmap(Width, Height)
  336. G = Graphics.FromImage(B)
  337.  
  338. G.Clear(C1)
  339.  
  340. If _Orientation = 0 Then
  341. G.DrawLine(P1, 0, I, Width, I)
  342. G.DrawLine(P2, 0, I + 1, Width, I + 1)
  343. Else
  344. G.DrawLine(P2, I, 0, I, Height)
  345. G.DrawLine(P1, I + 1, 0, I + 1, Height)
  346. End If
  347.  
  348. e.Graphics.DrawImage(B, 0, 0)
  349. G.Dispose()
  350. B.Dispose()
  351. End Sub
  352.  
  353. Protected Overrides Sub OnPaintBackground(ByVal pevent As PaintEventArgs)
  354. End Sub
  355.  
  356. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement