Advertisement
OverKiller

Noob GOldenArmy

Mar 1st, 2012
473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 45.40 KB | None | 0 0
  1. Imports System, System.IO, System.Collections.Generic
  2. Imports System.Drawing, System.Drawing.Drawing2D
  3. Imports System.ComponentModel, System.Windows.Forms
  4.  
  5. '------------------
  6. 'Theme base for NOOB GOLDEN ARMY
  7. '------------------
  8.  
  9. MustInherit Class ThemeContainer152
  10. Inherits ContainerControl
  11.  
  12. Protected G As Graphics
  13.  
  14. Sub New()
  15. SetStyle(DirectCast(139270, ControlStyles), True)
  16. _ImageSize = Size.Empty
  17.  
  18. MeasureBitmap = New Bitmap(1, 1)
  19. MeasureGraphics = Graphics.FromImage(MeasureBitmap)
  20.  
  21. Font = New Font("Verdana", 8S)
  22.  
  23. InvalidateCustimization()
  24. End Sub
  25.  
  26. Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
  27. If Not _LockWidth = 0 Then width = _LockWidth
  28. If Not _LockHeight = 0 Then height = _LockHeight
  29. MyBase.SetBoundsCore(x, y, width, height, specified)
  30. End Sub
  31.  
  32. Private Header As Rectangle
  33. Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  34. If _Movable AndAlso Not _ControlMode Then Header = New Rectangle(7, 7, Width - 14, _MoveHeight - 7)
  35. Invalidate()
  36. MyBase.OnSizeChanged(e)
  37. End Sub
  38.  
  39. Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  40. If Width = 0 OrElse Height = 0 Then Return
  41. G = e.Graphics
  42. PaintHook()
  43. End Sub
  44.  
  45. Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  46. InvalidateCustimization()
  47. ColorHook()
  48.  
  49. If Not _LockWidth = 0 Then Width = _LockWidth
  50. If Not _LockHeight = 0 Then Height = _LockHeight
  51. If Not _ControlMode Then MyBase.Dock = DockStyle.Fill
  52.  
  53. MyBase.OnHandleCreated(e)
  54. End Sub
  55.  
  56. Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
  57. MyBase.OnParentChanged(e)
  58.  
  59. If Parent Is Nothing Then Return
  60. _IsParentForm = TypeOf Parent Is Form
  61.  
  62. If Not _ControlMode Then
  63. InitializeMessages()
  64.  
  65. If _IsParentForm Then
  66. ParentForm.FormBorderStyle = _BorderStyle
  67. ParentForm.TransparencyKey = _TransparencyKey
  68. End If
  69.  
  70. Parent.BackColor = BackColor
  71. End If
  72.  
  73. OnCreation()
  74. End Sub
  75.  
  76. Protected Overridable Sub OnCreation()
  77. End Sub
  78.  
  79. #Region " Sizing and Movement "
  80.  
  81. Protected State As MouseState
  82. Private Sub SetState(ByVal current As MouseState)
  83. State = current
  84. Invalidate()
  85. End Sub
  86.  
  87. Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  88. If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized) Then
  89. If _Sizable AndAlso Not _ControlMode Then InvalidateMouse()
  90. End If
  91.  
  92. MyBase.OnMouseMove(e)
  93. End Sub
  94.  
  95. Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
  96. If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
  97. MyBase.OnEnabledChanged(e)
  98. End Sub
  99.  
  100. Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  101. SetState(MouseState.Over)
  102. MyBase.OnMouseEnter(e)
  103. End Sub
  104.  
  105. Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  106. SetState(MouseState.Over)
  107. MyBase.OnMouseUp(e)
  108. End Sub
  109.  
  110. Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  111. SetState(MouseState.None)
  112.  
  113. If GetChildAtPoint(PointToClient(MousePosition)) IsNot Nothing Then
  114. If _Sizable AndAlso Not _ControlMode Then
  115. Cursor = Cursors.Default
  116. Previous = 0
  117. End If
  118. End If
  119.  
  120. MyBase.OnMouseLeave(e)
  121. End Sub
  122.  
  123. Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  124. If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
  125.  
  126. If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized OrElse _ControlMode) Then
  127. If _Movable AndAlso Header.Contains(e.Location) Then
  128. Capture = False
  129. WM_LMBUTTONDOWN = True
  130. DefWndProc(Messages(0))
  131. ElseIf _Sizable AndAlso Not Previous = 0 Then
  132. Capture = False
  133. WM_LMBUTTONDOWN = True
  134. DefWndProc(Messages(Previous))
  135. End If
  136. End If
  137.  
  138. MyBase.OnMouseDown(e)
  139. End Sub
  140.  
  141. Private WM_LMBUTTONDOWN As Boolean
  142. Protected Overrides Sub WndProc(ByRef m As Message)
  143. MyBase.WndProc(m)
  144.  
  145. If WM_LMBUTTONDOWN AndAlso m.Msg = 513 Then
  146. WM_LMBUTTONDOWN = False
  147.  
  148. SetState(MouseState.Over)
  149. If Not _SmartBounds Then Return
  150.  
  151. If IsParentMdi Then
  152. CorrectBounds(New Rectangle(Point.Empty, Parent.Parent.Size))
  153. Else
  154. CorrectBounds(Screen.FromControl(Parent).WorkingArea)
  155. End If
  156. End If
  157. End Sub
  158.  
  159. Private GetIndexPoint As Point
  160. Private B1, B2, B3, B4 As Boolean
  161. Private Function GetIndex() As Integer
  162. GetIndexPoint = PointToClient(MousePosition)
  163. B1 = GetIndexPoint.X < 7
  164. B2 = GetIndexPoint.X > Width - 7
  165. B3 = GetIndexPoint.Y < 7
  166. B4 = GetIndexPoint.Y > Height - 7
  167.  
  168. If B1 AndAlso B3 Then Return 4
  169. If B1 AndAlso B4 Then Return 7
  170. If B2 AndAlso B3 Then Return 5
  171. If B2 AndAlso B4 Then Return 8
  172. If B1 Then Return 1
  173. If B2 Then Return 2
  174. If B3 Then Return 3
  175. If B4 Then Return 6
  176. Return 0
  177. End Function
  178.  
  179. Private Current, Previous As Integer
  180. Private Sub InvalidateMouse()
  181. Current = GetIndex()
  182. If Current = Previous Then Return
  183.  
  184. Previous = Current
  185. Select Case Previous
  186. Case 0
  187. Cursor = Cursors.Default
  188. Case 1, 2
  189. Cursor = Cursors.SizeWE
  190. Case 3, 6
  191. Cursor = Cursors.SizeNS
  192. Case 4, 8
  193. Cursor = Cursors.SizeNWSE
  194. Case 5, 7
  195. Cursor = Cursors.SizeNESW
  196. End Select
  197. End Sub
  198.  
  199. Private Messages(8) As Message
  200. Private Sub InitializeMessages()
  201. Messages(0) = Message.Create(Parent.Handle, 161, New IntPtr(2), IntPtr.Zero)
  202. For I As Integer = 1 To 8
  203. Messages(I) = Message.Create(Parent.Handle, 161, New IntPtr(I + 9), IntPtr.Zero)
  204. Next
  205. End Sub
  206.  
  207. Private Sub CorrectBounds(ByVal bounds As Rectangle)
  208. If Parent.Width > bounds.Width Then Parent.Width = bounds.Width
  209. If Parent.Height > bounds.Height Then Parent.Height = bounds.Height
  210.  
  211. Dim X As Integer = Parent.Location.X
  212. Dim Y As Integer = Parent.Location.Y
  213.  
  214. If X < bounds.X Then X = bounds.X
  215. If Y < bounds.Y Then Y = bounds.Y
  216.  
  217. Dim Width As Integer = bounds.X + bounds.Width
  218. Dim Height As Integer = bounds.Y + bounds.Height
  219.  
  220. If X + Parent.Width > Width Then X = Width - Parent.Width
  221. If Y + Parent.Height > Height Then Y = Height - Parent.Height
  222.  
  223. Parent.Location = New Point(X, Y)
  224. End Sub
  225.  
  226. #End Region
  227.  
  228.  
  229. #Region " Property Overrides "
  230.  
  231. Overrides Property Dock As DockStyle
  232. Get
  233. Return MyBase.Dock
  234. End Get
  235. Set(ByVal value As DockStyle)
  236. If Not _ControlMode Then Return
  237. MyBase.Dock = value
  238. End Set
  239. End Property
  240.  
  241. <Category("Misc")> _
  242. Overrides Property BackColor() As Color
  243. Get
  244. Return MyBase.BackColor
  245. End Get
  246. Set(ByVal value As Color)
  247. If value = BackColor Then Return
  248. MyBase.BackColor = value
  249.  
  250. If Parent IsNot Nothing Then
  251. If Not _ControlMode Then Parent.BackColor = value
  252. ColorHook()
  253. End If
  254. End Set
  255. End Property
  256.  
  257. Overrides Property MinimumSize As Size
  258. Get
  259. Return MyBase.MinimumSize
  260. End Get
  261. Set(ByVal value As Size)
  262. MyBase.MinimumSize = value
  263. If Parent IsNot Nothing Then Parent.MinimumSize = value
  264. End Set
  265. End Property
  266.  
  267. Overrides Property MaximumSize As Size
  268. Get
  269. Return MyBase.MaximumSize
  270. End Get
  271. Set(ByVal value As Size)
  272. MyBase.MaximumSize = value
  273. If Parent IsNot Nothing Then Parent.MaximumSize = value
  274. End Set
  275. End Property
  276.  
  277. Overrides Property Text() As String
  278. Get
  279. Return MyBase.Text
  280. End Get
  281. Set(ByVal value As String)
  282. MyBase.Text = value
  283. Invalidate()
  284. End Set
  285. End Property
  286.  
  287. Overrides Property Font() As Font
  288. Get
  289. Return MyBase.Font
  290. End Get
  291. Set(ByVal value As Font)
  292. MyBase.Font = value
  293. Invalidate()
  294. End Set
  295. End Property
  296.  
  297. <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  298. Overrides Property ForeColor() As Color
  299. Get
  300. Return Color.Empty
  301. End Get
  302. Set(ByVal value As Color)
  303. End Set
  304. End Property
  305. <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  306. Overrides Property BackgroundImage() As Image
  307. Get
  308. Return Nothing
  309. End Get
  310. Set(ByVal value As Image)
  311. End Set
  312. End Property
  313. <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  314. Overrides Property BackgroundImageLayout() As ImageLayout
  315. Get
  316. Return ImageLayout.None
  317. End Get
  318. Set(ByVal value As ImageLayout)
  319. End Set
  320. End Property
  321.  
  322. #End Region
  323.  
  324. #Region " Properties "
  325.  
  326. Private _SmartBounds As Boolean = True
  327. Property SmartBounds() As Boolean
  328. Get
  329. Return _SmartBounds
  330. End Get
  331. Set(ByVal value As Boolean)
  332. _SmartBounds = value
  333. End Set
  334. End Property
  335.  
  336. Private _Movable As Boolean = True
  337. Property Movable() As Boolean
  338. Get
  339. Return _Movable
  340. End Get
  341. Set(ByVal value As Boolean)
  342. _Movable = value
  343. End Set
  344. End Property
  345.  
  346. Private _Sizable As Boolean = True
  347. Property Sizable() As Boolean
  348. Get
  349. Return _Sizable
  350. End Get
  351. Set(ByVal value As Boolean)
  352. _Sizable = value
  353. End Set
  354. End Property
  355.  
  356. Private _TransparencyKey As Color
  357. Property TransparencyKey() As Color
  358. Get
  359. If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.TransparencyKey Else Return _TransparencyKey
  360. End Get
  361. Set(ByVal value As Color)
  362. If value = _TransparencyKey Then Return
  363. _TransparencyKey = value
  364.  
  365. If _IsParentForm AndAlso Not _ControlMode Then
  366. ParentForm.TransparencyKey = value
  367. ColorHook()
  368. End If
  369. End Set
  370. End Property
  371.  
  372. Private _BorderStyle As FormBorderStyle
  373. Property BorderStyle() As FormBorderStyle
  374. Get
  375. If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.FormBorderStyle Else Return _BorderStyle
  376. End Get
  377. Set(ByVal value As FormBorderStyle)
  378. _BorderStyle = value
  379.  
  380. If _IsParentForm AndAlso Not _ControlMode Then
  381. ParentForm.FormBorderStyle = value
  382.  
  383. If Not value = FormBorderStyle.None Then
  384. Movable = False
  385. Sizable = False
  386. End If
  387. End If
  388. End Set
  389. End Property
  390.  
  391. Private _NoRounding As Boolean
  392. Property NoRounding() As Boolean
  393. Get
  394. Return _NoRounding
  395. End Get
  396. Set(ByVal v As Boolean)
  397. _NoRounding = v
  398. Invalidate()
  399. End Set
  400. End Property
  401.  
  402. Private _Image As Image
  403. Property Image() As Image
  404. Get
  405. Return _Image
  406. End Get
  407. Set(ByVal value As Image)
  408. If value Is Nothing Then _ImageSize = Size.Empty Else _ImageSize = value.Size
  409.  
  410. _Image = value
  411. Invalidate()
  412. End Set
  413. End Property
  414.  
  415. Private _ImageSize As Size
  416. Protected ReadOnly Property ImageSize() As Size
  417. Get
  418. Return _ImageSize
  419. End Get
  420. End Property
  421.  
  422. Private _IsParentForm As Boolean
  423. Protected ReadOnly Property IsParentForm As Boolean
  424. Get
  425. Return _IsParentForm
  426. End Get
  427. End Property
  428.  
  429. Protected ReadOnly Property IsParentMdi As Boolean
  430. Get
  431. If Parent Is Nothing Then Return False
  432. Return Parent.Parent IsNot Nothing
  433. End Get
  434. End Property
  435.  
  436. Private _LockWidth As Integer
  437. Protected Property LockWidth() As Integer
  438. Get
  439. Return _LockWidth
  440. End Get
  441. Set(ByVal value As Integer)
  442. _LockWidth = value
  443. If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
  444. End Set
  445. End Property
  446.  
  447. Private _LockHeight As Integer
  448. Protected Property LockHeight() As Integer
  449. Get
  450. Return _LockHeight
  451. End Get
  452. Set(ByVal value As Integer)
  453. _LockHeight = value
  454. If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
  455. End Set
  456. End Property
  457.  
  458. Private _MoveHeight As Integer = 24
  459. Protected Property MoveHeight() As Integer
  460. Get
  461. Return _MoveHeight
  462. End Get
  463. Set(ByVal v As Integer)
  464. If v < 8 Then Return
  465. Header = New Rectangle(7, 7, Width - 14, v - 7)
  466. _MoveHeight = v
  467. Invalidate()
  468. End Set
  469. End Property
  470.  
  471. Private _ControlMode As Boolean
  472. Protected Property ControlMode() As Boolean
  473. Get
  474. Return _ControlMode
  475. End Get
  476. Set(ByVal v As Boolean)
  477. _ControlMode = v
  478. End Set
  479. End Property
  480.  
  481. Private Items As New Dictionary(Of String, Color)
  482. <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
  483. Property Colors() As Bloom()
  484. Get
  485. Dim T As New List(Of Bloom)
  486. Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
  487.  
  488. While E.MoveNext
  489. T.Add(New Bloom(E.Current.Key, E.Current.Value))
  490. End While
  491.  
  492. Return T.ToArray
  493. End Get
  494. Set(ByVal value As Bloom())
  495. For Each B As Bloom In value
  496. If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
  497. Next
  498.  
  499. InvalidateCustimization()
  500. ColorHook()
  501. Invalidate()
  502. End Set
  503. End Property
  504.  
  505. Private _Customization As String
  506. Property Customization() As String
  507. Get
  508. Return _Customization
  509. End Get
  510. Set(ByVal value As String)
  511. If value = _Customization Then Return
  512.  
  513. Dim Data As Byte()
  514. Dim Items As Bloom() = Colors
  515.  
  516. Try
  517. Data = Convert.FromBase64String(value)
  518. For I As Integer = 0 To Items.Length - 1
  519. Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
  520. Next
  521. Catch
  522. Return
  523. End Try
  524.  
  525. _Customization = value
  526.  
  527. Colors = Items
  528. ColorHook()
  529. Invalidate()
  530. End Set
  531. End Property
  532.  
  533. #End Region
  534.  
  535. #Region " Property Helpers "
  536.  
  537. Protected Function GetColor(ByVal name As String) As Color
  538. Return Items(name)
  539. End Function
  540.  
  541. Protected Sub SetColor(ByVal name As String, ByVal value As Color)
  542. If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
  543. End Sub
  544. Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  545. SetColor(name, Color.FromArgb(r, g, b))
  546. End Sub
  547. Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  548. SetColor(name, Color.FromArgb(a, r, g, b))
  549. End Sub
  550. Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
  551. SetColor(name, Color.FromArgb(a, value))
  552. End Sub
  553.  
  554. Private Sub InvalidateCustimization()
  555. Dim M As New MemoryStream(Items.Count * 4)
  556.  
  557. For Each B As Bloom In Colors
  558. M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
  559. Next
  560.  
  561. M.Close()
  562. _Customization = Convert.ToBase64String(M.ToArray)
  563. End Sub
  564.  
  565. #End Region
  566.  
  567.  
  568. #Region " User Hooks "
  569.  
  570. Protected MustOverride Sub ColorHook()
  571. Protected MustOverride Sub PaintHook()
  572.  
  573. #End Region
  574.  
  575.  
  576. #Region " Center Overloads "
  577.  
  578. Private CenterReturn As Point
  579.  
  580. Protected Function Center(ByVal r1 As Rectangle, ByVal s1 As Size) As Point
  581. CenterReturn = New Point((r1.Width \ 2 - s1.Width \ 2) + r1.X, (r1.Height \ 2 - s1.Height \ 2) + r1.Y)
  582. Return CenterReturn
  583. End Function
  584. Protected Function Center(ByVal r1 As Rectangle, ByVal r2 As Rectangle) As Point
  585. Return Center(r1, r2.Size)
  586. End Function
  587.  
  588. Protected Function Center(ByVal w1 As Integer, ByVal h1 As Integer, ByVal w2 As Integer, ByVal h2 As Integer) As Point
  589. CenterReturn = New Point(w1 \ 2 - w2 \ 2, h1 \ 2 - h2 \ 2)
  590. Return CenterReturn
  591. End Function
  592.  
  593. Protected Function Center(ByVal s1 As Size, ByVal s2 As Size) As Point
  594. Return Center(s1.Width, s1.Height, s2.Width, s2.Height)
  595. End Function
  596.  
  597. Protected Function Center(ByVal r1 As Rectangle) As Point
  598. Return Center(ClientRectangle.Width, ClientRectangle.Height, r1.Width, r1.Height)
  599. End Function
  600. Protected Function Center(ByVal s1 As Size) As Point
  601. Return Center(Width, Height, s1.Width, s1.Height)
  602. End Function
  603. Protected Function Center(ByVal w1 As Integer, ByVal h1 As Integer) As Point
  604. Return Center(Width, Height, w1, h1)
  605. End Function
  606.  
  607. #End Region
  608.  
  609. #Region " Measure Overloads "
  610.  
  611. Private MeasureBitmap As Bitmap
  612. Private MeasureGraphics As Graphics
  613.  
  614. Protected Function Measure(ByVal text As String) As Size
  615. Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
  616. End Function
  617. Protected Function Measure() As Size
  618. Return MeasureGraphics.MeasureString(Text, Font).ToSize
  619. End Function
  620.  
  621. #End Region
  622.  
  623. #Region " DrawCorners Overloads "
  624.  
  625. Private DrawCornersBrush As SolidBrush
  626.  
  627. Protected Sub DrawCorners(ByVal c1 As Color)
  628. DrawCorners(c1, 0, 0, Width, Height)
  629. End Sub
  630. Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
  631. DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
  632. End Sub
  633. Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  634. If _NoRounding Then Return
  635. DrawCornersBrush = New SolidBrush(c1)
  636. G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
  637. G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
  638. G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
  639. G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
  640. End Sub
  641.  
  642. #End Region
  643.  
  644. #Region " DrawBorders Overloads "
  645.  
  646. 'TODO: Remove triple overload?
  647.  
  648. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
  649. DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  650. End Sub
  651. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
  652. DrawBorders(p1, 0, 0, Width, Height, offset)
  653. End Sub
  654. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
  655. DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
  656. End Sub
  657.  
  658. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  659. G.DrawRectangle(p1, x, y, width - 1, height - 1)
  660. End Sub
  661. Protected Sub DrawBorders(ByVal p1 As Pen)
  662. DrawBorders(p1, 0, 0, Width, Height)
  663. End Sub
  664. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
  665. DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
  666. End Sub
  667.  
  668. #End Region
  669.  
  670. #Region " DrawText Overloads "
  671.  
  672. 'TODO: Remove triple overloads?
  673.  
  674. Private DrawTextPoint As Point
  675. Private DrawTextSize As Size
  676.  
  677. Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  678. DrawText(b1, Text, a, x, y)
  679. End Sub
  680. Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
  681. DrawText(b1, Text, p1.X, p1.Y)
  682. End Sub
  683. Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  684. DrawText(b1, Text, x, y)
  685. End Sub
  686.  
  687. Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  688. If text.Length = 0 Then Return
  689. DrawTextSize = Measure(text)
  690.  
  691. If _ControlMode Then
  692. DrawTextPoint = Center(DrawTextSize)
  693. Else
  694. DrawTextPoint = New Point(Width \ 2 - DrawTextSize.Width \ 2, MoveHeight \ 2 - DrawTextSize.Height \ 2)
  695. End If
  696.  
  697. Select Case a
  698. Case HorizontalAlignment.Left
  699. DrawText(b1, text, x, DrawTextPoint.Y + y)
  700. Case HorizontalAlignment.Center
  701. DrawText(b1, text, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  702. Case HorizontalAlignment.Right
  703. DrawText(b1, text, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  704. End Select
  705. End Sub
  706. Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal p1 As Point)
  707. DrawText(b1, text, p1.X, p1.Y)
  708. End Sub
  709. Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal x As Integer, ByVal y As Integer)
  710. If text.Length = 0 Then Return
  711. G.DrawString(text, Font, b1, x, y)
  712. End Sub
  713.  
  714. #End Region
  715.  
  716. #Region " DrawImage Overloads "
  717.  
  718. 'TODO: Remove triple overloads?
  719.  
  720. Private DrawImagePoint As Point
  721.  
  722. Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  723. DrawImage(_Image, a, x, y)
  724. End Sub
  725. Protected Sub DrawImage(ByVal p1 As Point)
  726. DrawImage(_Image, p1.X, p1.Y)
  727. End Sub
  728. Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
  729. DrawImage(_Image, x, y)
  730. End Sub
  731.  
  732. Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  733. If image Is Nothing Then Return
  734.  
  735. If _ControlMode Then
  736. DrawImagePoint = Center(image.Size)
  737. Else
  738. DrawImagePoint = New Point(Width \ 2 - image.Width \ 2, MoveHeight \ 2 - image.Height \ 2)
  739. End If
  740.  
  741. Select Case a
  742. Case HorizontalAlignment.Left
  743. DrawImage(image, x, DrawImagePoint.Y + y)
  744. Case HorizontalAlignment.Center
  745. DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y)
  746. Case HorizontalAlignment.Right
  747. DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y)
  748. End Select
  749. End Sub
  750. Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
  751. DrawImage(image, p1.X, p1.Y)
  752. End Sub
  753. Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
  754. If image Is Nothing Then Return
  755. G.DrawImage(image, x, y, image.Width, image.Height)
  756. End Sub
  757.  
  758. #End Region
  759.  
  760. #Region " DrawGradient Overloads "
  761.  
  762. 'TODO: Remove triple overload?
  763.  
  764. Private DrawGradientBrush As LinearGradientBrush
  765. Private DrawGradientRectangle As Rectangle
  766.  
  767. Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  768. DrawGradient(blend, x, y, width, height, 90S)
  769. End Sub
  770. 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)
  771. DrawGradient(c1, c2, x, y, width, height, 90S)
  772. End Sub
  773.  
  774. Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  775. DrawGradientRectangle = New Rectangle(x, y, width, height)
  776. DrawGradient(blend, DrawGradientRectangle, angle)
  777. End Sub
  778. 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)
  779. DrawGradientRectangle = New Rectangle(x, y, width, height)
  780. DrawGradient(c1, c2, DrawGradientRectangle, angle)
  781. End Sub
  782.  
  783. Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
  784. DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
  785. DrawGradientBrush.InterpolationColors = blend
  786. G.FillRectangle(DrawGradientBrush, r)
  787. End Sub
  788. Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  789. DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
  790. G.FillRectangle(DrawGradientBrush, r)
  791. End Sub
  792.  
  793. #End Region
  794.  
  795. End Class
  796.  
  797. MustInherit Class ThemeControl152
  798. Inherits Control
  799.  
  800. Protected G As Graphics, B As Bitmap
  801.  
  802. Sub New()
  803. SetStyle(DirectCast(139270, ControlStyles), True)
  804.  
  805. _ImageSize = Size.Empty
  806.  
  807. MeasureBitmap = New Bitmap(1, 1)
  808. MeasureGraphics = Graphics.FromImage(MeasureBitmap)
  809.  
  810. Font = New Font("Verdana", 8S)
  811.  
  812. InvalidateCustimization()
  813. End Sub
  814.  
  815. Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
  816. If Not _LockWidth = 0 Then width = _LockWidth
  817. If Not _LockHeight = 0 Then height = _LockHeight
  818. MyBase.SetBoundsCore(x, y, width, height, specified)
  819. End Sub
  820.  
  821. Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  822. If _Transparent AndAlso Not (Width = 0 OrElse Height = 0) Then
  823. B = New Bitmap(Width, Height)
  824. G = Graphics.FromImage(B)
  825. End If
  826.  
  827. Invalidate()
  828. MyBase.OnSizeChanged(e)
  829. End Sub
  830.  
  831. Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  832. If Width = 0 OrElse Height = 0 Then Return
  833.  
  834. If _Transparent Then
  835. PaintHook()
  836. e.Graphics.DrawImage(B, 0, 0)
  837. Else
  838. G = e.Graphics
  839. PaintHook()
  840. End If
  841. End Sub
  842.  
  843. Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  844. InvalidateCustimization()
  845. ColorHook()
  846.  
  847. If Not _LockWidth = 0 Then Width = _LockWidth
  848. If Not _LockHeight = 0 Then Height = _LockHeight
  849.  
  850. Transparent = _Transparent
  851. If _BackColorU AndAlso _Transparent Then BackColor = Color.Transparent
  852.  
  853. MyBase.OnHandleCreated(e)
  854. End Sub
  855.  
  856. Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
  857. If Parent IsNot Nothing Then OnCreation()
  858. MyBase.OnParentChanged(e)
  859. End Sub
  860.  
  861. Protected Overridable Sub OnCreation()
  862. End Sub
  863.  
  864. #Region " State Handling "
  865.  
  866. Private InPosition As Boolean
  867. Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  868. InPosition = True
  869. SetState(MouseState.Over)
  870. MyBase.OnMouseEnter(e)
  871. End Sub
  872.  
  873. Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  874. If InPosition Then SetState(MouseState.Over)
  875. MyBase.OnMouseUp(e)
  876. End Sub
  877.  
  878. Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  879. If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
  880. MyBase.OnMouseDown(e)
  881. End Sub
  882.  
  883. Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  884. InPosition = False
  885. SetState(MouseState.None)
  886. MyBase.OnMouseLeave(e)
  887. End Sub
  888.  
  889. Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
  890. If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
  891. MyBase.OnEnabledChanged(e)
  892. End Sub
  893.  
  894. Protected State As MouseState
  895. Private Sub SetState(ByVal current As MouseState)
  896. State = current
  897. Invalidate()
  898. End Sub
  899.  
  900. #End Region
  901.  
  902.  
  903. #Region " Property Overrides "
  904.  
  905. Private _BackColorU As Boolean
  906. <Category("Misc")> _
  907. Overrides Property BackColor() As Color
  908. Get
  909. Return MyBase.BackColor
  910. End Get
  911. Set(ByVal value As Color)
  912. If Not IsHandleCreated AndAlso value = Color.Transparent Then
  913. _BackColorU = True
  914. Return
  915. End If
  916.  
  917. MyBase.BackColor = value
  918. If Parent IsNot Nothing Then ColorHook()
  919. End Set
  920. End Property
  921.  
  922. <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  923. Overrides Property ForeColor() As Color
  924. Get
  925. Return Color.Empty
  926. End Get
  927. Set(ByVal value As Color)
  928. End Set
  929. End Property
  930. <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  931. Overrides Property BackgroundImage() As Image
  932. Get
  933. Return Nothing
  934. End Get
  935. Set(ByVal value As Image)
  936. End Set
  937. End Property
  938. <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  939. Overrides Property BackgroundImageLayout() As ImageLayout
  940. Get
  941. Return ImageLayout.None
  942. End Get
  943. Set(ByVal value As ImageLayout)
  944. End Set
  945. End Property
  946.  
  947. Overrides Property Text() As String
  948. Get
  949. Return MyBase.Text
  950. End Get
  951. Set(ByVal value As String)
  952. MyBase.Text = value
  953. Invalidate()
  954. End Set
  955. End Property
  956.  
  957. Overrides Property Font() As Font
  958. Get
  959. Return MyBase.Font
  960. End Get
  961. Set(ByVal value As Font)
  962. MyBase.Font = value
  963. Invalidate()
  964. End Set
  965. End Property
  966.  
  967. #End Region
  968.  
  969. #Region " Properties "
  970.  
  971. Private _NoRounding As Boolean
  972. Property NoRounding() As Boolean
  973. Get
  974. Return _NoRounding
  975. End Get
  976. Set(ByVal v As Boolean)
  977. _NoRounding = v
  978. Invalidate()
  979. End Set
  980. End Property
  981.  
  982. Private _Image As Image
  983. Property Image() As Image
  984. Get
  985. Return _Image
  986. End Get
  987. Set(ByVal value As Image)
  988. If value Is Nothing Then
  989. _ImageSize = Size.Empty
  990. Else
  991. _ImageSize = value.Size
  992. End If
  993.  
  994. _Image = value
  995. Invalidate()
  996. End Set
  997. End Property
  998.  
  999. Private _ImageSize As Size
  1000. Protected ReadOnly Property ImageSize() As Size
  1001. Get
  1002. Return _ImageSize
  1003. End Get
  1004. End Property
  1005.  
  1006. Private _LockWidth As Integer
  1007. Protected Property LockWidth() As Integer
  1008. Get
  1009. Return _LockWidth
  1010. End Get
  1011. Set(ByVal value As Integer)
  1012. _LockWidth = value
  1013. If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
  1014. End Set
  1015. End Property
  1016.  
  1017. Private _LockHeight As Integer
  1018. Protected Property LockHeight() As Integer
  1019. Get
  1020. Return _LockHeight
  1021. End Get
  1022. Set(ByVal value As Integer)
  1023. _LockHeight = value
  1024. If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
  1025. End Set
  1026. End Property
  1027.  
  1028. Private _Transparent As Boolean
  1029. Property Transparent() As Boolean
  1030. Get
  1031. Return _Transparent
  1032. End Get
  1033. Set(ByVal value As Boolean)
  1034. _Transparent = value
  1035. If Not IsHandleCreated Then Return
  1036.  
  1037. If Not value AndAlso Not BackColor.A = 255 Then
  1038. Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
  1039. End If
  1040.  
  1041. SetStyle(ControlStyles.Opaque, Not value)
  1042. SetStyle(ControlStyles.SupportsTransparentBackColor, value)
  1043.  
  1044. If value Then InvalidateBitmap() Else B = Nothing
  1045. Invalidate()
  1046. End Set
  1047. End Property
  1048.  
  1049. Private Items As New Dictionary(Of String, Color)
  1050. <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
  1051. Property Colors() As Bloom()
  1052. Get
  1053. Dim T As New List(Of Bloom)
  1054. Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
  1055.  
  1056. While E.MoveNext
  1057. T.Add(New Bloom(E.Current.Key, E.Current.Value))
  1058. End While
  1059.  
  1060. Return T.ToArray
  1061. End Get
  1062. Set(ByVal value As Bloom())
  1063. For Each B As Bloom In value
  1064. If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
  1065. Next
  1066.  
  1067. InvalidateCustimization()
  1068. ColorHook()
  1069. Invalidate()
  1070. End Set
  1071. End Property
  1072.  
  1073. Private _Customization As String
  1074. Property Customization() As String
  1075. Get
  1076. Return _Customization
  1077. End Get
  1078. Set(ByVal value As String)
  1079. If value = _Customization Then Return
  1080.  
  1081. Dim Data As Byte()
  1082. Dim Items As Bloom() = Colors
  1083.  
  1084. Try
  1085. Data = Convert.FromBase64String(value)
  1086. For I As Integer = 0 To Items.Length - 1
  1087. Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
  1088. Next
  1089. Catch
  1090. Return
  1091. End Try
  1092.  
  1093. _Customization = value
  1094.  
  1095. Colors = Items
  1096. ColorHook()
  1097. Invalidate()
  1098. End Set
  1099. End Property
  1100.  
  1101. #End Region
  1102.  
  1103. #Region " Property Helpers "
  1104.  
  1105. Private Sub InvalidateBitmap()
  1106. If Width = 0 OrElse Height = 0 Then Return
  1107. B = New Bitmap(Width, Height)
  1108. G = Graphics.FromImage(B)
  1109. End Sub
  1110.  
  1111. Protected Function GetColor(ByVal name As String) As Color
  1112. Return Items(name)
  1113. End Function
  1114.  
  1115. Protected Sub SetColor(ByVal name As String, ByVal value As Color)
  1116. If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
  1117. End Sub
  1118. Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1119. SetColor(name, Color.FromArgb(r, g, b))
  1120. End Sub
  1121. Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1122. SetColor(name, Color.FromArgb(a, r, g, b))
  1123. End Sub
  1124. Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
  1125. SetColor(name, Color.FromArgb(a, value))
  1126. End Sub
  1127.  
  1128. Private Sub InvalidateCustimization()
  1129. Dim M As New MemoryStream(Items.Count * 4)
  1130.  
  1131. For Each B As Bloom In Colors
  1132. M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
  1133. Next
  1134.  
  1135. M.Close()
  1136. _Customization = Convert.ToBase64String(M.ToArray)
  1137. End Sub
  1138.  
  1139. #End Region
  1140.  
  1141.  
  1142. #Region " User Hooks "
  1143.  
  1144. Protected MustOverride Sub ColorHook()
  1145. Protected MustOverride Sub PaintHook()
  1146.  
  1147. #End Region
  1148.  
  1149.  
  1150. #Region " Center Overloads "
  1151.  
  1152. Private CenterReturn As Point
  1153.  
  1154. Protected Function Center(ByVal r1 As Rectangle, ByVal s1 As Size) As Point
  1155. CenterReturn = New Point((r1.Width \ 2 - s1.Width \ 2) + r1.X, (r1.Height \ 2 - s1.Height \ 2) + r1.Y)
  1156. Return CenterReturn
  1157. End Function
  1158. Protected Function Center(ByVal r1 As Rectangle, ByVal r2 As Rectangle) As Point
  1159. Return Center(r1, r2.Size)
  1160. End Function
  1161.  
  1162. Protected Function Center(ByVal w1 As Integer, ByVal h1 As Integer, ByVal w2 As Integer, ByVal h2 As Integer) As Point
  1163. CenterReturn = New Point(w1 \ 2 - w2 \ 2, h1 \ 2 - h2 \ 2)
  1164. Return CenterReturn
  1165. End Function
  1166.  
  1167. Protected Function Center(ByVal s1 As Size, ByVal s2 As Size) As Point
  1168. Return Center(s1.Width, s1.Height, s2.Width, s2.Height)
  1169. End Function
  1170.  
  1171. Protected Function Center(ByVal r1 As Rectangle) As Point
  1172. Return Center(ClientRectangle.Width, ClientRectangle.Height, r1.Width, r1.Height)
  1173. End Function
  1174. Protected Function Center(ByVal s1 As Size) As Point
  1175. Return Center(Width, Height, s1.Width, s1.Height)
  1176. End Function
  1177. Protected Function Center(ByVal w1 As Integer, ByVal h1 As Integer) As Point
  1178. Return Center(Width, Height, w1, h1)
  1179. End Function
  1180.  
  1181. #End Region
  1182.  
  1183. #Region " Measure Overloads "
  1184.  
  1185. Private MeasureBitmap As Bitmap
  1186. Private MeasureGraphics As Graphics
  1187.  
  1188. Protected Function Measure(ByVal text As String) As Size
  1189. Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
  1190. End Function
  1191. Protected Function Measure() As Size
  1192. Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
  1193. End Function
  1194.  
  1195. #End Region
  1196.  
  1197. #Region " DrawCorners Overloads "
  1198.  
  1199. Private DrawCornersBrush As SolidBrush
  1200.  
  1201. Protected Sub DrawCorners(ByVal c1 As Color)
  1202. DrawCorners(c1, 0, 0, Width, Height)
  1203. End Sub
  1204. Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
  1205. DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
  1206. End Sub
  1207. Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1208. If _NoRounding Then Return
  1209.  
  1210. If _Transparent Then
  1211. B.SetPixel(x, y, c1)
  1212. B.SetPixel(x + (width - 1), y, c1)
  1213. B.SetPixel(x, y + (height - 1), c1)
  1214. B.SetPixel(x + (width - 1), y + (height - 1), c1)
  1215. Else
  1216. DrawCornersBrush = New SolidBrush(c1)
  1217. G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
  1218. G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
  1219. G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
  1220. G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
  1221. End If
  1222. End Sub
  1223.  
  1224. #End Region
  1225.  
  1226. #Region " DrawBorders Overloads "
  1227.  
  1228. 'TODO: Remove triple overload?
  1229.  
  1230. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
  1231. DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  1232. End Sub
  1233. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
  1234. DrawBorders(p1, 0, 0, Width, Height, offset)
  1235. End Sub
  1236. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
  1237. DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
  1238. End Sub
  1239.  
  1240. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1241. G.DrawRectangle(p1, x, y, width - 1, height - 1)
  1242. End Sub
  1243. Protected Sub DrawBorders(ByVal p1 As Pen)
  1244. DrawBorders(p1, 0, 0, Width, Height)
  1245. End Sub
  1246. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
  1247. DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
  1248. End Sub
  1249.  
  1250. #End Region
  1251.  
  1252. #Region " DrawText Overloads "
  1253.  
  1254. 'TODO: Remove triple overloads?
  1255.  
  1256. Private DrawTextPoint As Point
  1257. Private DrawTextSize As Size
  1258.  
  1259. Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1260. DrawText(b1, Text, a, x, y)
  1261. End Sub
  1262. Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
  1263. DrawText(b1, Text, p1.X, p1.Y)
  1264. End Sub
  1265. Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  1266. DrawText(b1, Text, x, y)
  1267. End Sub
  1268.  
  1269. Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1270. If text.Length = 0 Then Return
  1271. DrawTextSize = Measure(text)
  1272. DrawTextPoint = Center(DrawTextSize)
  1273.  
  1274. Select Case a
  1275. Case HorizontalAlignment.Left
  1276. DrawText(b1, text, x, DrawTextPoint.Y + y)
  1277. Case HorizontalAlignment.Center
  1278. DrawText(b1, text, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  1279. Case HorizontalAlignment.Right
  1280. DrawText(b1, text, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  1281. End Select
  1282. End Sub
  1283. Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal p1 As Point)
  1284. DrawText(b1, text, p1.X, p1.Y)
  1285. End Sub
  1286. Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal x As Integer, ByVal y As Integer)
  1287. If text.Length = 0 Then Return
  1288. G.DrawString(text, Font, b1, x, y)
  1289. End Sub
  1290.  
  1291. #End Region
  1292.  
  1293. #Region " DrawImage Overloads "
  1294.  
  1295. 'TODO: Remove triple overloads?
  1296.  
  1297. Private DrawImagePoint As Point
  1298.  
  1299. Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1300. DrawImage(_Image, a, x, y)
  1301. End Sub
  1302. Protected Sub DrawImage(ByVal p1 As Point)
  1303. DrawImage(_Image, p1.X, p1.Y)
  1304. End Sub
  1305. Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
  1306. DrawImage(_Image, x, y)
  1307. End Sub
  1308.  
  1309. Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1310. If image Is Nothing Then Return
  1311. DrawImagePoint = Center(image.Size)
  1312.  
  1313. Select Case a
  1314. Case HorizontalAlignment.Left
  1315. DrawImage(image, x, DrawImagePoint.Y + y)
  1316. Case HorizontalAlignment.Center
  1317. DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y)
  1318. Case HorizontalAlignment.Right
  1319. DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y)
  1320. End Select
  1321. End Sub
  1322. Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
  1323. DrawImage(image, p1.X, p1.Y)
  1324. End Sub
  1325. Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
  1326. If image Is Nothing Then Return
  1327. G.DrawImage(image, x, y, image.Width, image.Height)
  1328. End Sub
  1329.  
  1330. #End Region
  1331.  
  1332. #Region " DrawGradient Overloads "
  1333.  
  1334. 'TODO: Remove triple overload?
  1335.  
  1336. Private DrawGradientBrush As LinearGradientBrush
  1337. Private DrawGradientRectangle As Rectangle
  1338.  
  1339. Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1340. DrawGradient(blend, x, y, width, height, 90S)
  1341. End Sub
  1342. 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)
  1343. DrawGradient(c1, c2, x, y, width, height, 90S)
  1344. End Sub
  1345.  
  1346. Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  1347. DrawGradientRectangle = New Rectangle(x, y, width, height)
  1348. DrawGradient(blend, DrawGradientRectangle, angle)
  1349. End Sub
  1350. 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)
  1351. DrawGradientRectangle = New Rectangle(x, y, width, height)
  1352. DrawGradient(c1, c2, DrawGradientRectangle, angle)
  1353. End Sub
  1354.  
  1355. Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
  1356. DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
  1357. DrawGradientBrush.InterpolationColors = blend
  1358. G.FillRectangle(DrawGradientBrush, r)
  1359. End Sub
  1360. Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1361. DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
  1362. G.FillRectangle(DrawGradientBrush, r)
  1363. End Sub
  1364.  
  1365. #End Region
  1366.  
  1367. End Class
  1368.  
  1369. Enum MouseState As Byte
  1370. None = 0
  1371. Over = 1
  1372. Down = 2
  1373. Block = 3
  1374. End Enum
  1375.  
  1376. Class Bloom
  1377.  
  1378. Private _Name As String
  1379. Property Name() As String
  1380. Get
  1381. Return _Name
  1382. End Get
  1383. Set(ByVal value As String)
  1384. _Name = value
  1385. End Set
  1386. End Property
  1387.  
  1388. Private _Value As Color
  1389. Property Value() As Color
  1390. Get
  1391. Return _Value
  1392. End Get
  1393. Set(ByVal value As Color)
  1394. _Value = value
  1395. End Set
  1396. End Property
  1397.  
  1398. Sub New()
  1399. End Sub
  1400.  
  1401. Sub New(ByVal name As String, ByVal value As Color)
  1402. _Name = name
  1403. _Value = value
  1404. End Sub
  1405. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement