Vollständiger TwitLib v2.3cc Quellcode

    • VB.NET

    Es gibt 4 Antworten in diesem Thema. Der letzte Beitrag () ist von MarcoQuinten.

      Vollständiger TwitLib v2.3cc Quellcode

      Hi :)

      Zu meinem 16. Geburtstag Release ich den kompletten Quellcode meiner TwitLib!
      Der Quellcode ist auf dem neuesten Stand (v2.3cc)

      Das hier ist der erste Teil, weil nicht alles hingepasst hat.
      Den zweiten Teil findet ihr weiter unten :)


      View code

      VB.NET-Quellcode

      1. Option Strict On
      2. Option Explicit On
      3. Option Compare Binary
      4. Imports System
      5. Imports System.ComponentModel
      6. Imports System.Windows.Forms
      7. Imports System.Drawing
      8. Imports System.Drawing.Text
      9. Imports System.Drawing.Drawing2D
      10. Imports System.Runtime.InteropServices
      11. '
      12. ' CustomColors finished! :)
      13. '
      14. 'FINISHED: Form
      15. 'Update: changing the Font is now possible
      16. 'Update: CustomColors
      17. <Description("TwitterStyle Form"), DesignerCategory("Twitter Style")> _
      18. Public Class TwitForm
      19. Inherits Form
      20. <DefaultValue(False)> _
      21. Property UseCustomFont As Boolean
      22. Private Declare Function ReleaseCapture _
      23. Lib "user32" () As Integer
      24. Private Declare Function SendMessage _
      25. Lib "user32" Alias "SendMessageA" ( _
      26. ByVal hwnd As Integer, _
      27. ByVal wMsg As Integer, _
      28. ByVal wParam As Integer, _
      29. ByRef lParam As Object) As Integer
      30. Private Const WM_NCLBUTTONDOWN = &HA1
      31. Private Const HTCAPTION = 2
      32. Private internalStyle As FormTwitStyle = FormTwitStyle.CLASSIC_blue
      33. '
      34. 'CustomColors
      35. Private iccg1 As Color = Color.White
      36. Private iccg2 As Color = Color.Blue
      37. Property cc_Gradient1 As Color
      38. Get
      39. Return iccg1
      40. End Get
      41. Set(ByVal value As Color)
      42. iccg1 = value
      43. Invalidate()
      44. End Set
      45. End Property
      46. Property cc_Gradient2 As Color
      47. Get
      48. Return iccg2
      49. End Get
      50. Set(ByVal value As Color)
      51. iccg2 = value
      52. Invalidate()
      53. End Set
      54. End Property
      55. '/CustomColors
      56. '
      57. Enum FormTwitStyle As Integer
      58. CustomColors
      59. CLASSIC_blue
      60. NEW_black
      61. End Enum
      62. Property FormStyle As FormTwitStyle
      63. Get
      64. Return internalStyle
      65. End Get
      66. Set(ByVal value As FormTwitStyle)
      67. internalStyle = value
      68. 'CustomColors
      69. If Not internalStyle = FormTwitStyle.CustomColors AndAlso value = FormTwitStyle.CustomColors Then
      70. MessageBox.Show("CustomColors aktivated!" & vbCrLf & "Properties: cc_Gradient1 | cc_Gradient2")
      71. End If
      72. '/CustomColors
      73. Me.Invalidate()
      74. End Set
      75. End Property
      76. Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
      77. MyBase.OnPaintBackground(e)
      78. Dim pnt1 As New Point(CInt(Me.Width / 2), 0)
      79. Dim pnt2 As New Point(CInt(Me.Width / 2), 40)
      80. Dim fillcolor As LinearGradientBrush
      81. e.Graphics.SmoothingMode = SmoothingMode.HighQuality
      82. e.Graphics.CompositingQuality = CompositingQuality.HighQuality
      83. e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
      84. e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality
      85. Select Case FormStyle
      86. Case FormTwitStyle.CLASSIC_blue
      87. fillcolor = New LinearGradientBrush(pnt1, pnt2, Color.FromArgb(255, 0, 160, 209), Color.FromArgb(255, 0, 141, 185))
      88. e.Graphics.FillRectangle(fillcolor, New Rectangle(0, 0, Me.Width, 40))
      89. Case FormTwitStyle.NEW_black
      90. fillcolor = New LinearGradientBrush(pnt1, pnt2, Color.FromArgb(255, 63, 63, 63), Color.FromArgb(255, 47, 47, 47))
      91. e.Graphics.FillRectangle(fillcolor, New Rectangle(0, 0, Me.Width, 40))
      92. Case FormTwitStyle.CustomColors
      93. fillcolor = New LinearGradientBrush(pnt1, pnt2, Me.cc_Gradient1, Me.cc_Gradient2)
      94. e.Graphics.FillRectangle(fillcolor, New Rectangle(0, 0, Me.Width, 40))
      95. End Select
      96. With e.Graphics
      97. .DrawImage(My.Resources.bar_close, New Point(Me.Width - 32, 8))
      98. End With
      99. ApplyBorder(e)
      100. End Sub
      101. Sub ApplyBorder(ByVal e As PaintEventArgs)
      102. Dim pnt1 As New Point(CInt(e.ClipRectangle.Width / 2), 0)
      103. Dim pnt2 As New Point(CInt(e.ClipRectangle.Width / 2), e.ClipRectangle.Height)
      104. Dim stylebrush As LinearGradientBrush
      105. Select Case FormStyle
      106. Case FormTwitStyle.CLASSIC_blue
      107. stylebrush = New LinearGradientBrush(pnt1, pnt2, Color.FromArgb(255, 0, 160, 209), Color.FromArgb(255, 0, 141, 185))
      108. e.Graphics.DrawRectangle(New Pen(stylebrush, 6), e.ClipRectangle)
      109. Case FormTwitStyle.NEW_black
      110. stylebrush = New LinearGradientBrush(pnt1, pnt2, Color.FromArgb(255, 63, 63, 63), Color.FromArgb(255, 47, 47, 47))
      111. e.Graphics.DrawRectangle(New Pen(stylebrush, 6), e.ClipRectangle)
      112. Case Else
      113. stylebrush = New LinearGradientBrush(pnt1, pnt2, Me.cc_Gradient1, Me.cc_Gradient2)
      114. e.Graphics.DrawRectangle(New Pen(stylebrush, 6), e.ClipRectangle)
      115. End Select
      116. End Sub
      117. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
      118. MyBase.OnPaint(e)
      119. e.Graphics.SmoothingMode = SmoothingMode.HighQuality
      120. e.Graphics.CompositingQuality = CompositingQuality.HighQuality
      121. e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
      122. e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality
      123. With e.Graphics
      124. .TextRenderingHint = Drawing.Text.TextRenderingHint.SystemDefault
      125. End With
      126. Dim flags As TextFormatFlags = TextFormatFlags.Left Or TextFormatFlags.VerticalCenter
      127. Dim twitterfont As Font
      128. If UseCustomFont Then
      129. twitterfont = Me.Font
      130. Else
      131. twitterfont = TwitterFontLoader.GetFont(14, FontStyle.Bold)
      132. End If
      133. TextRenderer.DrawText(e.Graphics, Me.Text, twitterfont, New Rectangle(0, 0, Me.Width, 40), Color.White, Color.Transparent, flags)
      134. End Sub
      135. Private Sub appclose()
      136. Me.Close()
      137. End Sub
      138. Private Sub twitform_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove
      139. Dim tloc As Point = Me.PointToClient(Control.MousePosition)
      140. If tloc.Y <= 40 AndAlso e.Button = MouseButtons.Left Then
      141. Call ReleaseCapture()
      142. SendMessage(Me.Handle.ToInt32, WM_NCLBUTTONDOWN, HTCAPTION, 0)
      143. End If
      144. End Sub
      145. Private Sub twitform_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseClick
      146. Dim tloc As Point = Me.PointToClient(Control.MousePosition)
      147. If tloc.X >= (Me.Width - 32) AndAlso tloc.X <= (Me.Width - 8) _
      148. AndAlso (tloc.Y >= 8) AndAlso tloc.Y <= (32) Then
      149. appclose()
      150. End If
      151. End Sub
      152. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
      153. MyBase.OnTextChanged(e)
      154. Me.Refresh()
      155. End Sub
      156. Sub New()
      157. Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
      158. End Sub
      159. End Class
      160. 'FINISHED: Button
      161. 'Update: Now Double-Buffered
      162. 'Thank you ThuCommix! :)
      163. 'Update: CustomColors
      164. <Description("TwitterStyle Button"), DesignerCategory("Twitter Style")> _
      165. Public Class TwitButton
      166. Inherits Control
      167. Dim internalmouseover As Boolean = False
      168. Dim internaltwitstyle As ButtonTwitStyle = ButtonTwitStyle.Classic_Blue
      169. '
      170. 'CustomColors
      171. Private iccg1 As Color = Color.White
      172. Private iccg2 As Color = Color.Blue
      173. Property cc_Gradient1 As Color
      174. Get
      175. Return iccg1
      176. End Get
      177. Set(ByVal value As Color)
      178. iccg1 = value
      179. Invalidate()
      180. End Set
      181. End Property
      182. Property cc_Gradient2 As Color
      183. Get
      184. Return iccg2
      185. End Get
      186. Set(ByVal value As Color)
      187. iccg2 = value
      188. Invalidate()
      189. End Set
      190. End Property
      191. '/CustomColors
      192. '
      193. Enum ButtonTwitStyle As Integer
      194. CustomColors
      195. Classic_Silver
      196. Classic_Blue
      197. End Enum
      198. Property Style As ButtonTwitStyle
      199. Get
      200. Return internaltwitstyle
      201. End Get
      202. Set(ByVal value As ButtonTwitStyle)
      203. internaltwitstyle = value
      204. Me.Refresh()
      205. End Set
      206. End Property
      207. Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
      208. MyBase.OnPaintBackground(pevent)
      209. Dim pnt1 As New Point(CInt(Me.Width / 2), 0)
      210. Dim pnt2 As New Point(CInt(Me.Width / 2), Me.Height)
      211. Dim fillcolor As LinearGradientBrush
      212. pevent.Graphics.SmoothingMode = SmoothingMode.HighQuality
      213. pevent.Graphics.CompositingQuality = CompositingQuality.HighQuality
      214. pevent.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
      215. pevent.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality
      216. If Not internalmouseover Then
      217. Select Case Style
      218. Case ButtonTwitStyle.Classic_Silver
      219. fillcolor = New LinearGradientBrush(pnt1, pnt2, Color.FromArgb(255, 254, 254, 254), Color.FromArgb(255, 225, 225, 225))
      220. pevent.Graphics.FillRectangle(fillcolor, New Rectangle(0, 0, Me.Width, Me.Height))
      221. pevent.Graphics.DrawRectangle(New Pen(Brushes.Silver, 4), pevent.ClipRectangle)
      222. Case ButtonTwitStyle.Classic_Blue
      223. fillcolor = New LinearGradientBrush(pnt1, pnt2, Color.FromArgb(255, 76, 181, 214), Color.FromArgb(255, 0, 160, 209))
      224. pevent.Graphics.FillRectangle(fillcolor, New Rectangle(0, 0, Me.Width, Me.Height))
      225. pevent.Graphics.DrawRectangle(New Pen(Brushes.LightBlue, 4), pevent.ClipRectangle)
      226. Case ButtonTwitStyle.CustomColors
      227. fillcolor = New LinearGradientBrush(pnt1, pnt2, Me.cc_Gradient1, Me.cc_Gradient2)
      228. pevent.Graphics.FillRectangle(fillcolor, New Rectangle(0, 0, Me.Width, Me.Height))
      229. pevent.Graphics.DrawRectangle(New Pen(Brushes.LightBlue, 4), pevent.ClipRectangle)
      230. End Select
      231. Else
      232. Select Case Style
      233. Case ButtonTwitStyle.Classic_Silver
      234. fillcolor = New LinearGradientBrush(pnt1, pnt2, Color.FromArgb(255, 250, 250, 250), Color.FromArgb(255, 220, 220, 240))
      235. pevent.Graphics.FillRectangle(fillcolor, pevent.ClipRectangle)
      236. pevent.Graphics.DrawRectangle(New Pen(Brushes.Silver, 4), pevent.ClipRectangle)
      237. Case ButtonTwitStyle.Classic_Blue
      238. fillcolor = New LinearGradientBrush(pnt1, pnt2, Color.FromArgb(255, 70, 175, 200), Color.FromArgb(255, 0, 144, 200))
      239. pevent.Graphics.FillRectangle(fillcolor, New Rectangle(0, 0, Me.Width, Me.Height))
      240. pevent.Graphics.DrawRectangle(New Pen(Brushes.LightBlue, 4), pevent.ClipRectangle)
      241. End Select
      242. End If
      243. End Sub
      244. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
      245. MyBase.OnPaint(e)
      246. Dim flags As TextFormatFlags = TextFormatFlags.HorizontalCenter Or TextFormatFlags.VerticalCenter
      247. TextRenderer.DrawText(e.Graphics, Me.Text, Me.Font, e.ClipRectangle, Me.ForeColor, Color.Transparent, flags)
      248. End Sub
      249. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
      250. MyBase.OnTextChanged(e)
      251. Me.Refresh()
      252. End Sub
      253. Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
      254. MyBase.OnMouseEnter(e)
      255. internalmouseover = True
      256. Me.Refresh()
      257. End Sub
      258. Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
      259. MyBase.OnMouseLeave(e)
      260. internalmouseover = False
      261. Me.Refresh()
      262. End Sub
      263. Sub New()
      264. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.UserPaint, True)
      265. End Sub
      266. End Class

      Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „MarcoQuinten“ ()

      Sorry, hat nicht alles in den ersten Post gepasst :D

      Code anzeigen

      VB.NET-Quellcode

      1. 'FINISHED: ProgressBar
      2. 'Update: Now with Marquee!
      3. 'Thank you ThuCommix! :)
      4. 'Update: CustomColors
      5. <Description("TwitterStyle ProgressBar"), DesignerCategory("Twitter Style")> _
      6. Public Class TwitProgressBar
      7. Inherits UserControl
      8. '
      9. 'CustomColors
      10. Private iccg1 As Color = Color.White
      11. Private iccg2 As Color = Color.Blue
      12. Property cc_Gradient1 As Color
      13. Get
      14. Return iccg1
      15. End Get
      16. Set(ByVal value As Color)
      17. iccg1 = value
      18. Invalidate()
      19. End Set
      20. End Property
      21. Property cc_Gradient2 As Color
      22. Get
      23. Return iccg2
      24. End Get
      25. Set(ByVal value As Color)
      26. iccg2 = value
      27. Invalidate()
      28. End Set
      29. End Property
      30. '/CustomColors
      31. '
      32. Private ivalue_max As Integer = 100
      33. Private ivalue_min As Integer = 0
      34. Private ivalue As Integer = 0
      35. Private icc As Boolean = False
      36. Property UseCustomColors As Boolean
      37. Get
      38. Return icc
      39. End Get
      40. Set(ByVal value As Boolean)
      41. icc = value
      42. Invalidate()
      43. End Set
      44. End Property
      45. Property Maximum As Integer
      46. Get
      47. Return ivalue_max
      48. End Get
      49. Set(ByVal extvalue As Integer)
      50. If extvalue > Minimum Then
      51. ivalue_max = extvalue
      52. Me.Invalidate()
      53. Else
      54. Throw New ArgumentException("Das Wert muss größer als Minimum sein")
      55. End If
      56. End Set
      57. End Property
      58. Property Minimum As Integer
      59. Get
      60. Return ivalue_min
      61. End Get
      62. Set(ByVal extvalue As Integer)
      63. If extvalue < Maximum Then
      64. ivalue_min = extvalue
      65. Me.Invalidate()
      66. Else
      67. Throw New ArgumentException("Das Wert muss kleiner als Maximum sein")
      68. End If
      69. End Set
      70. End Property
      71. Property Value As Integer
      72. Get
      73. Return ivalue
      74. End Get
      75. Set(ByVal extvalue As Integer)
      76. If extvalue >= Minimum AndAlso extvalue <= Maximum Then
      77. ivalue = extvalue
      78. Me.Invalidate()
      79. Else
      80. Throw New ArgumentException("Der Wert muss zwischen Minimum und Maximum liegen")
      81. End If
      82. End Set
      83. End Property
      84. Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
      85. MyBase.OnPaintBackground(e)
      86. With e.Graphics
      87. .FillRectangle(New SolidBrush(Color.LightGray), e.ClipRectangle)
      88. .DrawRectangle(New Pen(Brushes.Silver, 2.0!), e.ClipRectangle)
      89. End With
      90. End Sub
      91. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
      92. MyBase.OnPaint(e)
      93. '
      94. 'Alles schön Darstellen :)
      95. '
      96. e.Graphics.SmoothingMode = SmoothingMode.HighSpeed
      97. e.Graphics.CompositingQuality = CompositingQuality.HighQuality
      98. e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
      99. e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality
      100. '
      101. 'Rectangle zur ordnungsgemäßen Anzeige des Values berechnen
      102. '
      103. Dim valrect As New Rectangle(New Point(2, 2), New Size(2, e.ClipRectangle.Height - 2) + New Size(CInt(((MyBase.Width / Maximum) * Value) - 2), -2))
      104. '
      105. 'ProgressBar zeichnen
      106. '
      107. Dim pnt1 As New Point(CInt(e.ClipRectangle.Width / 2), 0)
      108. Dim pnt2 As New Point(CInt(e.ClipRectangle.Width / 2), e.ClipRectangle.Height)
      109. Dim stylebrush As LinearGradientBrush
      110. If Not UseCustomColors Then
      111. stylebrush = New LinearGradientBrush(pnt1, pnt2, Color.FromArgb(255, 76, 181, 214), Color.FromArgb(255, 0, 160, 209))
      112. Else
      113. stylebrush = New LinearGradientBrush(pnt1, pnt2, Me.cc_Gradient1, Me.cc_Gradient2)
      114. End If
      115. With e.Graphics
      116. If ProgressBarStyle = Style.Continuous Then
      117. .FillRectangle(stylebrush, valrect)
      118. Else
      119. 'Animated Marquee
      120. animationTimer.Start()
      121. .FillRectangle(stylebrush, SpinningRect)
      122. End If
      123. End With
      124. End Sub
      125. Sub New()
      126. Me.Height = 20
      127. Me.Width = 100
      128. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.UserPaint, True)
      129. AddHandler animationTimer.Tick, New EventHandler(AddressOf animationTimer_Tick)
      130. SpinningRect = New Rectangle(1, 1, Width \ 10, Height - 2)
      131. End Sub
      132. #Region "Marquee Code by ThuCommix THANX!"
      133. Private SpinningRect As New Rectangle()
      134. Private Sub animationTimer_Tick(ByVal sender As Object, ByVal e As EventArgs)
      135. 'Balken bewegen, vorsicht:wird auch im Designer ausgeführt, eventuell optimieren.
      136. animationTimer.Interval = Me.MarqueeAnimationSpeed
      137. If SpinningRect.Location.X >= Width - 5 Then
      138. SpinningRect.Location = New Point(2 - SpinningRect.Size.Width, 1)
      139. Me.Invalidate()
      140. Else
      141. SpinningRect.Location = New Point(SpinningRect.Location.X + 4, 1)
      142. Me.Invalidate()
      143. End If
      144. End Sub
      145. Protected Overrides Sub OnResize(ByVal eventargs As EventArgs)
      146. 'Marquee Balken an die Größe Anpassen
      147. SpinningRect = New Rectangle(SpinningRect.Location.X + 1, SpinningRect.Location.Y + 1, Width \ 4, Height - 2)
      148. Me.Invalidate()
      149. MyBase.OnResize(eventargs)
      150. End Sub
      151. Private animationTimer As New Timer()
      152. Private iinterval As Integer = 50
      153. Public Property MarqueeAnimationSpeed() As Integer
      154. Get
      155. Return iinterval
      156. End Get
      157. Set(ByVal value As Integer)
      158. iinterval = value
      159. animationTimer.Stop()
      160. animationTimer.Interval = iinterval
      161. animationTimer.Start()
      162. Me.Invalidate()
      163. End Set
      164. End Property
      165. Public Property ProgressBarStyle() As Style
      166. Get
      167. Return m_ProgressBarStyle
      168. End Get
      169. Set(ByVal value As Style)
      170. m_ProgressBarStyle = value
      171. End Set
      172. End Property
      173. Private m_ProgressBarStyle As Style
      174. Public Enum Style
      175. Continuous
      176. Marquee
      177. End Enum
      178. #End Region
      179. End Class
      180. 'FINISHED: Twitter FontLoader
      181. Public Module TwitterFontLoader
      182. 'PRIVATE FONT COLLECTION TO HOLD THE DYNAMIC FONT
      183. Private _pfc As PrivateFontCollection = Nothing
      184. Public ReadOnly Property GetFont(ByVal Size As Single, _
      185. ByVal style As FontStyle) As Font
      186. Get
      187. 'IF THIS IS THE FIRST TIME GETTING AN INSTANCE
      188. 'LOAD THE FONT FROM RESOURCES
      189. If _pfc Is Nothing Then LoadFont()
      190. 'RETURN A NEW FONT OBJECT BASED ON THE SIZE AND STYLE PASSED IN
      191. Return New Font(_pfc.Families(0), Size, style)
      192. End Get
      193. End Property
      194. Private Sub LoadFont()
      195. Try
      196. 'INIT THE FONT COLLECTION
      197. _pfc = New PrivateFontCollection
      198. 'LOAD MEMORY POINTER FOR FONT RESOURCE
      199. Dim fontMemPointer As IntPtr = _
      200. Marshal.AllocCoTaskMem( _
      201. My.Resources.PICOBLA_.Length)
      202. 'COPY THE DATA TO THE MEMORY LOCATION
      203. Marshal.Copy(My.Resources.PICOBLA_, _
      204. 0, fontMemPointer, _
      205. My.Resources.PICOBLA_.Length)
      206. 'LOAD THE MEMORY FONT INTO THE PRIVATE FONT COLLECTION
      207. _pfc.AddMemoryFont(fontMemPointer, _
      208. My.Resources.PICOBLA_.Length)
      209. 'FREE UNSAFE MEMORY
      210. Marshal.FreeCoTaskMem(fontMemPointer)
      211. Catch ex As Exception
      212. 'ERROR LOADING FONT. HANDLE EXCEPTION HERE
      213. End Try
      214. End Sub
      215. End Module
      216. 'FINISHED: CheckBox
      217. <Description("TwitterStyle CheckBox"), DesignerCategory("Twitter Style")> _
      218. Public Class twitCheckBox
      219. Inherits CheckBox
      220. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
      221. MyBase.OnPaint(e)
      222. e.Graphics.SmoothingMode = SmoothingMode.HighQuality
      223. e.Graphics.CompositingQuality = CompositingQuality.HighQuality
      224. e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
      225. e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality
      226. Dim siz As Size = CheckBoxRenderer.GetGlyphSize(e.Graphics, VisualStyles.CheckBoxState.UncheckedNormal)
      227. Dim pnt1 As New Point(CInt(e.ClipRectangle.Width / 2), 0)
      228. Dim pnt2 As New Point(CInt(e.ClipRectangle.Width / 2), e.ClipRectangle.Height)
      229. Dim stylebrush As New LinearGradientBrush(pnt1, pnt2, Color.FromArgb(255, 76, 181, 214), Color.FromArgb(255, 0, 160, 209))
      230. If Me.Checked = False Then
      231. e.Graphics.FillRectangle(stylebrush, New Rectangle(New Point(0, 0), siz))
      232. Else
      233. e.Graphics.FillRectangle(stylebrush, New Rectangle(New Point(0, 0), siz))
      234. e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(255, 22, 22, 22)), New Rectangle(New Point(2, 2), New Size(siz.Width - 4, siz.Height - 4)))
      235. End If
      236. End Sub
      237. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
      238. MyBase.OnTextChanged(e)
      239. Me.Refresh()
      240. End Sub
      241. End Class
      242. 'FINISHED: FollowBox
      243. 'Update: added AntiAliasing
      244. Public Class FollowBox
      245. Inherits Control
      246. <DefaultValue("Follow Me")> _
      247. Public Overrides Property Text As String
      248. Get
      249. Return (MyBase.Text)
      250. End Get
      251. Set(ByVal value As String)
      252. MyBase.Text = value
      253. Me.Refresh()
      254. End Set
      255. End Property
      256. Sub New()
      257. Me.Width = 200
      258. Me.Height = 64
      259. End Sub
      260. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
      261. MyBase.OnPaint(e)
      262. With e.Graphics
      263. .SmoothingMode = SmoothingMode.HighQuality
      264. .TextRenderingHint = TextRenderingHint.SystemDefault
      265. .InterpolationMode = InterpolationMode.HighQualityBicubic
      266. .DrawImage(My.Resources.twitterbird, New Rectangle(0, 0, 64, 64))
      267. End With
      268. Dim rect As New Rectangle(64, 0, e.ClipRectangle.Width, e.ClipRectangle.Height)
      269. Dim flags As TextFormatFlags = TextFormatFlags.SingleLine Or TextFormatFlags.VerticalCenter Or TextFormatFlags.Left
      270. TextRenderer.DrawText(e.Graphics, Me.Text, TwitterFontLoader.GetFont(Me.Font.Size, FontStyle.Bold), rect, Me.ForeColor, Color.Transparent, flags)
      271. End Sub
      272. End Class
      273. 'FINISHED: TweetBox
      274. Public Class TweetBox
      275. Inherits Control
      276. Dim isubtext As String = "gerade eben"
      277. Dim ititle As String = "@Twitter_Username"
      278. Dim iavatar As Image = My.Resources.twitterbird
      279. Property Text_Sub As String
      280. Get
      281. Return isubtext
      282. End Get
      283. Set(ByVal value As String)
      284. isubtext = value
      285. RaiseEvent SubTextChanged(isubtext)
      286. Me.Refresh()
      287. End Set
      288. End Property
      289. Property Text_Title As String
      290. Get
      291. Return ititle
      292. End Get
      293. Set(ByVal value As String)
      294. ititle = value
      295. RaiseEvent TitleChanged(ititle)
      296. Me.Refresh()
      297. End Set
      298. End Property
      299. Property Text_Avatar As Image
      300. Get
      301. Return iavatar
      302. End Get
      303. Set(ByVal value As Image)
      304. iavatar = value
      305. RaiseEvent AvatarChanged(iavatar)
      306. Me.Refresh()
      307. End Set
      308. End Property
      309. Property TitleFont As Font = New Font(FontFamily.GenericSerif, 12.25)
      310. Property TitleColor As Color = Color.Black
      311. Property SubColor As Color = Color.DimGray
      312. Property SubFont As Font = New Font(FontFamily.GenericMonospace, 8.25)
      313. Event TitleChanged(ByVal newTitle As String)
      314. Event SubTextChanged(ByVal newSubText As String)
      315. Event AvatarChanged(ByVal newAvatar As Image)
      316. Sub New()
      317. MyBase.Height = 64
      318. MyBase.Width = 250
      319. End Sub
      320. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
      321. MyBase.OnPaint(e)
      322. With e.Graphics
      323. .InterpolationMode = InterpolationMode.HighQualityBicubic
      324. .SmoothingMode = SmoothingMode.HighQuality
      325. .PixelOffsetMode = PixelOffsetMode.HighQuality
      326. .TextRenderingHint = TextRenderingHint.SystemDefault
      327. '
      328. 'Border
      329. '
      330. .DrawRectangle(New Pen(Brushes.SkyBlue, -4.0!), e.ClipRectangle)
      331. .DrawRectangle(New Pen(Brushes.DeepSkyBlue, 2.0!), e.ClipRectangle)
      332. '
      333. 'Avatar
      334. '
      335. .DrawImage(Me.Text_Avatar, New Rectangle(0, 0, 64, 64))
      336. .DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(75, Color.White)), 2.0!), New Rectangle(0, 0, 64, 64))
      337. '
      338. 'Title
      339. '
      340. TextRenderer.DrawText(e.Graphics, Me.Text_Title, Me.TitleFont, New Rectangle(66, 0, e.ClipRectangle.Width - 25, 20), Me.TitleColor, Color.Transparent, TextFormatFlags.Left Or TextFormatFlags.SingleLine)
      341. '
      342. 'Text
      343. '
      344. TextRenderer.DrawText(e.Graphics, Me.Text, Me.Font, New Rectangle(66, 20, e.ClipRectangle.Width, e.ClipRectangle.Height), Me.ForeColor, Color.Transparent, TextFormatFlags.Left Or TextFormatFlags.Top)
      345. '
      346. 'SubText
      347. '
      348. TextRenderer.DrawText(e.Graphics, Me.Text_Sub, Me.SubFont, New Rectangle(66, 0, e.ClipRectangle.Width, e.ClipRectangle.Height), Me.SubColor, Color.Transparent, TextFormatFlags.Bottom Or TextFormatFlags.Left)
      349. End With
      350. End Sub
      351. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
      352. MyBase.OnTextChanged(e)
      353. Me.Refresh()
      354. End Sub
      355. End Class



      Die Resourcen sind hier zu finden (müssen noch umbenannt werden :)):
      Bilder
      • close.png

        1,2 kB, 24×24, 391 mal angesehen
      • twitter-bird-light-transparent-bgs.png

        3,37 kB, 300×300, 97 mal angesehen