Control BinärUhr

    • VB.NET

    Es gibt 31 Antworten in diesem Thema. Der letzte Beitrag () ist von Cypress.

      So ich habe es endlich geschaft mir nen Image zu erstellen :)

      VB.NET-Quellcode

      1. Protected Sub CreateColorImage(ByVal _g As Graphics, ByVal _Rect As Rectangle, ByVal _CenterColor As Color, ByVal _SurroundColor As Color())
      2. Dim m_GraphicsPath As New GraphicsPath
      3. m_GraphicsPath.AddEllipse(_Rect)
      4. Dim m_PGB As PathGradientBrush = New PathGradientBrush(m_GraphicsPath)
      5. m_PGB.CenterColor = _CenterColor
      6. m_PGB.SurroundColors = _SurroundColor
      7. m_PGB.CenterPoint = New Point(CInt(_Rect.Width / 2), CInt((_Rect.Height / 100) * 10))
      8. _g.FillEllipse(m_PGB, _Rect)
      9. End Sub
      Keep Calm And Color Your Life
      So hier mal mit Einbindung von meinem DrawCode

      Spoiler anzeigen

      VB.NET-Quellcode

      1. Option Strict On
      2. Option Explicit On
      3. Imports System.Drawing
      4. Imports System.Windows.Forms
      5. Imports System.Drawing.Drawing2D
      6. Imports System.ComponentModel
      7. Public Class BinaryClock
      8. Inherits Control
      9. #Region " Instance variables "
      10. Protected m_BorderRadius As Single = 3
      11. Protected m_BorderColor As Color = SystemColors.ControlDarkDark
      12. Protected m_ColorTop As Color = SystemColors.ControlDark
      13. Protected m_ColorBottom As Color = SystemColors.ControlLight
      14. Protected m_Activated As Boolean = False
      15. Protected m_AllowDesignTimeAction As Boolean = False
      16. Protected m_TrueCenterColor As Color = Color.White
      17. Protected m_TrueSurroundColor As Color() = {Color.Green}
      18. Protected m_FalseCenterColor As Color = Color.White
      19. Protected m_FalseSurroundColor As Color() = {Color.Red}
      20. Public WithEvents m_Timer As New Timers.Timer With {.Interval = 1000}
      21. #End Region
      22. #Region " Initializing "
      23. Public Sub New()
      24. MyBase.New()
      25. MyBase.SetStyle(ControlStyles.CacheText Or ControlStyles.DoubleBuffer Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
      26. MyBase.UpdateStyles()
      27. With Me
      28. .Size = New Size(151, 75)
      29. .MinimumSize = New Size(.Width, .Height)
      30. .MaximumSize = New Size(.Width, .Height)
      31. End With
      32. End Sub
      33. #End Region
      34. #Region " Properties "
      35. <Category("BinaryClock")>
      36. <Description("Startet oder stoppt die Animation.")>
      37. Public Property Activated As Boolean
      38. Get
      39. Return m_Activated
      40. End Get
      41. Set(ByVal value As Boolean)
      42. m_Activated = value
      43. If m_Activated AndAlso ((Me.DesignMode AndAlso Me.AllowDesignTimeAction) OrElse Not Me.DesignMode) Then
      44. m_Timer.Start()
      45. Else
      46. m_Timer.Stop()
      47. End If
      48. Me.Invalidate()
      49. End Set
      50. End Property
      51. <Category("BinaryClock")>
      52. <Description("Gibt an, ob die Animation auch zur Designzeit aktiviert ist.")>
      53. Public Property AllowDesignTimeAction As Boolean
      54. Get
      55. Return m_AllowDesignTimeAction
      56. End Get
      57. Set(ByVal value As Boolean)
      58. m_AllowDesignTimeAction = value
      59. Me.Activated = Me.Activated
      60. End Set
      61. End Property
      62. <Category("BinaryClock")>
      63. <Description("Anfangsfarbe des Hintergrundfarbverlaufs.")>
      64. Public Property ColorTop As Color
      65. Get
      66. Return m_ColorTop
      67. End Get
      68. Set(ByVal value As Color)
      69. m_ColorTop = value
      70. Me.Invalidate()
      71. End Set
      72. End Property
      73. <Category("BinaryClock")>
      74. <Description("Endfarbe des Hintergrundfarbverlaufs.")>
      75. Public Property ColorBottom As Color
      76. Get
      77. Return m_ColorBottom
      78. End Get
      79. Set(ByVal value As Color)
      80. m_ColorBottom = value
      81. Me.Invalidate()
      82. End Set
      83. End Property
      84. <Category("BinaryClock")>
      85. <Description("Farbe des Rahmens.")>
      86. Public Property BorderColor As Color
      87. Get
      88. Return m_BorderColor
      89. End Get
      90. Set(ByVal value As Color)
      91. m_BorderColor = value
      92. Me.Invalidate()
      93. End Set
      94. End Property
      95. <Category("BinaryClock")>
      96. <Description("Centerfarbe vom True Image")>
      97. Public Property TrueCenterColor As Color
      98. Get
      99. Return m_TrueCenterColor
      100. End Get
      101. Set(ByVal value As Color)
      102. m_TrueCenterColor = value
      103. Me.Invalidate()
      104. End Set
      105. End Property
      106. <Category("BinaryClock")>
      107. <Description("Surroundfarbe vom True Image")>
      108. Public Property TrueSurroundColor As Color()
      109. Get
      110. Return m_TrueSurroundColor
      111. End Get
      112. Set(ByVal value As Color())
      113. m_TrueSurroundColor = value
      114. Me.Invalidate()
      115. End Set
      116. End Property
      117. <Category("BinaryClock")>
      118. <Description("Centerfarbe vom False Image")>
      119. Public Property FalseCenterColor As Color
      120. Get
      121. Return m_FalseCenterColor
      122. End Get
      123. Set(ByVal value As Color)
      124. m_FalseCenterColor = value
      125. Me.Invalidate()
      126. End Set
      127. End Property
      128. <Category("BinaryClock")>
      129. <Description("Surroundfarbe vom False Image")>
      130. Public Property FalseSurroundColor As Color()
      131. Get
      132. Return m_FalseSurroundColor
      133. End Get
      134. Set(ByVal value As Color())
      135. m_FalseSurroundColor = value
      136. Me.Invalidate()
      137. End Set
      138. End Property
      139. <Category("BinaryClock")>
      140. <Description("Radius der Abrundung des Rahmens in Pixel.")>
      141. Public Property BorderRadius As Single
      142. Get
      143. Return m_BorderRadius
      144. End Get
      145. Set(ByVal value As Single)
      146. m_BorderRadius = value
      147. Me.Invalidate()
      148. End Set
      149. End Property
      150. #End Region
      151. #Region " Eventhandler "
      152. Protected Overrides Sub OnResize(ByVal e As EventArgs)
      153. ' Größenänderung ignorieren
      154. ' MyBase.OnResize(e)
      155. End Sub
      156. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
      157. MyBase.OnPaint(e)
      158. With e.Graphics
      159. .SmoothingMode = SmoothingMode.HighQuality
      160. End With
      161. Dim m_r As Rectangle
      162. With e.ClipRectangle
      163. m_r = New Rectangle(0, 0, .Width - 1, .Height - 1)
      164. End With
      165. If m_r.Width = 0 OrElse m_r.Height = 0 Then
      166. Return
      167. End If
      168. Dim m_BoolList = GetBinaryValues(Now.Hour, Now.Minute, Now.Second)
      169. DrawFillRoundedRectangle(e.Graphics, m_r, Me.BorderRadius, Me.BorderColor, New LinearGradientBrush(m_r, Me.ColorTop, Me.ColorBottom, LinearGradientMode.Vertical))
      170. Dim m_temp As Integer = 0
      171. For i As Integer = 0 To 2 Step 1
      172. For j As Integer = 0 To 5 Step 1
      173. Select Case m_BoolList(m_temp)
      174. Case True
      175. CreateColorImage(e.Graphics, New Rectangle(New Point(5 + ((j * 24) + (j * 1)), 5 + ((i * 24) + (i * 1))), _
      176. New Size(10, 10)), Me.TrueCenterColor, Me.TrueSurroundColor)
      177. Case False
      178. CreateColorImage(e.Graphics, New Rectangle(New Point(5 + ((j * 24) + (j * 1)), 5 + ((i * 24) + (i * 1))), _
      179. New Size(10, 10)), Me.FalseCenterColor, Me.FalseSurroundColor)
      180. End Select
      181. m_temp += 1
      182. Next
      183. Next
      184. End Sub
      185. Protected Sub m_Timer_Elapsed(ByVal sender As Object, ByVal e As EventArgs) Handles m_Timer.Elapsed
      186. Me.Invalidate()
      187. End Sub
      188. #End Region
      189. #Region " Supporting methods "
      190. Protected Sub DrawFillRoundedRectangle(ByVal _g As Graphics, ByVal _r As Rectangle, ByVal _radius As Single, ByVal _borderColor As Color, ByVal _fillBrush As Brush)
      191. Using m_path As GraphicsPath = FillRoundedRectanglePath(_r, _radius)
      192. With _g
      193. .FillPath(_fillBrush, m_path)
      194. .DrawPath(New Pen(_borderColor), m_path)
      195. End With
      196. End Using
      197. End Sub
      198. Protected Function FillRoundedRectanglePath(ByVal _Rect As RectangleF, ByVal _Radius As Single) As GraphicsPath
      199. Dim m_GraphicsPath As New GraphicsPath
      200. Dim m_DiaMeter As Single = 2 * _Radius
      201. With m_GraphicsPath
      202. If _Radius < 1 Then
      203. .AddRectangle(_Rect)
      204. Else
      205. .AddLine(_Rect.X + _Radius, _Rect.Y, _Rect.X + _Rect.Width - m_DiaMeter, _Rect.Y)
      206. .AddArc(_Rect.X + _Rect.Width - m_DiaMeter, _Rect.Y, m_DiaMeter, m_DiaMeter, 270, 90)
      207. .AddLine(_Rect.X + _Rect.Width, _Rect.Y + _Radius, _Rect.X + _Rect.Width, _Rect.Y + _Rect.Height - m_DiaMeter)
      208. .AddArc(_Rect.X + _Rect.Width - m_DiaMeter, _Rect.Y + _Rect.Height - m_DiaMeter, m_DiaMeter, m_DiaMeter, 0, 90)
      209. .AddLine(_Rect.X + _Rect.Width - m_DiaMeter, _Rect.Y + _Rect.Height, _Rect.X + _Radius, _Rect.Y + _Rect.Height)
      210. .AddArc(_Rect.X, _Rect.Y + _Rect.Height - m_DiaMeter, m_DiaMeter, m_DiaMeter, 90, 90)
      211. .AddLine(_Rect.X, _Rect.Y + _Rect.Height - m_DiaMeter, _Rect.X, _Rect.Y + _Radius)
      212. .AddArc(_Rect.X, _Rect.Y, m_DiaMeter, m_DiaMeter, 180, 90)
      213. End If
      214. .CloseFigure()
      215. End With
      216. Return m_GraphicsPath
      217. End Function
      218. Protected Function GetBinaryValues(ByVal _Hours As Integer, ByVal _Minutes As Integer, ByVal _Seconds As Integer) As List(Of Boolean)
      219. Dim m_Value As New List(Of Boolean)
      220. If _Hours < 12 And _Hours > 0 Then
      221. m_Value.Add(True)
      222. Else
      223. m_Value.Add(False)
      224. End If
      225. For i As Int32 = 0 To 2
      226. Dim m_temp As String = String.Empty
      227. Select Case i
      228. Case 0
      229. m_temp = Convert.ToString(_Hours, 2)
      230. For j As Integer = (4 - m_temp.Length) To 0 Step -1
      231. m_Value.Add(False)
      232. Next
      233. For j As Integer = 0 To m_temp.Length - 1 Step 1
      234. m_Value.Add(m_temp.Substring(j, 1) = "1")
      235. Next
      236. Case 1
      237. m_temp = Convert.ToString(_Minutes, 2)
      238. For j As Integer = (5 - m_temp.Length) To 0 Step -1
      239. m_Value.Add(False)
      240. Next
      241. For j As Integer = 0 To m_temp.Length - 1 Step 1
      242. m_Value.Add(m_temp.Substring(j, 1) = "1")
      243. Next
      244. Case 2
      245. m_temp = Convert.ToString(_Seconds, 2)
      246. For j As Integer = (5 - m_temp.Length) To 0 Step -1
      247. m_Value.Add(False)
      248. Next
      249. For j As Integer = 0 To m_temp.Length - 1 Step 1
      250. m_Value.Add(m_temp.Substring(j, 1) = "1")
      251. Next
      252. End Select
      253. Next
      254. Return m_Value
      255. End Function
      256. Protected Sub CreateColorImage(ByVal _G As Graphics, ByVal _Rect As Rectangle, ByVal _CenterColor As Color, ByVal _SurroundColor As Color())
      257. Dim m_GraphicsPath As New GraphicsPath
      258. m_GraphicsPath.AddEllipse(_Rect)
      259. Dim m_PGB As PathGradientBrush = New PathGradientBrush(m_GraphicsPath)
      260. m_PGB.CenterColor = _CenterColor
      261. m_PGB.SurroundColors = _SurroundColor
      262. m_PGB.CenterPoint = New Point(_Rect.X + CInt(_Rect.Width / 2), _Rect.Y + CInt(_Rect.Height / 3))
      263. _G.FillEllipse(m_PGB, _Rect)
      264. m_GraphicsPath.Dispose()
      265. End Sub
      266. #End Region
      267. End Class



      Jetzt fehlt mir nurnoch die Resize Methode, sprich
      -True/False Bilder werden Größer,Kleiner...
      -True/False Bilder verschieben sich gleichmäßig...

      Na das kann ja noch was werden :D


      Keep Calm And Color Your Life

      Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Cypress“ ()

      In AllowDesignTimeAction()

      Cypress schrieb:

      VB.NET-Quellcode

      1. Me.Activated = Me.Activated
      Soll das Me.Invalidate() heißen?
      Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
      Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
      Ein guter .NET-Snippetkonverter (der ist verfügbar).
      Programmierfragen über PN / Konversation werden ignoriert!

      Cypress schrieb:

      ein Verweis auf die Property
      Dann würde ich da genau solch Kommentar reinschreiben, damit unsereiner in einem halben Jahr nicht den Grübelzwang kriegt. :D
      Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
      Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
      Ein guter .NET-Snippetkonverter (der ist verfügbar).
      Programmierfragen über PN / Konversation werden ignoriert!
      @Cypress
      Sehr hübsch geworden.
      Und ja, da muss einiges in Protected Overrides OnResize(...) geschehen. Ich würde dort die Abmessungen bestimmen, die Du dann in den Zeilen 199 ff von Post#23 brauchst.
      Das könnte eine mögliche Lösung sein:
      Spoiler anzeigen

      VB.NET-Quellcode

      1. Option Strict On
      2. Option Explicit On
      3. Imports System.Drawing
      4. Imports System.Windows.Forms
      5. Imports System.Drawing.Drawing2D
      6. Imports System.ComponentModel
      7. Public Class BinaryClockControl
      8. Inherits Control
      9. #Region " Instance variables "
      10. Protected m_BorderRadius As Single = 3
      11. Protected m_BorderColor As Color = SystemColors.ControlDarkDark
      12. Protected m_ColorTop As Color = SystemColors.ControlDark
      13. Protected m_ColorBottom As Color = SystemColors.ControlLight
      14. Protected m_Activated As Boolean = False
      15. Protected m_AllowDesignTimeAction As Boolean = False
      16. Protected m_TrueCenterColor As Color = Color.White
      17. Protected m_TrueSurroundColor As Color() = {Color.Green}
      18. Protected m_FalseCenterColor As Color = Color.White
      19. Protected m_FalseSurroundColor As Color() = {Color.Red}
      20. Public WithEvents m_Timer As New Timers.Timer With {.Interval = 1000}
      21. Protected m_OriginalWidth As Int32 = 151
      22. Protected m_OriginalHeight As Int32 = 75
      23. Protected m_Padding As Padding = New Padding(7)
      24. Protected m_FactorX As Single = 1.0
      25. Protected m_FactorY As Single = 1.0
      26. #End Region
      27. #Region " Initializing "
      28. Public Sub New()
      29. MyBase.New()
      30. MyBase.SetStyle(ControlStyles.CacheText Or ControlStyles.DoubleBuffer Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
      31. MyBase.UpdateStyles()
      32. With Me
      33. .Size = New Size(m_OriginalWidth, m_OriginalHeight)
      34. .MinimumSize = .Size
      35. '.MaximumSize = New Size(.Width, .Height)
      36. End With
      37. End Sub
      38. #End Region
      39. #Region " Properties "
      40. <Category("BinaryClock")>
      41. <Description("Setzt den Linken und oberen Abstand der Zeitzeichen.")>
      42. Public Overloads Property Padding As Padding
      43. Get
      44. Return m_Padding
      45. End Get
      46. Set(value As Padding)
      47. m_Padding = value
      48. Me.Invalidate()
      49. End Set
      50. End Property
      51. <Category("BinaryClock")>
      52. <Description("Startet oder stoppt die Animation.")>
      53. Public Property Activated As Boolean
      54. Get
      55. Return m_Activated
      56. End Get
      57. Set(ByVal value As Boolean)
      58. m_Activated = value
      59. If m_Activated AndAlso ((Me.DesignMode AndAlso Me.AllowDesignTimeAction) OrElse Not Me.DesignMode) Then
      60. m_Timer.Start()
      61. Else
      62. m_Timer.Stop()
      63. End If
      64. Me.Invalidate()
      65. End Set
      66. End Property
      67. <Category("BinaryClock")>
      68. <Description("Gibt an, ob die Animation auch zur Designzeit aktiviert ist.")>
      69. Public Property AllowDesignTimeAction As Boolean
      70. Get
      71. Return m_AllowDesignTimeAction
      72. End Get
      73. Set(ByVal value As Boolean)
      74. m_AllowDesignTimeAction = value
      75. Me.Activated = Me.Activated
      76. End Set
      77. End Property
      78. <Category("BinaryClock")>
      79. <Description("Anfangsfarbe des Hintergrundfarbverlaufs.")>
      80. Public Property ColorTop As Color
      81. Get
      82. Return m_ColorTop
      83. End Get
      84. Set(ByVal value As Color)
      85. m_ColorTop = value
      86. Me.Invalidate()
      87. End Set
      88. End Property
      89. <Category("BinaryClock")>
      90. <Description("Endfarbe des Hintergrundfarbverlaufs.")>
      91. Public Property ColorBottom As Color
      92. Get
      93. Return m_ColorBottom
      94. End Get
      95. Set(ByVal value As Color)
      96. m_ColorBottom = value
      97. Me.Invalidate()
      98. End Set
      99. End Property
      100. <Category("BinaryClock")>
      101. <Description("Farbe des Rahmens.")>
      102. Public Property BorderColor As Color
      103. Get
      104. Return m_BorderColor
      105. End Get
      106. Set(ByVal value As Color)
      107. m_BorderColor = value
      108. Me.Invalidate()
      109. End Set
      110. End Property
      111. <Category("BinaryClock")>
      112. <Description("Centerfarbe vom True Image")>
      113. Public Property TrueCenterColor As Color
      114. Get
      115. Return m_TrueCenterColor
      116. End Get
      117. Set(ByVal value As Color)
      118. m_TrueCenterColor = value
      119. Me.Invalidate()
      120. End Set
      121. End Property
      122. <Category("BinaryClock")>
      123. <Description("Surroundfarbe vom True Image")>
      124. Public Property TrueSurroundColor As Color()
      125. Get
      126. Return m_TrueSurroundColor
      127. End Get
      128. Set(ByVal value As Color())
      129. m_TrueSurroundColor = value
      130. Me.Invalidate()
      131. End Set
      132. End Property
      133. <Category("BinaryClock")>
      134. <Description("Centerfarbe vom False Image")>
      135. Public Property FalseCenterColor As Color
      136. Get
      137. Return m_FalseCenterColor
      138. End Get
      139. Set(ByVal value As Color)
      140. m_FalseCenterColor = value
      141. Me.Invalidate()
      142. End Set
      143. End Property
      144. <Category("BinaryClock")>
      145. <Description("Surroundfarbe vom False Image")>
      146. Public Property FalseSurroundColor As Color()
      147. Get
      148. Return m_FalseSurroundColor
      149. End Get
      150. Set(ByVal value As Color())
      151. m_FalseSurroundColor = value
      152. Me.Invalidate()
      153. End Set
      154. End Property
      155. <Category("BinaryClock")>
      156. <Description("Radius der Abrundung des Rahmens in Pixel.")>
      157. Public Property BorderRadius As Single
      158. Get
      159. Return m_BorderRadius
      160. End Get
      161. Set(ByVal value As Single)
      162. m_BorderRadius = value
      163. Me.Invalidate()
      164. End Set
      165. End Property
      166. #End Region
      167. #Region " Eventhandler "
      168. Protected Overrides Sub OnResize(ByVal e As EventArgs)
      169. ' Größenänderung ignorieren
      170. MyBase.OnResize(e)
      171. Me.m_FactorX = CSng(Me.Width / m_OriginalWidth)
      172. Me.m_FactorY = CSng(Me.Height / m_OriginalHeight)
      173. End Sub
      174. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
      175. MyBase.OnPaint(e)
      176. With e.Graphics
      177. .SmoothingMode = SmoothingMode.HighQuality
      178. End With
      179. Dim m_r As Rectangle
      180. With e.ClipRectangle
      181. m_r = New Rectangle(0, 0, .Width - 1, .Height - 1)
      182. End With
      183. If m_r.Width = 0 OrElse m_r.Height = 0 Then
      184. Return
      185. End If
      186. Dim m_BoolList = GetBinaryValues(Now.Hour, Now.Minute, Now.Second)
      187. DrawFillRoundedRectangle(e.Graphics, m_r, Me.BorderRadius, Me.BorderColor, New LinearGradientBrush(m_r, Me.ColorTop, Me.ColorBottom, LinearGradientMode.Vertical))
      188. Dim m_temp As Integer = 0
      189. Dim m_CenterColor As Color = Nothing
      190. Dim m_SurroundColors() As Color = Nothing
      191. For Zeile As Integer = 0 To 2 Step 1
      192. For Spalte As Integer = 0 To 5 Step 1
      193. Select Case m_BoolList(m_temp)
      194. Case True
      195. m_CenterColor = Me.TrueCenterColor
      196. m_SurroundColors = Me.TrueSurroundColor
      197. Case False
      198. m_CenterColor = Me.FalseCenterColor
      199. m_SurroundColors = Me.FalseSurroundColor
      200. End Select
      201. CreateColorImage(e.Graphics, New Rectangle(New Point(CInt(Me.Padding.Left * m_FactorX + Spalte * 24 * m_FactorX + Spalte * m_FactorX),
      202. CInt(Me.Padding.Top * m_FactorY + Zeile * 24 * m_FactorY + Zeile * m_FactorY)), New Size(CInt(10 * m_FactorX), CInt(10 * m_FactorY))), m_CenterColor, m_SurroundColors)
      203. m_temp += 1
      204. Next
      205. Next
      206. End Sub
      207. Protected Sub m_Timer_Elapsed(ByVal sender As Object, ByVal e As EventArgs) Handles m_Timer.Elapsed
      208. Me.Invalidate()
      209. End Sub
      210. #End Region
      211. #Region " Supporting methods "
      212. Protected Sub DrawFillRoundedRectangle(ByVal _g As Graphics, ByVal _r As Rectangle, ByVal _radius As Single, ByVal _borderColor As Color, ByVal _fillBrush As Brush)
      213. Using m_path As GraphicsPath = FillRoundedRectanglePath(_r, _radius)
      214. With _g
      215. .FillPath(_fillBrush, m_path)
      216. .DrawPath(New Pen(_borderColor), m_path)
      217. End With
      218. End Using
      219. End Sub
      220. Protected Function FillRoundedRectanglePath(ByVal _Rect As RectangleF, ByVal _Radius As Single) As GraphicsPath
      221. Dim m_GraphicsPath As New GraphicsPath
      222. Dim m_DiaMeter As Single = 2 * _Radius
      223. With m_GraphicsPath
      224. If _Radius < 1 Then
      225. .AddRectangle(_Rect)
      226. Else
      227. .AddLine(_Rect.X + _Radius, _Rect.Y, _Rect.X + _Rect.Width - m_DiaMeter, _Rect.Y)
      228. .AddArc(_Rect.X + _Rect.Width - m_DiaMeter, _Rect.Y, m_DiaMeter, m_DiaMeter, 270, 90)
      229. .AddLine(_Rect.X + _Rect.Width, _Rect.Y + _Radius, _Rect.X + _Rect.Width, _Rect.Y + _Rect.Height - m_DiaMeter)
      230. .AddArc(_Rect.X + _Rect.Width - m_DiaMeter, _Rect.Y + _Rect.Height - m_DiaMeter, m_DiaMeter, m_DiaMeter, 0, 90)
      231. .AddLine(_Rect.X + _Rect.Width - m_DiaMeter, _Rect.Y + _Rect.Height, _Rect.X + _Radius, _Rect.Y + _Rect.Height)
      232. .AddArc(_Rect.X, _Rect.Y + _Rect.Height - m_DiaMeter, m_DiaMeter, m_DiaMeter, 90, 90)
      233. .AddLine(_Rect.X, _Rect.Y + _Rect.Height - m_DiaMeter, _Rect.X, _Rect.Y + _Radius)
      234. .AddArc(_Rect.X, _Rect.Y, m_DiaMeter, m_DiaMeter, 180, 90)
      235. End If
      236. .CloseFigure()
      237. End With
      238. Return m_GraphicsPath
      239. End Function
      240. Protected Function GetBinaryValues(ByVal _Hours As Integer, ByVal _Minutes As Integer, ByVal _Seconds As Integer) As List(Of Boolean)
      241. Dim m_Value As New List(Of Boolean)
      242. If _Hours < 12 And _Hours > 0 Then
      243. m_Value.Add(True)
      244. Else
      245. m_Value.Add(False)
      246. End If
      247. For i As Int32 = 0 To 2
      248. Dim m_temp As String = String.Empty
      249. Select Case i
      250. Case 0
      251. m_temp = Convert.ToString(_Hours, 2)
      252. For j As Integer = (4 - m_temp.Length) To 0 Step -1
      253. m_Value.Add(False)
      254. Next
      255. For j As Integer = 0 To m_temp.Length - 1 Step 1
      256. m_Value.Add(m_temp.Substring(j, 1) = "1")
      257. Next
      258. Case 1
      259. m_temp = Convert.ToString(_Minutes, 2)
      260. For j As Integer = (5 - m_temp.Length) To 0 Step -1
      261. m_Value.Add(False)
      262. Next
      263. For j As Integer = 0 To m_temp.Length - 1 Step 1
      264. m_Value.Add(m_temp.Substring(j, 1) = "1")
      265. Next
      266. Case 2
      267. m_temp = Convert.ToString(_Seconds, 2)
      268. For j As Integer = (5 - m_temp.Length) To 0 Step -1
      269. m_Value.Add(False)
      270. Next
      271. For j As Integer = 0 To m_temp.Length - 1 Step 1
      272. m_Value.Add(m_temp.Substring(j, 1) = "1")
      273. Next
      274. End Select
      275. Next
      276. Return m_Value
      277. End Function
      278. Protected Sub CreateColorImage(ByVal _G As Graphics, ByVal _Rect As Rectangle, ByVal _CenterColor As Color, ByVal _SurroundColor As Color())
      279. Dim m_GraphicsPath As New GraphicsPath
      280. m_GraphicsPath.AddEllipse(_Rect)
      281. Dim m_PGB As PathGradientBrush = New PathGradientBrush(m_GraphicsPath)
      282. m_PGB.CenterColor = _CenterColor
      283. m_PGB.SurroundColors = _SurroundColor
      284. m_PGB.CenterPoint = New Point(_Rect.X + CInt(_Rect.Width / 2), _Rect.Y + CInt(_Rect.Height / 3))
      285. _G.FillEllipse(m_PGB, _Rect)
      286. m_GraphicsPath.Dispose()
      287. End Sub
      288. #End Region
      289. End Class