Guest User

Aether Circular Update

a guest
Oct 7th, 2015
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.52 KB | None | 0 0
  1.  
  2. Public Class AetherCircular
  3. Inherits Control
  4.  
  5. Private G As Graphics
  6. Private ProgressAngle As Single
  7. Private RemainderAngle As Single
  8. Private ExceedingLimits As Boolean
  9. Private ExceedingSign As String
  10.  
  11. Private _Progress As Single
  12. Private _Max As Single = 100
  13. Private _Min As Single = 0
  14.  
  15. Public Property Percent As Boolean = True
  16.  
  17.  
  18. Public Property Progress As Single
  19. Get
  20. Return _Progress
  21. End Get
  22. Set(value As Single)
  23. Select Case value
  24. Case Is > Max
  25. value = Max
  26. ExceedingSign = "+"
  27. ExceedingLimits = True
  28. Invalidate()
  29.  
  30. Case Is < Min
  31. value = Min
  32. ExceedingSign = "-"
  33. ExceedingLimits = True
  34. Invalidate()
  35. End Select
  36. _Progress = value
  37. Invalidate()
  38. End Set
  39. End Property
  40.  
  41. Public Property Max As Single
  42. Get
  43. Return _Max
  44. End Get
  45. Set(value As Single)
  46. Select Case value
  47. Case Is < _Progress
  48. _Progress = value
  49. End Select
  50. _Max = value
  51. Invalidate()
  52. End Set
  53. End Property
  54.  
  55. Public Property Min As Single
  56. Get
  57. Return _Min
  58. End Get
  59. Set(value As Single)
  60. Select Case value
  61. Case Is > _Progress
  62. _Progress = value
  63. End Select
  64. _Min = value
  65. Invalidate()
  66. End Set
  67. End Property
  68.  
  69. Public Property Border As Color = Color.LightGray
  70. Public Property HatchPrimary As Color = Color.Green
  71. Public Property HatchSecondary As Color = Color.Red
  72. Public Property PostText As String = "%"
  73. Public Property ShowMax As Boolean = False
  74. Public Property HatchBrush As Boolean = False
  75.  
  76. Sub New()
  77. DoubleBuffered = True
  78. Size = New Size(128, 128)
  79. End Sub
  80.  
  81. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  82.  
  83. G = e.Graphics
  84. G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  85. G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  86.  
  87. MyBase.OnPaint(e)
  88.  
  89. ProgressAngle = 360 / Max * Progress
  90. RemainderAngle = 360 - ProgressAngle
  91.  
  92. If HatchBrush Then
  93. Using P1 As New Pen(New Drawing2D.HatchBrush(Drawing2D.HatchStyle.LightUpwardDiagonal, HatchPrimary, HatchSecondary), 4), P2 As New Pen(Border, 4)
  94. G.DrawArc(P1, New Rectangle(2, 2, Width - 5, Height - 5), -90, ProgressAngle)
  95. G.DrawArc(P2, New Rectangle(2, 2, Width - 5, Height - 5), ProgressAngle - 90, RemainderAngle)
  96. End Using
  97. Else
  98. Using P1 As New Pen(HatchPrimary, 4), P2 As New Pen(Border, 4)
  99. G.DrawArc(P1, New Rectangle(2, 2, Width - 5, Height - 5), -90, ProgressAngle)
  100. G.DrawArc(P2, New Rectangle(2, 2, Width - 5, Height - 5), ProgressAngle - 90, RemainderAngle)
  101. End Using
  102. End If
  103.  
  104.  
  105. If Percent Then
  106.  
  107. Using F1 As New Font("Segoe UI", 9, FontStyle.Bold)
  108.  
  109. Dim Progress_Text As String = ""
  110. If ShowMax Then
  111. Progress_Text = Progress & "/" & Max & " " & PostText
  112. Else
  113. Progress_Text = Progress & PostText
  114. End If
  115.  
  116. If ExceedingLimits Then
  117. CenterString(G, Progress_Text & ExceedingSign, F1, Color.FromArgb(100, 100, 100), New Rectangle(1, 1, Width, Height + 1))
  118. Else
  119. CenterString(G, Progress_Text, F1, Color.FromArgb(100, 100, 100), New Rectangle(1, 1, Width, Height + 1))
  120. End If
  121.  
  122. End Using
  123.  
  124. Else
  125.  
  126. If ExceedingLimits Then
  127. CenterString(G, Progress & ExceedingSign, New Font("Segoe UI", 9, FontStyle.Bold), Color.FromArgb(100, 100, 100), New Rectangle(1, 1, Width, Height + 1))
  128. Else
  129. CenterString(G, Progress, New Font("Segoe UI", 9, FontStyle.Bold), Color.FromArgb(100, 100, 100), New Rectangle(1, 1, Width, Height + 1))
  130. End If
  131.  
  132. End If
  133.  
  134. ExceedingLimits = False
  135.  
  136. CenterString(G, Text.ToUpper, New Font("Segoe UI", 6, FontStyle.Bold), Color.FromArgb(170, 170, 170), New Rectangle(2, 2, Width, Height + 27))
  137.  
  138. End Sub
  139.  
  140. End Class
Advertisement
Add Comment
Please, Sign In to add comment