Valley Theme


SUBMITTED BY: Guest

DATE: Aug. 1, 2014, 10:16 p.m.

FORMAT: C#

SIZE: 32.7 kB

HITS: 24859

  1. Imports System.Drawing
  2. Imports System.Drawing.Drawing2D
  3. Imports System.ComponentModel
  4. Imports System.Drawing.Text
  5. ''' <summary>
  6. ''' Valley Theme
  7. ''' Created by Earn
  8. ''' from HackForums.net
  9. ''' </summary>
  10. ''' <remarks></remarks>
  11. #Region "Properties"
  12. #Region " Mouse States"
  13. Enum MouseState As Byte
  14. None = 0
  15. Over = 1
  16. Down = 2
  17. Block = 3
  18. End Enum
  19. #End Region
  20. #End Region
  21. Class ValleyTheme
  22. Inherits ContainerControl
  23. #Region "Variables"
  24. Private Cap As Boolean = False
  25. Private MousePoint As New Point(0, 0)
  26. Private MoveHeight = 36
  27. #End Region
  28. #Region "Properties"
  29. Public WriteOnly Property TransparencyKey As Color
  30. Set(ByVal value As Color)
  31. value = Color.Fuchsia
  32. End Set
  33. End Property
  34. Protected Overrides Sub OnCreateControl()
  35. MyBase.OnCreateControl()
  36. ParentForm.FormBorderStyle = FormBorderStyle.None
  37. ParentForm.AllowTransparency = False
  38. ParentForm.TransparencyKey = Color.Fuchsia
  39. ParentForm.FindForm.StartPosition = FormStartPosition.CenterScreen
  40. Dock = DockStyle.Fill
  41. Invalidate()
  42. End Sub
  43. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  44. MyBase.OnMouseDown(e)
  45. If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  46. Cap = True
  47. MousePoint = e.Location
  48. End If
  49. End Sub
  50. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  51. MyBase.OnMouseUp(e) : Cap = False
  52. End Sub
  53. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  54. MyBase.OnMouseMove(e)
  55. If Cap Then
  56. Parent.Location = MousePosition - MousePoint
  57. End If
  58. End Sub
  59. #End Region
  60. Sub New()
  61. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  62. DoubleBuffered = True
  63. BackColor = Color.FromArgb(242, 242, 242)
  64. Font = New Font("Segoe UI", 9)
  65. End Sub
  66. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  67. Dim G = e.Graphics
  68. G.Clear(Color.FromArgb(22, 22, 22))
  69. G.DrawRectangle(New Pen(Color.FromArgb(38, 38, 38)), New Rectangle(0, 0, Width - 1, Height - 1))
  70. G.FillRectangle(New LinearGradientBrush(New Point(0, 0), New Point(0, 36), Color.FromArgb(50, 50, 50), Color.FromArgb(47, 47, 47)), New Rectangle(1, 1, Width - 2, 36))
  71. G.FillRectangle(New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(45, 45, 45), Color.FromArgb(23, 23, 23)), New Rectangle(1, 36, Width - 2, Height - 46))
  72. G.DrawRectangle(New Pen(Color.FromArgb(38, 38, 38)), New Rectangle(9, 35, Width - 19, Height - 45))
  73. G.FillRectangle(New SolidBrush(BackColor), New Rectangle(10, 36, Width - 20, Height - 46))
  74. G.FillRectangle(New SolidBrush(Color.FromArgb(47, 47, 47)), New Rectangle(9, 35, 1, 1))
  75. G.FillRectangle(New SolidBrush(Color.FromArgb(47, 47, 47)), New Rectangle(Width - 10, 35, 1, 1))
  76. G.FillRectangle(New SolidBrush(Color.Fuchsia), New Rectangle(0, 0, 1, 1))
  77. G.FillRectangle(New SolidBrush(Color.Fuchsia), New Rectangle(Width - 1, 0, 1, 1))
  78. G.FillRectangle(New SolidBrush(Color.Fuchsia), New Rectangle(0, Height - 1, 1, 1))
  79. G.FillRectangle(New SolidBrush(Color.Fuchsia), New Rectangle(Width - 1, Height - 1, 1, 1))
  80. G.DrawString(FindForm.Text, New Font("Segoe UI", 10), New SolidBrush(Color.FromArgb(242, 242, 242)), New Point(12, 6))
  81. MyBase.OnPaint(e)
  82. End Sub
  83. End Class
  84. Class ValleyButton
  85. Inherits Control
  86. #Region "Variables"
  87. Private State As MouseState = MouseState.None
  88. #End Region
  89. #Region "Properties"
  90. #Region " Mouse States"
  91. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  92. MyBase.OnMouseDown(e)
  93. State = MouseState.Down : Invalidate()
  94. End Sub
  95. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  96. MyBase.OnMouseUp(e)
  97. State = MouseState.Over : Invalidate()
  98. End Sub
  99. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  100. MyBase.OnMouseEnter(e)
  101. State = MouseState.Over : Invalidate()
  102. End Sub
  103. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  104. MyBase.OnMouseLeave(e)
  105. State = MouseState.None : Invalidate()
  106. End Sub
  107. #End Region
  108. #End Region
  109. Sub New()
  110. Size = New Size(150, 50)
  111. End Sub
  112. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  113. Dim G = e.Graphics
  114. G.Clear(Color.FromArgb(34, 122, 247))
  115. G.DrawRectangle(New Pen(Color.FromArgb(42, 59, 252)), New Rectangle(0, 0, Width - 1, Height - 1))
  116. Select Case State
  117. Case MouseState.Over
  118. G.FillRectangle(New SolidBrush(Color.FromArgb(20, Color.White)), New Rectangle(1, 1, Width - 2, Height - 2))
  119. Case MouseState.Down
  120. G.FillRectangle(New SolidBrush(Color.FromArgb(20, Color.Black)), New Rectangle(1, 1, Width - 2, Height - 2))
  121. End Select
  122. G.FillRectangle(New SolidBrush(BackColor), New Rectangle(0, 0, 1, 1))
  123. G.FillRectangle(New SolidBrush(Color.FromArgb(134, 144, 253)), New Rectangle(0, 1, 1, 1))
  124. G.FillRectangle(New SolidBrush(Color.FromArgb(134, 144, 253)), New Rectangle(1, 0, 1, 1))
  125. G.FillRectangle(New SolidBrush(Color.FromArgb(56, 72, 251)), New Rectangle(0, 2, 1, 1))
  126. G.FillRectangle(New SolidBrush(Color.FromArgb(56, 72, 251)), New Rectangle(2, 0, 1, 1))
  127. G.FillRectangle(New SolidBrush(Color.FromArgb(62, 107, 249)), New Rectangle(1, 1, 1, 1))
  128. G.FillRectangle(New SolidBrush(BackColor), New Rectangle(Width - 1, 0, 1, 1))
  129. G.FillRectangle(New SolidBrush(Color.FromArgb(134, 144, 253)), New Rectangle(Width - 1, 1, 1, 1))
  130. G.FillRectangle(New SolidBrush(Color.FromArgb(134, 144, 253)), New Rectangle(Width - 2, 0, 1, 1))
  131. G.FillRectangle(New SolidBrush(Color.FromArgb(56, 72, 251)), New Rectangle(Width - 1, 2, 1, 1))
  132. G.FillRectangle(New SolidBrush(Color.FromArgb(56, 72, 251)), New Rectangle(Width - 3, 0, 1, 1))
  133. G.FillRectangle(New SolidBrush(Color.FromArgb(62, 107, 249)), New Rectangle(Width - 2, 1, 1, 1))
  134. G.FillRectangle(New SolidBrush(BackColor), New Rectangle(0, Height - 1, 1, 1))
  135. G.FillRectangle(New SolidBrush(Color.FromArgb(134, 144, 253)), New Rectangle(0, Height - 2, 1, 1))
  136. G.FillRectangle(New SolidBrush(Color.FromArgb(134, 144, 253)), New Rectangle(1, Height - 1, 1, 1))
  137. G.FillRectangle(New SolidBrush(Color.FromArgb(56, 72, 251)), New Rectangle(0, Height - 3, 1, 1))
  138. G.FillRectangle(New SolidBrush(Color.FromArgb(56, 72, 251)), New Rectangle(2, Height - 1, 1, 1))
  139. G.FillRectangle(New SolidBrush(Color.FromArgb(62, 107, 249)), New Rectangle(1, Height - 2, 1, 1))
  140. G.FillRectangle(New SolidBrush(BackColor), New Rectangle(Width - 1, Height - 1, 1, 1))
  141. G.FillRectangle(New SolidBrush(Color.FromArgb(134, 144, 253)), New Rectangle(Width - 1, Height - 2, 1, 1))
  142. G.FillRectangle(New SolidBrush(Color.FromArgb(134, 144, 253)), New Rectangle(Width - 2, Height - 1, 1, 1))
  143. G.FillRectangle(New SolidBrush(Color.FromArgb(56, 72, 251)), New Rectangle(Width - 1, Height - 3, 1, 1))
  144. G.FillRectangle(New SolidBrush(Color.FromArgb(56, 72, 251)), New Rectangle(Width - 3, Height - 1, 1, 1))
  145. G.FillRectangle(New SolidBrush(Color.FromArgb(62, 107, 249)), New Rectangle(Width - 2, Height - 2, 1, 1))
  146. G.DrawString(Text, Font, Brushes.White, New Point((Width / 2) - (TextRenderer.MeasureText(Text, Font).Width / 2), (Height / 2) - (TextRenderer.MeasureText(Text, Font).Height / 2)))
  147. MyBase.OnPaint(e)
  148. End Sub
  149. End Class
  150. <DefaultEvent("CheckedChanged")>
  151. Class ValleyRadioButton
  152. Inherits Control
  153. #Region " Variables"
  154. Private State As MouseState = MouseState.None
  155. Private W, H As Integer
  156. Private _Checked As Boolean
  157. #End Region
  158. #Region " Properties"
  159. Property Checked() As Boolean
  160. Get
  161. Return _Checked
  162. End Get
  163. Set(value As Boolean)
  164. _Checked = value
  165. InvalidateControls()
  166. RaiseEvent CheckedChanged(Me)
  167. Invalidate()
  168. End Set
  169. End Property
  170. Event CheckedChanged(ByVal sender As Object)
  171. Protected Overrides Sub OnClick(e As EventArgs)
  172. If Not _Checked Then Checked = True
  173. MyBase.OnClick(e)
  174. End Sub
  175. Private Sub InvalidateControls()
  176. If Not IsHandleCreated OrElse Not _Checked Then Return
  177. For Each C As Control In Parent.Controls
  178. If C IsNot Me AndAlso TypeOf C Is ValleyRadioButton Then
  179. DirectCast(C, ValleyRadioButton).Checked = False
  180. Invalidate()
  181. End If
  182. Next
  183. End Sub
  184. Protected Overrides Sub OnCreateControl()
  185. MyBase.OnCreateControl()
  186. InvalidateControls()
  187. End Sub
  188. Protected Overrides Sub OnResize(e As EventArgs)
  189. MyBase.OnResize(e)
  190. Height = 16
  191. End Sub
  192. #Region " Mouse States"
  193. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  194. MyBase.OnMouseDown(e)
  195. State = MouseState.Down : Invalidate()
  196. End Sub
  197. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  198. MyBase.OnMouseUp(e)
  199. State = MouseState.Over : Invalidate()
  200. End Sub
  201. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  202. MyBase.OnMouseEnter(e)
  203. State = MouseState.Over : Invalidate()
  204. End Sub
  205. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  206. MyBase.OnMouseLeave(e)
  207. State = MouseState.None : Invalidate()
  208. End Sub
  209. #End Region
  210. #End Region
  211. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  212. Dim G = e.Graphics
  213. G.SmoothingMode = 2
  214. G.TextRenderingHint = 5
  215. G.Clear(BackColor)
  216. G.DrawEllipse(New Pen(Color.FromArgb(191, 191, 191)), New Rectangle(0, 0, 15, 15))
  217. Select Case State
  218. Case MouseState.Over
  219. G.DrawEllipse(New Pen(Color.FromArgb(160, 160, 160)), New Rectangle(0, 0, 15, 15))
  220. End Select
  221. If Checked Then
  222. G.FillEllipse(New SolidBrush(Color.FromArgb(56, 56, 56)), New Rectangle(4, 4, 7, 7))
  223. End If
  224. G.DrawString(Text, Font, New SolidBrush(Color.FromArgb(131, 131, 131)), New Point(18, -3))
  225. MyBase.OnPaint(e)
  226. End Sub
  227. End Class
  228. <DefaultEvent("CheckedChanged")>
  229. Class ValleyCheckBox
  230. Inherits Control
  231. #Region "Variables"
  232. Private W, H As Integer
  233. Private State As MouseState = MouseState.None
  234. Private _Checked As Boolean
  235. #End Region
  236. #Region " Properties"
  237. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  238. MyBase.OnTextChanged(e)
  239. Invalidate()
  240. End Sub
  241. Property Checked() As Boolean
  242. Get
  243. Return _Checked
  244. End Get
  245. Set(ByVal value As Boolean)
  246. _Checked = value
  247. Invalidate()
  248. End Set
  249. End Property
  250. Event CheckedChanged(ByVal sender As Object)
  251. Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
  252. _Checked = Not _Checked
  253. RaiseEvent CheckedChanged(Me)
  254. MyBase.OnClick(e)
  255. End Sub
  256. Protected Overrides Sub OnResize(e As EventArgs)
  257. MyBase.OnResize(e)
  258. Height = 16
  259. End Sub
  260. #End Region
  261. #Region " Mouse States"
  262. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  263. MyBase.OnMouseDown(e)
  264. State = MouseState.Down : Invalidate()
  265. End Sub
  266. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  267. MyBase.OnMouseUp(e)
  268. State = MouseState.Over : Invalidate()
  269. End Sub
  270. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  271. MyBase.OnMouseEnter(e)
  272. State = MouseState.Over : Invalidate()
  273. End Sub
  274. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  275. MyBase.OnMouseLeave(e)
  276. State = MouseState.None : Invalidate()
  277. End Sub
  278. #End Region
  279. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  280. Dim G = e.Graphics
  281. G.Clear(BackColor)
  282. G.DrawRectangle(New Pen(Color.FromArgb(192, 192, 192)), New Rectangle(0, 0, 15, 15))
  283. Select Case State
  284. Case MouseState.Over
  285. G.DrawRectangle(New Pen(Color.FromArgb(160, 160, 160)), New Rectangle(0, 0, 15, 15))
  286. End Select
  287. If Checked Then
  288. G.DrawString("ü", New Font("Wingdings", 9), New SolidBrush(Color.FromArgb(56, 56, 56)), New Point(0, 2))
  289. End If
  290. G.FillRectangle(New SolidBrush(BackColor), New Rectangle(0, 0, 1, 1))
  291. G.FillRectangle(New SolidBrush(BackColor), New Rectangle(15, 15, 1, 1))
  292. G.FillRectangle(New SolidBrush(BackColor), New Rectangle(0, 15, 1, 1))
  293. G.FillRectangle(New SolidBrush(BackColor), New Rectangle(15, 0, 1, 1))
  294. G.DrawString(Text, Font, New SolidBrush(Color.FromArgb(131, 131, 131)), New Point(18, -3))
  295. MyBase.OnPaint(e)
  296. End Sub
  297. End Class
  298. Class ValleyProgressbar
  299. Inherits Control
  300. #Region " Variables"
  301. Private W, H As Integer
  302. Private _Value As Integer = 0
  303. Private _Maximum As Integer = 100
  304. #End Region
  305. #Region " Control"
  306. <Category("Control")>
  307. Public Property Maximum() As Integer
  308. Get
  309. Return _Maximum
  310. End Get
  311. Set(V As Integer)
  312. Select Case V
  313. Case Is < _Value
  314. _Value = V
  315. End Select
  316. _Maximum = V
  317. Invalidate()
  318. End Set
  319. End Property
  320. <Category("Control")>
  321. Public Property Value() As Integer
  322. Get
  323. Select Case _Value
  324. Case 0
  325. Return 0
  326. Invalidate()
  327. Case Else
  328. Return _Value
  329. Invalidate()
  330. End Select
  331. End Get
  332. Set(V As Integer)
  333. Select Case V
  334. Case Is > _Maximum
  335. V = _Maximum
  336. Invalidate()
  337. End Select
  338. _Value = V
  339. Invalidate()
  340. End Set
  341. End Property
  342. #End Region
  343. #Region "Events"
  344. Protected Overrides Sub OnResize(e As EventArgs)
  345. MyBase.OnResize(e)
  346. Height = 25
  347. End Sub
  348. Protected Overrides Sub CreateHandle()
  349. MyBase.CreateHandle()
  350. Height = 25
  351. End Sub
  352. Public Sub Increment(ByVal Amount As Integer)
  353. Value += Amount
  354. End Sub
  355. #End Region
  356. Sub New()
  357. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  358. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  359. DoubleBuffered = True
  360. End Sub
  361. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  362. Dim G = e.Graphics
  363. G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  364. G.SmoothingMode = SmoothingMode.HighQuality
  365. G.PixelOffsetMode = PixelOffsetMode.HighQuality
  366. G.Clear(Color.FromArgb(223, 223, 223))
  367. Dim ProgVal As Integer = CInt(_Value / _Maximum * Width)
  368. Select Value
  369. Case 0
  370. G.FillRectangle(New SolidBrush(Color.FromArgb(223, 223, 223)), New Rectangle(0, 0, Width, Height))
  371. G.FillRectangle(New SolidBrush(Color.FromArgb(50, 124, 244)), New Rectangle(0, 0, ProgVal - 1, Height))
  372. Case _Maximum
  373. G.FillRectangle(New SolidBrush(Color.FromArgb(223, 223, 223)), New Rectangle(0, 0, Width, Height))
  374. G.FillRectangle(New SolidBrush(Color.FromArgb(50, 124, 244)), New Rectangle(0, 0, ProgVal - 1, Height))
  375. Case Else
  376. G.FillRectangle(New SolidBrush(Color.FromArgb(223, 223, 223)), New Rectangle(0, 0, Width, Height))
  377. G.FillRectangle(New SolidBrush(Color.FromArgb(50, 124, 244)), New Rectangle(0, 0, ProgVal - 1, Height))
  378. End Select
  379. G.InterpolationMode = CType(7, InterpolationMode)
  380. MyBase.OnPaint(e)
  381. End Sub
  382. End Class
  383. <DefaultEvent("TextChanged")>
  384. Class ValleyTextBox
  385. Inherits Control
  386. #Region " Variables"
  387. Private W, H As Integer
  388. Private State As MouseState = MouseState.None
  389. Private WithEvents TB As Windows.Forms.TextBox
  390. #End Region
  391. #Region " Properties"
  392. #Region " TextBox Properties"
  393. Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
  394. <Category("Options")> _
  395. Property TextAlign() As HorizontalAlignment
  396. Get
  397. Return _TextAlign
  398. End Get
  399. Set(ByVal value As HorizontalAlignment)
  400. _TextAlign = value
  401. If TB IsNot Nothing Then
  402. TB.TextAlign = value
  403. End If
  404. End Set
  405. End Property
  406. Private _MaxLength As Integer = 32767
  407. <Category("Options")> _
  408. Property MaxLength() As Integer
  409. Get
  410. Return _MaxLength
  411. End Get
  412. Set(ByVal value As Integer)
  413. _MaxLength = value
  414. If TB IsNot Nothing Then
  415. TB.MaxLength = value
  416. End If
  417. End Set
  418. End Property
  419. Private _ReadOnly As Boolean
  420. <Category("Options")> _
  421. Property [ReadOnly]() As Boolean
  422. Get
  423. Return _ReadOnly
  424. End Get
  425. Set(ByVal value As Boolean)
  426. _ReadOnly = value
  427. If TB IsNot Nothing Then
  428. TB.ReadOnly = value
  429. End If
  430. End Set
  431. End Property
  432. Private _UseSystemPasswordChar As Boolean
  433. <Category("Options")> _
  434. Property UseSystemPasswordChar() As Boolean
  435. Get
  436. Return _UseSystemPasswordChar
  437. End Get
  438. Set(ByVal value As Boolean)
  439. _UseSystemPasswordChar = value
  440. If TB IsNot Nothing Then
  441. TB.UseSystemPasswordChar = value
  442. End If
  443. End Set
  444. End Property
  445. Private _Multiline As Boolean
  446. <Category("Options")> _
  447. Property Multiline() As Boolean
  448. Get
  449. Return _Multiline
  450. End Get
  451. Set(ByVal value As Boolean)
  452. _Multiline = value
  453. If TB IsNot Nothing Then
  454. TB.Multiline = value
  455. If value Then
  456. TB.Height = Height - 11
  457. Else
  458. Height = TB.Height + 11
  459. End If
  460. End If
  461. End Set
  462. End Property
  463. <Category("Options")> _
  464. Overrides Property Text As String
  465. Get
  466. Return MyBase.Text
  467. End Get
  468. Set(ByVal value As String)
  469. MyBase.Text = value
  470. If TB IsNot Nothing Then
  471. TB.Text = value
  472. End If
  473. End Set
  474. End Property
  475. <Category("Options")> _
  476. Overrides Property Font As Font
  477. Get
  478. Return MyBase.Font
  479. End Get
  480. Set(ByVal value As Font)
  481. MyBase.Font = value
  482. If TB IsNot Nothing Then
  483. TB.Font = value
  484. TB.Location = New Point(3, 5)
  485. TB.Width = Width - 6
  486. If Not _Multiline Then
  487. Height = TB.Height + 11
  488. End If
  489. End If
  490. End Set
  491. End Property
  492. Protected Overrides Sub OnCreateControl()
  493. MyBase.OnCreateControl()
  494. If Not Controls.Contains(TB) Then
  495. Controls.Add(TB)
  496. End If
  497. End Sub
  498. Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs)
  499. Text = TB.Text
  500. End Sub
  501. Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs)
  502. If e.Control AndAlso e.KeyCode = Keys.A Then
  503. TB.SelectAll()
  504. e.SuppressKeyPress = True
  505. End If
  506. If e.Control AndAlso e.KeyCode = Keys.C Then
  507. TB.Copy()
  508. e.SuppressKeyPress = True
  509. End If
  510. End Sub
  511. Protected Overrides Sub OnResize(ByVal e As EventArgs)
  512. TB.Location = New Point(5, 5)
  513. TB.Width = Width - 10
  514. If _Multiline Then
  515. TB.Height = Height - 11
  516. Else
  517. Height = TB.Height + 11
  518. End If
  519. MyBase.OnResize(e)
  520. End Sub
  521. #End Region
  522. #Region " Colors"
  523. <Category("Colors")> _
  524. Public Property TextColor As Color
  525. Get
  526. Return _TextColor
  527. End Get
  528. Set(value As Color)
  529. _TextColor = value
  530. End Set
  531. End Property
  532. Public Overrides Property ForeColor() As Color
  533. Get
  534. Return _TextColor
  535. End Get
  536. Set(value As Color)
  537. _TextColor = value
  538. End Set
  539. End Property
  540. #End Region
  541. #Region " Mouse States"
  542. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  543. MyBase.OnMouseDown(e)
  544. State = MouseState.Down : Invalidate()
  545. End Sub
  546. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  547. MyBase.OnMouseUp(e)
  548. State = MouseState.Over : TB.Focus() : Invalidate()
  549. End Sub
  550. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  551. MyBase.OnMouseEnter(e)
  552. State = MouseState.Over : TB.Focus() : Invalidate()
  553. End Sub
  554. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  555. MyBase.OnMouseLeave(e)
  556. State = MouseState.None : Invalidate()
  557. End Sub
  558. #End Region
  559. #End Region
  560. #Region " Colors"
  561. Private _BaseColor As Color = BackColor
  562. Private _TextColor As Color = Color.FromArgb(131, 131, 131)
  563. Private _BorderColor As Color = Color.FromArgb(191, 191, 191)
  564. #End Region
  565. Sub New()
  566. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  567. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  568. ControlStyles.SupportsTransparentBackColor, True)
  569. DoubleBuffered = True
  570. BackColor = Color.Transparent
  571. TB = New Windows.Forms.TextBox
  572. TB.Font = Font
  573. TB.Text = Text
  574. TB.BackColor = _BaseColor
  575. TB.ForeColor = _TextColor
  576. TB.MaxLength = _MaxLength
  577. TB.Multiline = _Multiline
  578. TB.ReadOnly = _ReadOnly
  579. TB.UseSystemPasswordChar = _UseSystemPasswordChar
  580. TB.BorderStyle = BorderStyle.None
  581. TB.Location = New Point(5, 5)
  582. TB.Width = Width - 10
  583. TB.Cursor = Cursors.IBeam
  584. If _Multiline Then
  585. TB.Height = Height - 11
  586. Else
  587. Height = TB.Height + 11
  588. End If
  589. AddHandler TB.TextChanged, AddressOf OnBaseTextChanged
  590. AddHandler TB.KeyDown, AddressOf OnBaseKeyDown
  591. End Sub
  592. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  593. Dim G = e.Graphics
  594. G.Clear(Color.FromArgb(242, 242, 242))
  595. G.DrawRectangle(New Pen(_BorderColor), New Rectangle(0, 0, Width - 1, Height - 1))
  596. MyBase.OnPaint(e)
  597. End Sub
  598. End Class
  599. Class ValleyClose
  600. Inherits Control
  601. #Region " Variables"
  602. Private State As MouseState = MouseState.None
  603. Private x As Integer
  604. #End Region
  605. #Region " Properties"
  606. #Region " Mouse States"
  607. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  608. MyBase.OnMouseEnter(e)
  609. State = MouseState.Over : Invalidate()
  610. End Sub
  611. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  612. MyBase.OnMouseDown(e)
  613. State = MouseState.Down : Invalidate()
  614. End Sub
  615. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  616. MyBase.OnMouseLeave(e)
  617. State = MouseState.None : Invalidate()
  618. End Sub
  619. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  620. MyBase.OnMouseUp(e)
  621. State = MouseState.Over : Invalidate()
  622. End Sub
  623. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  624. MyBase.OnMouseMove(e)
  625. x = e.X : Invalidate()
  626. End Sub
  627. Protected Overrides Sub OnClick(e As EventArgs)
  628. MyBase.OnClick(e)
  629. Environment.Exit(0)
  630. End Sub
  631. #End Region
  632. Protected Overrides Sub OnResize(e As EventArgs)
  633. MyBase.OnResize(e)
  634. Size = New Size(16, 16)
  635. End Sub
  636. #End Region
  637. Sub New()
  638. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  639. SetStyle(ControlStyles.Opaque, True)
  640. Anchor = AnchorStyles.Top Or AnchorStyles.Right
  641. End Sub
  642. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  643. Dim G = e.Graphics
  644. G.Clear(Color.FromArgb(49, 49, 49))
  645. G.SmoothingMode = SmoothingMode.HighQuality
  646. G.FillEllipse(New SolidBrush(Color.FromArgb(39, 39, 39)), New Rectangle(0, 0, 15, 15))
  647. G.FillEllipse(New SolidBrush(Color.FromArgb(254, 97, 82)), New Rectangle(2, 2, 11, 11))
  648. Select Case State
  649. Case MouseState.Over
  650. G.FillEllipse(New SolidBrush(Color.FromArgb(40, Color.White)), New Rectangle(2, 2, 11, 11))
  651. Case MouseState.Down
  652. G.FillEllipse(New SolidBrush(Color.FromArgb(40, Color.Black)), New Rectangle(2, 2, 11, 11))
  653. End Select
  654. MyBase.OnPaint(e)
  655. End Sub
  656. End Class
  657. Class ValleyMax
  658. Inherits Control
  659. #Region " Variables"
  660. Private State As MouseState = MouseState.None
  661. Private x As Integer
  662. #End Region
  663. #Region " Properties"
  664. #Region " Mouse States"
  665. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  666. MyBase.OnMouseEnter(e)
  667. State = MouseState.Over : Invalidate()
  668. End Sub
  669. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  670. MyBase.OnMouseDown(e)
  671. State = MouseState.Down : Invalidate()
  672. End Sub
  673. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  674. MyBase.OnMouseLeave(e)
  675. State = MouseState.None : Invalidate()
  676. End Sub
  677. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  678. MyBase.OnMouseUp(e)
  679. State = MouseState.Over : Invalidate()
  680. End Sub
  681. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  682. MyBase.OnMouseMove(e)
  683. x = e.X : Invalidate()
  684. End Sub
  685. Protected Overrides Sub OnClick(e As EventArgs)
  686. MyBase.OnClick(e)
  687. Select Case FindForm.WindowState
  688. Case FormWindowState.Maximized
  689. FindForm.WindowState = FormWindowState.Normal
  690. Case FormWindowState.Normal
  691. FindForm.WindowState = FormWindowState.Maximized
  692. End Select
  693. End Sub
  694. #End Region
  695. Protected Overrides Sub OnResize(e As EventArgs)
  696. MyBase.OnResize(e)
  697. Size = New Size(16, 16)
  698. End Sub
  699. #End Region
  700. Sub New()
  701. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  702. SetStyle(ControlStyles.Opaque, True)
  703. Anchor = AnchorStyles.Top Or AnchorStyles.Right
  704. End Sub
  705. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  706. Dim G = e.Graphics
  707. G.Clear(Color.FromArgb(49, 49, 49))
  708. G.SmoothingMode = SmoothingMode.HighQuality
  709. G.FillEllipse(New SolidBrush(Color.FromArgb(39, 39, 39)), New Rectangle(0, 0, 15, 15))
  710. G.FillEllipse(New SolidBrush(Color.FromArgb(254, 190, 4)), New Rectangle(2, 2, 11, 11))
  711. Select Case State
  712. Case MouseState.Over
  713. G.FillEllipse(New SolidBrush(Color.FromArgb(40, Color.White)), New Rectangle(2, 2, 11, 11))
  714. Case MouseState.Down
  715. G.FillEllipse(New SolidBrush(Color.FromArgb(40, Color.Black)), New Rectangle(2, 2, 11, 11))
  716. End Select
  717. MyBase.OnPaint(e)
  718. End Sub
  719. End Class
  720. Class ValleyMini
  721. Inherits Control
  722. #Region " Variables"
  723. Private State As MouseState = MouseState.None
  724. Private x As Integer
  725. #End Region
  726. #Region " Properties"
  727. #Region " Mouse States"
  728. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  729. MyBase.OnMouseEnter(e)
  730. State = MouseState.Over : Invalidate()
  731. End Sub
  732. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  733. MyBase.OnMouseDown(e)
  734. State = MouseState.Down : Invalidate()
  735. End Sub
  736. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  737. MyBase.OnMouseLeave(e)
  738. State = MouseState.None : Invalidate()
  739. End Sub
  740. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  741. MyBase.OnMouseUp(e)
  742. State = MouseState.Over : Invalidate()
  743. End Sub
  744. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  745. MyBase.OnMouseMove(e)
  746. x = e.X : Invalidate()
  747. End Sub
  748. Protected Overrides Sub OnClick(e As EventArgs)
  749. MyBase.OnClick(e)
  750. Select Case FindForm.WindowState
  751. Case FormWindowState.Normal
  752. FindForm.WindowState = FormWindowState.Minimized
  753. Case FormWindowState.Maximized
  754. FindForm.WindowState = FormWindowState.Minimized
  755. End Select
  756. End Sub
  757. #End Region
  758. Protected Overrides Sub OnResize(e As EventArgs)
  759. MyBase.OnResize(e)
  760. Size = New Size(16, 16)
  761. End Sub
  762. #End Region
  763. Sub New()
  764. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  765. SetStyle(ControlStyles.Opaque, True)
  766. Anchor = AnchorStyles.Top Or AnchorStyles.Right
  767. End Sub
  768. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  769. Dim G = e.Graphics
  770. G.Clear(Color.FromArgb(49, 49, 49))
  771. G.SmoothingMode = SmoothingMode.HighQuality
  772. G.FillEllipse(New SolidBrush(Color.FromArgb(39, 39, 39)), New Rectangle(0, 0, 15, 15))
  773. G.FillEllipse(New SolidBrush(Color.FromArgb(23, 205, 58)), New Rectangle(2, 2, 11, 11))
  774. Select Case State
  775. Case MouseState.Over
  776. G.FillEllipse(New SolidBrush(Color.FromArgb(40, Color.White)), New Rectangle(2, 2, 11, 11))
  777. Case MouseState.Down
  778. G.FillEllipse(New SolidBrush(Color.FromArgb(40, Color.Black)), New Rectangle(2, 2, 11, 11))
  779. End Select
  780. MyBase.OnPaint(e)
  781. End Sub
  782. End Class

comments powered by Disqus