Avast Theme


SUBMITTED BY: Guest

DATE: June 5, 2014, 9:26 a.m.

FORMAT: Text only

SIZE: 38.9 kB

HITS: 853

  1. '/// Theme by GammaRay
  2. '/// You may use this in any program but you must leave credits
  3. '/// Don't forget to leave feedback on the thread
  4. Imports System.Drawing.Text
  5. Imports System.IO
  6. Imports System.Drawing.Drawing2D
  7. Imports System.ComponentModel
  8. Imports System.ComponentModel.Design
  9. Imports System.Drawing.Design
  10. Imports System.Windows.Forms
  11. Public Class AVTheme
  12. Inherits ContainerControl
  13. Private C1 As Color = Color.FromArgb(242, 242, 242)
  14. Private C2 As Color = Color.FromArgb(0, 166, 208)
  15. Private B1 As New SolidBrush(C1)
  16. Private B2 As New SolidBrush(C2)
  17. Private F As Font
  18. Private T As String
  19. Private _PageName As String = "Scan"
  20. Private _PageImage As Image
  21. Private MouseP As Point = New Point(0, 0)
  22. Private Cap As Boolean = False
  23. Private MoveHeight As Integer = 48
  24. Public Property PageName() As String
  25. Get
  26. Return _PageName
  27. End Get
  28. Set(v As String)
  29. _PageName = v : Invalidate()
  30. End Set
  31. End Property
  32. Public Property PageImage() As Image
  33. Get
  34. Return _PageImage
  35. End Get
  36. Set(v As Image)
  37. _PageImage = v
  38. End Set
  39. End Property
  40. Sub New()
  41. MyBase.New()
  42. Me.BackColor = C1
  43. DoubleBuffered = True
  44. Me.Dock = DockStyle.Fill
  45. F = New Font("Segoe UI", 13, FontStyle.Regular)
  46. End Sub
  47. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  48. MyBase.OnMouseDown(e)
  49. If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  50. Cap = True : MouseP = e.Location
  51. End If
  52. End Sub
  53. Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  54. MyBase.OnMouseUp(e) : Cap = False
  55. End Sub
  56. Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  57. MyBase.OnMouseMove(e)
  58. If Cap Then
  59. Parent.Location = MousePosition - MouseP
  60. End If
  61. End Sub
  62. Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  63. MyBase.OnPaint(e)
  64. Dim G As Graphics
  65. G = e.Graphics
  66. G.SmoothingMode = SmoothingMode.None
  67. Dim I As Bitmap = Me.ParentForm.Icon.ToBitmap
  68. Dim IM As Image = I
  69. T = Me.ParentForm.Text
  70. G.FillRectangle(B2, New Rectangle(0, 48, Me.Width, 70))
  71. G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(203, 203, 203))), New Point(0, Me.Height - 49), New Point(Me.Width, Me.Height - 49))
  72. G.DrawString(T, F, Brushes.Black, Me.Width / 2 - G.MeasureString(T, F).Width / 2, 24 - G.MeasureString(T, F).Height / 2)
  73. G.DrawImage(IM, New Point(Me.Width / 2 - G.MeasureString(T, F).Width / 2 - IM.Width - 2, IM.Height / 2 - 7))
  74. If Not Me.ParentForm.FormBorderStyle = FormBorderStyle.None Then
  75. Me.ParentForm.FormBorderStyle = FormBorderStyle.None
  76. End If
  77. G.TextRenderingHint = TextRenderingHint.AntiAlias
  78. G.DrawString(_PageName, New Font("Verdana", 17, FontStyle.Regular), Brushes.White, 105, 70)
  79. If Not _PageImage Is Nothing Then
  80. G.DrawImage(_PageImage, New Point(70, 84 - _PageImage.Height / 2))
  81. End If
  82. End Sub
  83. End Class
  84. Public Class AVWindowButton : Inherits Control
  85. Private Hover As Color = Color.FromArgb(242, 242, 242)
  86. Private _SetImage As String = "Close"
  87. Sub New()
  88. Me.Size = New Size(33, 33)
  89. Me.DoubleBuffered = True
  90. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  91. Me.BackColor = Color.Transparent
  92. End Sub
  93. <TypeConverter(GetType(btnimProperty)), Category("Misc"), Description("Select Image from the list")>
  94. Public Property SetImage() As String
  95. Get
  96. Return _SetImage
  97. End Get
  98. Set(value As String)
  99. _SetImage = value
  100. End Set
  101. End Property
  102. Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  103. Hover = Color.FromArgb(228, 228, 228)
  104. MyBase.Invalidate()
  105. MyBase.OnMouseEnter(e)
  106. End Sub
  107. Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  108. Hover = Color.FromArgb(242, 242, 242)
  109. MyBase.Invalidate()
  110. MyBase.OnMouseEnter(e)
  111. End Sub
  112. Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  113. Hover = Color.FromArgb(214, 214, 214)
  114. MyBase.Invalidate()
  115. MyBase.OnMouseUp(e)
  116. End Sub
  117. Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  118. Hover = Color.FromArgb(151, 151, 151)
  119. MyBase.Invalidate()
  120. MyBase.OnMouseClick(e)
  121. End Sub
  122. Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  123. Dim P As GraphicsPath = New GraphicsPath()
  124. Dim ArcRectangleWidth As Integer = Curve * 2
  125. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  126. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  127. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  128. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  129. P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  130. Return P
  131. End Function
  132. Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  133. MyBase.OnPaint(e)
  134. Dim G As Graphics
  135. G = e.Graphics
  136. G.SmoothingMode = SmoothingMode.HighQuality
  137. G.FillPath(New SolidBrush(Color.FromArgb(Hover.ToArgb)), RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
  138. G.SmoothingMode = SmoothingMode.None
  139. If _SetImage = "Close" Then
  140. Using P1 As New Pen(Brushes.DimGray, 2)
  141. P1.StartCap = LineCap.Triangle : P1.EndCap = LineCap.Triangle
  142. G.DrawLine(P1, 6, 6, Me.Width - 6, Me.Height - 6)
  143. G.DrawLine(P1, Me.Width - 6, 6, 6, Me.Height - 6)
  144. End Using
  145. ElseIf _SetImage = "Minimize" Then
  146. Using P1 As New Pen(Brushes.DimGray, 2)
  147. P1.StartCap = LineCap.Triangle : P1.EndCap = LineCap.Triangle
  148. G.DrawLine(P1, 6, Me.Height - 6, Me.Width - 6, Me.Height - 6)
  149. End Using
  150. ElseIf _SetImage = "Maximize" Then
  151. Using P1 As New Pen(Brushes.DimGray, 2)
  152. P1.StartCap = LineCap.Triangle : P1.EndCap = LineCap.Triangle
  153. G.FillRectangle(New SolidBrush(Color.FromArgb(Hover.ToArgb)), 6, 8, 16, 13)
  154. G.DrawRectangle(P1, 6, 8, 16, 13)
  155. G.FillRectangle(New SolidBrush(Color.FromArgb(Hover.ToArgb)), 12, Me.Height - 19, 16, 13)
  156. G.DrawRectangle(P1, 12, Me.Height - 19, 16, 13)
  157. End Using
  158. ElseIf _SetImage = "Stop" Then
  159. Dim R1 As New Rectangle(Me.Height / 2 - 6, Me.Width / 2 - 6, 12, 12)
  160. G.FillRectangle(New SolidBrush(Color.DimGray), R1)
  161. ElseIf _SetImage = "Play" Then
  162. G.SmoothingMode = SmoothingMode.AntiAlias
  163. Dim ptsArray As PointF() = {New PointF(10, 10), New PointF(Me.Width - 10, Me.Height / 2), New PointF(10, Me.Height - 10), New PointF(10, 10)}
  164. Dim gp As New Drawing2D.GraphicsPath(Drawing2D.FillMode.Alternate)
  165. gp.AddLines(ptsArray)
  166. gp.CloseFigure()
  167. G.FillPath(Brushes.DimGray, gp)
  168. End If
  169. End Sub
  170. End Class
  171. Public Class btnimProperty
  172. Inherits System.ComponentModel.StringConverter
  173. Public Overrides Function GetStandardValues(context As System.ComponentModel.ITypeDescriptorContext) As System.ComponentModel.TypeConverter.StandardValuesCollection
  174. Return New StandardValuesCollection(myList)
  175. End Function
  176. Public Overrides Function GetStandardValuesSupported(context As System.ComponentModel.ITypeDescriptorContext) As Boolean
  177. Return True
  178. End Function
  179. Public Overrides Function GetStandardValuesExclusive(context As System.ComponentModel.ITypeDescriptorContext) As Boolean
  180. Return True
  181. End Function
  182. Private Function myList() As Collections.IList
  183. Dim imgList As New Collection
  184. With imgList
  185. .Add("Close")
  186. .Add("Minimize")
  187. .Add("Maximize")
  188. .Add("Stop")
  189. .Add("Play")
  190. End With
  191. Return imgList
  192. End Function
  193. End Class
  194. Public Class AVTextbox
  195. Inherits Control
  196. Dim WithEvents txtbox As New TextBox
  197. Private _passmask As Boolean = False
  198. Public Shadows Property UseSystemPasswordChar() As Boolean
  199. Get
  200. Return _passmask
  201. End Get
  202. Set(ByVal v As Boolean)
  203. txtbox.UseSystemPasswordChar = UseSystemPasswordChar
  204. _passmask = v
  205. Invalidate()
  206. End Set
  207. End Property
  208. Private _maxchars As Integer = 32767
  209. Public Shadows Property MaxLength() As Integer
  210. Get
  211. Return _maxchars
  212. End Get
  213. Set(ByVal v As Integer)
  214. _maxchars = v
  215. txtbox.MaxLength = MaxLength
  216. Invalidate()
  217. End Set
  218. End Property
  219. Private _align As HorizontalAlignment
  220. Public Shadows Property TextAlignment() As HorizontalAlignment
  221. Get
  222. Return _align
  223. End Get
  224. Set(ByVal v As HorizontalAlignment)
  225. _align = v
  226. Invalidate()
  227. End Set
  228. End Property
  229. Private _multiline As Boolean = False
  230. Public Shadows Property MultiLine() As Boolean
  231. Get
  232. Return _multiline
  233. End Get
  234. Set(ByVal value As Boolean)
  235. _multiline = value
  236. Invalidate()
  237. End Set
  238. End Property
  239. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  240. MyBase.OnTextChanged(e)
  241. Invalidate()
  242. End Sub
  243. Protected Overrides Sub OnBackColorChanged(ByVal e As System.EventArgs)
  244. MyBase.OnBackColorChanged(e)
  245. txtbox.BackColor = BackColor
  246. Invalidate()
  247. End Sub
  248. Protected Overrides Sub OnForeColorChanged(ByVal e As System.EventArgs)
  249. MyBase.OnForeColorChanged(e)
  250. txtbox.ForeColor = ForeColor
  251. Invalidate()
  252. End Sub
  253. Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs)
  254. MyBase.OnFontChanged(e)
  255. txtbox.Font = Font
  256. End Sub
  257. Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
  258. MyBase.OnGotFocus(e)
  259. txtbox.Focus()
  260. End Sub
  261. Sub TextChngTxtBox() Handles txtbox.TextChanged
  262. Text = txtbox.Text
  263. End Sub
  264. Sub TextChng() Handles MyBase.TextChanged
  265. txtbox.Text = Text
  266. End Sub
  267. Sub NewTextBox()
  268. With txtbox
  269. .Multiline = False
  270. .BackColor = Color.FromArgb(43, 43, 43)
  271. .ForeColor = ForeColor
  272. .Text = String.Empty
  273. .TextAlign = HorizontalAlignment.Center
  274. .BorderStyle = BorderStyle.None
  275. .Location = New Point(7, 5)
  276. .Font = New Font("Verdana", 10)
  277. .Size = New Size(Width - 10, 33)
  278. .UseSystemPasswordChar = UseSystemPasswordChar
  279. End With
  280. End Sub
  281. Sub New()
  282. MyBase.New()
  283. NewTextBox()
  284. Controls.Add(txtbox)
  285. SetStyle(ControlStyles.UserPaint, True)
  286. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  287. Text = ""
  288. BackColor = Color.White
  289. ForeColor = Color.Gray
  290. Font = New Font("Verdana", 10)
  291. Size = New Size(135, 33)
  292. DoubleBuffered = True
  293. End Sub
  294. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  295. Dim B As New Bitmap(Width, Height)
  296. Dim G As Graphics = Graphics.FromImage(B)
  297. G.SmoothingMode = SmoothingMode.HighQuality
  298. Height = 33
  299. With txtbox
  300. .Width = Width - 10
  301. .TextAlign = TextAlignment
  302. .UseSystemPasswordChar = UseSystemPasswordChar
  303. .Height = 33
  304. End With
  305. G.Clear(Color.Transparent)
  306. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(216, 216, 216))), New Rectangle(0, 0, Width - 1, Height - 1))
  307. e.Graphics.DrawImage(B.Clone(), 0, 0)
  308. G.Dispose() : B.Dispose()
  309. End Sub
  310. End Class
  311. Class AVTabControl
  312. Inherits Windows.Forms.TabControl
  313. Private _DrawBottomBorder As Boolean
  314. Public Property DrawBottomBorder() As Boolean
  315. Get
  316. Return _DrawBottomBorder
  317. End Get
  318. Set(ByVal value As Boolean)
  319. _DrawBottomBorder = value
  320. Invalidate()
  321. End Set
  322. End Property
  323. Private _BorderColor As Pen = Pens.Black
  324. Public Property BorderColor() As Color
  325. Get
  326. Return _BorderColor.Color
  327. End Get
  328. Set(ByVal value As Color)
  329. _BorderColor = New Pen(value)
  330. Invalidate()
  331. End Set
  332. End Property
  333. Private _TextAlignment As StringAlignment = StringAlignment.Near
  334. Public Property TextAlignment() As StringAlignment
  335. Get
  336. Return _TextAlignment
  337. End Get
  338. Set(ByVal value As StringAlignment)
  339. _TextAlignment = value
  340. Invalidate()
  341. End Set
  342. End Property
  343. Sub New()
  344. SetStyle(DirectCast(139286, ControlStyles), True)
  345. SizeMode = TabSizeMode.Fixed
  346. Alignment = TabAlignment.Left
  347. ItemSize = New Size(50, 50)
  348. Font = New Font("Segoe UI", 9, FontStyle.Regular, GraphicsUnit.Point)
  349. DrawMode = TabDrawMode.OwnerDrawFixed
  350. P1 = New Pen(Color.FromArgb(94, 94, 94))
  351. P2 = New Pen(Color.FromArgb(17, 17, 17))
  352. B1 = New SolidBrush(Color.FromArgb(38, 38, 38))
  353. B2 = New SolidBrush(Color.FromArgb(35, 35, 35))
  354. B3 = New SolidBrush(Color.FromArgb(5, Color.White))
  355. SF1 = New StringFormat()
  356. SF1.LineAlignment = StringAlignment.Center
  357. For Each pg As TabPage In Me.TabPages
  358. pg.BackColor = Color.FromArgb(242, 242, 242)
  359. Next
  360. End Sub
  361. Protected Overrides Sub OnControlAdded(ByVal e As ControlEventArgs)
  362. If TypeOf e.Control Is TabPage Then
  363. For Each i As TabPage In Me.Controls
  364. i = New TabPage
  365. Next
  366. e.Control.BackColor = Color.FromArgb(242, 242, 242)
  367. End If
  368. MyBase.OnControlAdded(e)
  369. End Sub
  370. Private R1, R2 As Rectangle
  371. Private P1, P2 As Pen
  372. Private B1, B2, B3 As SolidBrush
  373. Private GB1 As LinearGradientBrush
  374. Private GB2 As LinearGradientBrush
  375. Private TP1 As TabPage
  376. Private SF1 As StringFormat
  377. Private ItemHeight As Integer
  378. Dim S1 As Size
  379. Dim REC As New Rectangle
  380. Dim BR1 As LinearGradientBrush
  381. Private G As Graphics
  382. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  383. Dim F1 As New System.Drawing.Font("Segoe UI", 9, FontStyle.Bold, GraphicsUnit.Point)
  384. G = e.Graphics
  385. G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  386. G.SmoothingMode = SmoothingMode.AntiAlias
  387. G.Clear(Color.FromArgb(242, 242, 242))
  388. ItemHeight = ItemSize.Height + 2
  389. G.FillRectangle(B1, 0, 0, ItemHeight, Height)
  390. G.DrawRectangle(Pens.Black, 0, 0, ItemHeight, Height)
  391. Dim B5 As New SolidBrush(Color.FromArgb(51, 51, 51))
  392. Dim P5 As New Pen(B5)
  393. For I As Integer = 0 To TabCount - 1
  394. R1 = GetTabRect(I)
  395. R1.Y -= 1
  396. R1.Width += 1
  397. R1.X -= 1
  398. TP1 = TabPages(I)
  399. If SelectedIndex = I Then
  400. Using GB1 As New LinearGradientBrush(R1, Color.FromArgb(26, 26, 26), Color.FromArgb(17, 17, 17), 90.0F)
  401. Dim ColorBlend As New ColorBlend()
  402. ColorBlend.Colors = {Color.FromArgb(25, 25, 25), Color.FromArgb(17, 17, 17), Color.FromArgb(25, 25, 25)}
  403. ColorBlend.Positions = {0.0F, 0.5F, 1.0F}
  404. GB1.InterpolationColors = ColorBlend
  405. G.FillRectangle(GB1, R1)
  406. End Using
  407. G.DrawLine(P5, R1.Left, R1.Y - 1, R1.Width + 1, R1.Y - 1)
  408. If HoverIndex = I Then
  409. G.FillRectangle(B3, R1)
  410. End If
  411. R1.X += 5
  412. R1.Width -= 14
  413. R2 = R1
  414. R2.Y += 1
  415. R2.X += 1
  416. SF1.Alignment = _TextAlignment
  417. G.DrawString(TP1.Text, Font, Brushes.White, New Rectangle(R2.Left + 33, R2.Top - 1, R2.Width - 43, R2.Height), SF1)
  418. Try
  419. G.DrawImage(Me.ImageList.Images.Item(TabPages(I).ImageIndex), R1.X + 1, R1.Y + 11, 32, 32)
  420. Catch
  421. End Try
  422. Else
  423. Dim BR2 As New SolidBrush(Color.FromArgb(38, 38, 38))
  424. R1.Y -= 1
  425. G.FillRectangle(BR2, R1)
  426. G.DrawLine(P5, R1.X, R1.Y, R1.Right, R1.Y)
  427. If HoverIndex = I Then
  428. G.FillRectangle(B3, R1)
  429. End If
  430. Dim BR As New SolidBrush(Color.FromArgb(140, Color.Black))
  431. G.DrawLine(P2, R1.X, R1.Bottom - 1, R1.Right, R1.Bottom - 1)
  432. R1.X += 5
  433. R1.Width -= 14
  434. R2 = R1
  435. R2.Y += 1
  436. R2.X += 1
  437. SF1.Alignment = _TextAlignment
  438. G.DrawString(TP1.Text, Font, Brushes.Gray, New Rectangle(R2.Left + 33, R2.Top - 1, R2.Width - 43, R2.Height), SF1)
  439. Try
  440. G.DrawImage(Me.ImageList.Images.Item(TabPages(I).ImageIndex), R1.X + 2, R1.Y + 11, 32, 32)
  441. Catch
  442. End Try
  443. End If
  444. G.DrawLine(P5, R1.Right + 8, R1.Top, R1.Right + 8, R1.Bottom - 3)
  445. Next
  446. G.DrawLine(Pens.Black, 0, 0, R2.Height - 9, 0)
  447. G.DrawLine(_BorderColor, ItemHeight, 0, ItemHeight, Height)
  448. G.DrawLine(P5, R1.Left - 5, ItemSize.Width * (TabCount), R1.Right + 8, ItemSize.Width * (TabCount))
  449. If _DrawBottomBorder Then
  450. G.DrawLine(_BorderColor, 0, Height - 1, Width, Height - 1)
  451. End If
  452. G.DrawLine(P5, R1.Left - 5, ((TabCount) * (R1.Width + 12)) + (TabCount * 2), R1.Left - 5, 1)
  453. End Sub
  454. Private HoverIndex As Integer = -1
  455. Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  456. For I As Integer = 0 To TabPages.Count - 1
  457. If GetTabRect(I).Contains(e.Location) Then
  458. HoverIndex = I
  459. Exit For
  460. End If
  461. Next
  462. Invalidate()
  463. MyBase.OnMouseMove(e)
  464. End Sub
  465. Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  466. HoverIndex = -1
  467. Invalidate()
  468. MyBase.OnMouseLeave(e)
  469. End Sub
  470. End Class
  471. Public Class AVProgressBar
  472. Inherits Control
  473. Private _Value As Integer = 50
  474. Private _Thickness As Integer = 5
  475. Private _Angle As Integer = 0
  476. Private _Symbol As String = "%"
  477. Sub New()
  478. Size = New Size(65, 65)
  479. Invalidate()
  480. End Sub
  481. Public Property Angle() As Integer
  482. Get
  483. Return _Angle
  484. End Get
  485. Set(ByVal v As Integer)
  486. _Angle = v : Invalidate()
  487. End Set
  488. End Property
  489. Public Property Symbol() As String
  490. Get
  491. Return _Symbol
  492. End Get
  493. Set(ByVal v As String)
  494. _Symbol = v : Invalidate()
  495. End Set
  496. End Property
  497. Public Property Thickness() As Integer
  498. Get
  499. Return _Thickness
  500. End Get
  501. Set(ByVal v As Integer)
  502. _Thickness = v : Invalidate()
  503. End Set
  504. End Property
  505. Protected Overrides Sub OnPaintBackground(ByVal p As PaintEventArgs)
  506. End Sub
  507. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  508. MyBase.OnPaint(e)
  509. Me.Width = Me.Height
  510. Using B1 As New Bitmap(Width, Height)
  511. Using G As Graphics = Graphics.FromImage(B1)
  512. G.SmoothingMode = SmoothingMode.AntiAlias
  513. G.Clear(BackColor)
  514. Using LGB As New LinearGradientBrush(ClientRectangle, Color.FromArgb(217, 217, 217), Color.FromArgb(217, 217, 217), LinearGradientMode.Vertical)
  515. Using P1 As New Pen(LGB, Thickness + 3)
  516. G.DrawArc(P1, CInt(Thickness / 2) + 2, CInt(Thickness / 2) + 2, Width - Thickness - 4, Height - Thickness - 4, -90, 360)
  517. End Using
  518. End Using
  519. Using LGB As New LinearGradientBrush(ClientRectangle, Color.FromArgb(0, 166, 208), Color.FromArgb(0, 166, 208), LinearGradientMode.Vertical)
  520. Using P1 As New Pen(LGB, Thickness + 3)
  521. G.DrawArc(P1, CInt(Thickness / 2) + 9, CInt(Thickness / 2) + 9, Width - Thickness - 18, Height - Thickness - 18, -90, 360)
  522. End Using
  523. End Using
  524. Using LGB As New LinearGradientBrush(ClientRectangle, Color.FromArgb(255, 255, 255), Color.FromArgb(255, 255, 255), LinearGradientMode.Vertical)
  525. Using P1 As New Pen(LGB, Thickness - 2)
  526. Dim i As Integer = 360 / 100 * _Value
  527. G.DrawArc(P1, CInt(Thickness / 2) + 9, CInt(Thickness / 2) + 9, Width - Thickness - 18, Height - Thickness - 18, -90, i)
  528. End Using
  529. End Using
  530. G.DrawString(_Value & _Symbol, New Font("Arial", 13), Brushes.Black, New Point(Me.Width / 2 - G.MeasureString(_Value & _Symbol, New Font("Arial", 13)).Width / 2 + 1, Me.Height / 2 - G.MeasureString(_Value & "%", New Font("Arial", 13)).Height / 2 + 1))
  531. End Using
  532. e.Graphics.DrawImage(B1, 0, 0)
  533. End Using
  534. End Sub
  535. End Class
  536. Public Class AVLabel : Inherits Control
  537. Sub New()
  538. Me.Size = New Size(175, 25)
  539. End Sub
  540. Private _String1 As String = "Quick Scan"
  541. Private _String2 As String = "/ Scan running..."
  542. Private _Img As Image
  543. Public Property String1() As String
  544. Get
  545. Return _String1
  546. End Get
  547. Set(v As String)
  548. _String1 = v : Invalidate()
  549. End Set
  550. End Property
  551. Public Property String2() As String
  552. Get
  553. Return _String2
  554. End Get
  555. Set(v As String)
  556. _String2 = v : Invalidate()
  557. End Set
  558. End Property
  559. Public Property Image As Image
  560. Get
  561. Return _Img
  562. End Get
  563. Set(v As Image)
  564. _Img = v : Invalidate()
  565. End Set
  566. End Property
  567. Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  568. MyBase.OnPaint(e)
  569. Dim G As Graphics
  570. G = e.Graphics
  571. G.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  572. G.DrawString(_String1, New Font("Segoe UI", 9, FontStyle.Bold), Brushes.DimGray, 32, 6)
  573. G.DrawString(_String2, New Font("Segoe UI", 9), Brushes.DimGray, 33 + G.MeasureString(_String1, New Font("Segoe UI", 9, FontStyle.Bold)).Width, 6)
  574. If Not _Img Is Nothing Then
  575. G.DrawImage(_Img, 0, 0)
  576. End If
  577. End Sub
  578. End Class
  579. Public Class AVComboBox
  580. Inherits ComboBox
  581. Private _StartIndex As Integer = 0
  582. Private C1 As Color = Color.FromArgb(254, 254, 254)
  583. Private C2 As Color = Color.FromArgb(244, 244, 244)
  584. Public Property StartIndex As Integer
  585. Get
  586. Return _StartIndex
  587. End Get
  588. Set(ByVal value As Integer)
  589. _StartIndex = value
  590. Try
  591. MyBase.SelectedIndex = value
  592. Catch
  593. End Try
  594. Invalidate()
  595. End Set
  596. End Property
  597. Sub ReplaceItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Me.DrawItem
  598. e.DrawBackground()
  599. Try
  600. If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  601. e.Graphics.FillRectangle(New SolidBrush(Color.LightGray), e.Bounds)
  602. Using b As New SolidBrush(e.ForeColor)
  603. e.Graphics.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), New Font("Verdana", 10), b, 1, e.Bounds.Top + 5)
  604. End Using
  605. Else
  606. e.Graphics.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), New Font("Verdana", 10), Brushes.Gray, 1, e.Bounds.Top + 5)
  607. End If
  608. Catch
  609. End Try
  610. e.DrawFocusRectangle()
  611. Me.Invalidate()
  612. End Sub
  613. Protected Sub DrawTriangle(ByVal Clr As Color, ByVal FirstPoint As Point, ByVal SecondPoint As Point, ByVal ThirdPoint As Point, ByVal G As Graphics)
  614. Dim points As New List(Of Point)()
  615. points.Add(FirstPoint)
  616. points.Add(SecondPoint)
  617. points.Add(ThirdPoint)
  618. G.FillPolygon(New SolidBrush(Clr), points.ToArray)
  619. End Sub
  620. Sub New()
  621. Me.Width = 163
  622. Me.Font = New Font("Verdana", 15)
  623. Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  624. ControlStyles.ResizeRedraw Or _
  625. ControlStyles.UserPaint Or _
  626. ControlStyles.DoubleBuffer, True)
  627. Me.DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  628. Me.BackColor = C1
  629. Me.ForeColor = C1
  630. Me.DropDownStyle = ComboBoxStyle.DropDownList
  631. Me.DoubleBuffered = True
  632. End Sub
  633. Protected Overrides Sub OnTextChanged(e As System.EventArgs)
  634. MyBase.OnTextChanged(e)
  635. Invalidate()
  636. End Sub
  637. Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  638. C2 = Color.FromArgb(233, 233, 233)
  639. MyBase.Invalidate()
  640. MyBase.OnMouseClick(e)
  641. End Sub
  642. Protected Overrides Sub OnMouseUp(e As System.Windows.Forms.MouseEventArgs)
  643. C2 = Color.FromArgb(244, 244, 244)
  644. MyBase.Invalidate()
  645. MyBase.OnMouseUp(e)
  646. End Sub
  647. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  648. MyBase.OnPaint(e)
  649. Dim G As Graphics
  650. G = e.Graphics
  651. G.FillRectangle(New SolidBrush(Color.FromArgb(C2.ToArgb)), New Rectangle(Width - 20, 2, 17, Height - 5))
  652. G.SmoothingMode = SmoothingMode.HighQuality
  653. Try
  654. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(216, 216, 216))), New Rectangle(Width - 20, 2, 17, Height - 5))
  655. Try
  656. G.DrawString(Text, New Font("Verdana", 10), Brushes.Gray, New Rectangle(3, 0, Width - 20, Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
  657. Catch : End Try
  658. G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(216, 216, 216))), 0, 0, 0, 0)
  659. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(216, 216, 216))), New Rectangle(0, 0, Width - 1, Height - 1))
  660. DrawTriangle(Color.FromArgb(216, 216, 216), New Point(Width - 15, 14), New Point(Width - 8, 14), New Point(Width - 12, 17), G)
  661. Catch
  662. End Try
  663. End Sub
  664. End Class
  665. Public Class AVButton
  666. Inherits Control
  667. Private Hover As Color
  668. Private _MainColor As String
  669. Private Loaded As Boolean
  670. Sub New()
  671. Me.Size = New Size(33, 33)
  672. Me.DoubleBuffered = True
  673. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  674. Me.BackColor = Color.Transparent
  675. End Sub
  676. <TypeConverter(GetType(btnColorProperty)), Category("Misc"), Description("Select color from the list")>
  677. Public Property MainColor() As String
  678. Get
  679. Return _MainColor
  680. End Get
  681. Set(value As String)
  682. _MainColor = value
  683. End Set
  684. End Property
  685. Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  686. Hover = Color.FromArgb(228, 228, 228)
  687. If _MainColor = "Light" Then
  688. Hover = Color.FromArgb(228, 228, 228)
  689. Else
  690. Hover = Color.FromArgb(117, 117, 117)
  691. End If
  692. MyBase.Invalidate()
  693. MyBase.OnMouseEnter(e)
  694. End Sub
  695. Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  696. Hover = Color.FromArgb(242, 242, 242)
  697. If _MainColor = "Light" Then
  698. Hover = Color.FromArgb(242, 242, 242)
  699. Else
  700. Hover = Color.DimGray
  701. End If
  702. MyBase.Invalidate()
  703. MyBase.OnMouseEnter(e)
  704. End Sub
  705. Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  706. If _MainColor = "Light" Then
  707. Hover = Color.FromArgb(228, 228, 228)
  708. Else
  709. Hover = Color.FromArgb(117, 117, 117)
  710. End If
  711. MyBase.Invalidate()
  712. MyBase.OnMouseUp(e)
  713. End Sub
  714. Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  715. If _MainColor = "Light" Then
  716. Hover = Color.FromArgb(151, 151, 151)
  717. Else
  718. Hover = Color.FromArgb(66, 66, 66)
  719. End If
  720. MyBase.Invalidate()
  721. MyBase.OnMouseClick(e)
  722. End Sub
  723. Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  724. Dim P As GraphicsPath = New GraphicsPath()
  725. Dim ArcRectangleWidth As Integer = Curve * 2
  726. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  727. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  728. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  729. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  730. P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  731. Return P
  732. End Function
  733. Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  734. MyBase.OnPaint(e)
  735. Dim G As Graphics
  736. G = e.Graphics
  737. If Loaded = False Then
  738. If MainColor = "Light" Then
  739. Hover = Color.FromArgb(242, 242, 242)
  740. Else
  741. Hover = Color.DimGray
  742. End If
  743. Loaded = True
  744. End If
  745. G.SmoothingMode = SmoothingMode.HighQuality
  746. If MainColor = "Light" Then
  747. G.FillPath(New SolidBrush(Color.FromArgb(Hover.ToArgb)), RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 5))
  748. Else
  749. G.FillPath(New SolidBrush(Color.FromArgb(Hover.ToArgb)), RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 5))
  750. End If
  751. G.DrawString(Text, New Font("Verdana", 10), Brushes.Black, Me.Width / 2 - G.MeasureString(Text, New Font("Verdana", 10)).Width / 2, Me.Height / 2 - G.MeasureString(Text, New Font("Verdana", 10)).Height / 2)
  752. G.SmoothingMode = SmoothingMode.None
  753. End Sub
  754. End Class
  755. Public Class btnColorProperty
  756. Inherits System.ComponentModel.StringConverter
  757. Public Overrides Function GetStandardValues(context As System.ComponentModel.ITypeDescriptorContext) As System.ComponentModel.TypeConverter.StandardValuesCollection
  758. Return New StandardValuesCollection(myList)
  759. End Function
  760. Public Overrides Function GetStandardValuesSupported(context As System.ComponentModel.ITypeDescriptorContext) As Boolean
  761. Return True
  762. End Function
  763. Public Overrides Function GetStandardValuesExclusive(context As System.ComponentModel.ITypeDescriptorContext) As Boolean
  764. Return True
  765. End Function
  766. Private Function myList() As Collections.IList
  767. Dim imgList As New Collection
  768. With imgList
  769. .Add("Light")
  770. .Add("Dark")
  771. End With
  772. Return imgList
  773. End Function
  774. End Class

comments powered by Disqus