Hi ![:)](https://www.vb-paradise.de/wcf/images/smilies/smile.png)
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
![:)](https://www.vb-paradise.de/wcf/images/smilies/smile.png)
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 :)
VB.NET-Quellcode
- Option Strict On
- Option Explicit On
- Option Compare Binary
- Imports System
- Imports System.ComponentModel
- Imports System.Windows.Forms
- Imports System.Drawing
- Imports System.Drawing.Text
- Imports System.Drawing.Drawing2D
- Imports System.Runtime.InteropServices
- '
- ' CustomColors finished! :)
- '
- 'FINISHED: Form
- 'Update: changing the Font is now possible
- 'Update: CustomColors
- <Description("TwitterStyle Form"), DesignerCategory("Twitter Style")> _
- Public Class TwitForm
- Inherits Form
- <DefaultValue(False)> _
- Property UseCustomFont As Boolean
- Private Declare Function ReleaseCapture _
- Lib "user32" () As Integer
- Private Declare Function SendMessage _
- Lib "user32" Alias "SendMessageA" ( _
- ByVal hwnd As Integer, _
- ByVal wMsg As Integer, _
- ByVal wParam As Integer, _
- ByRef lParam As Object) As Integer
- Private Const WM_NCLBUTTONDOWN = &HA1
- Private Const HTCAPTION = 2
- Private internalStyle As FormTwitStyle = FormTwitStyle.CLASSIC_blue
- '
- 'CustomColors
- Private iccg1 As Color = Color.White
- Private iccg2 As Color = Color.Blue
- Property cc_Gradient1 As Color
- Get
- Return iccg1
- End Get
- Set(ByVal value As Color)
- iccg1 = value
- Invalidate()
- End Set
- End Property
- Property cc_Gradient2 As Color
- Get
- Return iccg2
- End Get
- Set(ByVal value As Color)
- iccg2 = value
- Invalidate()
- End Set
- End Property
- '/CustomColors
- '
- Enum FormTwitStyle As Integer
- CustomColors
- CLASSIC_blue
- NEW_black
- End Enum
- Property FormStyle As FormTwitStyle
- Get
- Return internalStyle
- End Get
- Set(ByVal value As FormTwitStyle)
- internalStyle = value
- 'CustomColors
- If Not internalStyle = FormTwitStyle.CustomColors AndAlso value = FormTwitStyle.CustomColors Then
- MessageBox.Show("CustomColors aktivated!" & vbCrLf & "Properties: cc_Gradient1 | cc_Gradient2")
- End If
- '/CustomColors
- Me.Invalidate()
- End Set
- End Property
- Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
- MyBase.OnPaintBackground(e)
- Dim pnt1 As New Point(CInt(Me.Width / 2), 0)
- Dim pnt2 As New Point(CInt(Me.Width / 2), 40)
- Dim fillcolor As LinearGradientBrush
- e.Graphics.SmoothingMode = SmoothingMode.HighQuality
- e.Graphics.CompositingQuality = CompositingQuality.HighQuality
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality
- Select Case FormStyle
- Case FormTwitStyle.CLASSIC_blue
- fillcolor = New LinearGradientBrush(pnt1, pnt2, Color.FromArgb(255, 0, 160, 209), Color.FromArgb(255, 0, 141, 185))
- e.Graphics.FillRectangle(fillcolor, New Rectangle(0, 0, Me.Width, 40))
- Case FormTwitStyle.NEW_black
- fillcolor = New LinearGradientBrush(pnt1, pnt2, Color.FromArgb(255, 63, 63, 63), Color.FromArgb(255, 47, 47, 47))
- e.Graphics.FillRectangle(fillcolor, New Rectangle(0, 0, Me.Width, 40))
- Case FormTwitStyle.CustomColors
- fillcolor = New LinearGradientBrush(pnt1, pnt2, Me.cc_Gradient1, Me.cc_Gradient2)
- e.Graphics.FillRectangle(fillcolor, New Rectangle(0, 0, Me.Width, 40))
- End Select
- With e.Graphics
- .DrawImage(My.Resources.bar_close, New Point(Me.Width - 32, 8))
- End With
- ApplyBorder(e)
- End Sub
- Sub ApplyBorder(ByVal e As PaintEventArgs)
- Dim pnt1 As New Point(CInt(e.ClipRectangle.Width / 2), 0)
- Dim pnt2 As New Point(CInt(e.ClipRectangle.Width / 2), e.ClipRectangle.Height)
- Dim stylebrush As LinearGradientBrush
- Select Case FormStyle
- Case FormTwitStyle.CLASSIC_blue
- stylebrush = New LinearGradientBrush(pnt1, pnt2, Color.FromArgb(255, 0, 160, 209), Color.FromArgb(255, 0, 141, 185))
- e.Graphics.DrawRectangle(New Pen(stylebrush, 6), e.ClipRectangle)
- Case FormTwitStyle.NEW_black
- stylebrush = New LinearGradientBrush(pnt1, pnt2, Color.FromArgb(255, 63, 63, 63), Color.FromArgb(255, 47, 47, 47))
- e.Graphics.DrawRectangle(New Pen(stylebrush, 6), e.ClipRectangle)
- Case Else
- stylebrush = New LinearGradientBrush(pnt1, pnt2, Me.cc_Gradient1, Me.cc_Gradient2)
- e.Graphics.DrawRectangle(New Pen(stylebrush, 6), e.ClipRectangle)
- End Select
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- MyBase.OnPaint(e)
- e.Graphics.SmoothingMode = SmoothingMode.HighQuality
- e.Graphics.CompositingQuality = CompositingQuality.HighQuality
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality
- With e.Graphics
- .TextRenderingHint = Drawing.Text.TextRenderingHint.SystemDefault
- End With
- Dim flags As TextFormatFlags = TextFormatFlags.Left Or TextFormatFlags.VerticalCenter
- Dim twitterfont As Font
- If UseCustomFont Then
- twitterfont = Me.Font
- Else
- twitterfont = TwitterFontLoader.GetFont(14, FontStyle.Bold)
- End If
- TextRenderer.DrawText(e.Graphics, Me.Text, twitterfont, New Rectangle(0, 0, Me.Width, 40), Color.White, Color.Transparent, flags)
- End Sub
- Private Sub appclose()
- Me.Close()
- End Sub
- Private Sub twitform_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove
- Dim tloc As Point = Me.PointToClient(Control.MousePosition)
- If tloc.Y <= 40 AndAlso e.Button = MouseButtons.Left Then
- Call ReleaseCapture()
- SendMessage(Me.Handle.ToInt32, WM_NCLBUTTONDOWN, HTCAPTION, 0)
- End If
- End Sub
- Private Sub twitform_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseClick
- Dim tloc As Point = Me.PointToClient(Control.MousePosition)
- If tloc.X >= (Me.Width - 32) AndAlso tloc.X <= (Me.Width - 8) _
- AndAlso (tloc.Y >= 8) AndAlso tloc.Y <= (32) Then
- appclose()
- End If
- End Sub
- Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
- MyBase.OnTextChanged(e)
- Me.Refresh()
- End Sub
- Sub New()
- Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
- End Sub
- End Class
- 'FINISHED: Button
- 'Update: Now Double-Buffered
- 'Thank you ThuCommix! :)
- 'Update: CustomColors
- <Description("TwitterStyle Button"), DesignerCategory("Twitter Style")> _
- Public Class TwitButton
- Inherits Control
- Dim internalmouseover As Boolean = False
- Dim internaltwitstyle As ButtonTwitStyle = ButtonTwitStyle.Classic_Blue
- '
- 'CustomColors
- Private iccg1 As Color = Color.White
- Private iccg2 As Color = Color.Blue
- Property cc_Gradient1 As Color
- Get
- Return iccg1
- End Get
- Set(ByVal value As Color)
- iccg1 = value
- Invalidate()
- End Set
- End Property
- Property cc_Gradient2 As Color
- Get
- Return iccg2
- End Get
- Set(ByVal value As Color)
- iccg2 = value
- Invalidate()
- End Set
- End Property
- '/CustomColors
- '
- Enum ButtonTwitStyle As Integer
- CustomColors
- Classic_Silver
- Classic_Blue
- End Enum
- Property Style As ButtonTwitStyle
- Get
- Return internaltwitstyle
- End Get
- Set(ByVal value As ButtonTwitStyle)
- internaltwitstyle = value
- Me.Refresh()
- End Set
- End Property
- Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
- MyBase.OnPaintBackground(pevent)
- Dim pnt1 As New Point(CInt(Me.Width / 2), 0)
- Dim pnt2 As New Point(CInt(Me.Width / 2), Me.Height)
- Dim fillcolor As LinearGradientBrush
- pevent.Graphics.SmoothingMode = SmoothingMode.HighQuality
- pevent.Graphics.CompositingQuality = CompositingQuality.HighQuality
- pevent.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- pevent.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality
- If Not internalmouseover Then
- Select Case Style
- Case ButtonTwitStyle.Classic_Silver
- fillcolor = New LinearGradientBrush(pnt1, pnt2, Color.FromArgb(255, 254, 254, 254), Color.FromArgb(255, 225, 225, 225))
- pevent.Graphics.FillRectangle(fillcolor, New Rectangle(0, 0, Me.Width, Me.Height))
- pevent.Graphics.DrawRectangle(New Pen(Brushes.Silver, 4), pevent.ClipRectangle)
- Case ButtonTwitStyle.Classic_Blue
- fillcolor = New LinearGradientBrush(pnt1, pnt2, Color.FromArgb(255, 76, 181, 214), Color.FromArgb(255, 0, 160, 209))
- pevent.Graphics.FillRectangle(fillcolor, New Rectangle(0, 0, Me.Width, Me.Height))
- pevent.Graphics.DrawRectangle(New Pen(Brushes.LightBlue, 4), pevent.ClipRectangle)
- Case ButtonTwitStyle.CustomColors
- fillcolor = New LinearGradientBrush(pnt1, pnt2, Me.cc_Gradient1, Me.cc_Gradient2)
- pevent.Graphics.FillRectangle(fillcolor, New Rectangle(0, 0, Me.Width, Me.Height))
- pevent.Graphics.DrawRectangle(New Pen(Brushes.LightBlue, 4), pevent.ClipRectangle)
- End Select
- Else
- Select Case Style
- Case ButtonTwitStyle.Classic_Silver
- fillcolor = New LinearGradientBrush(pnt1, pnt2, Color.FromArgb(255, 250, 250, 250), Color.FromArgb(255, 220, 220, 240))
- pevent.Graphics.FillRectangle(fillcolor, pevent.ClipRectangle)
- pevent.Graphics.DrawRectangle(New Pen(Brushes.Silver, 4), pevent.ClipRectangle)
- Case ButtonTwitStyle.Classic_Blue
- fillcolor = New LinearGradientBrush(pnt1, pnt2, Color.FromArgb(255, 70, 175, 200), Color.FromArgb(255, 0, 144, 200))
- pevent.Graphics.FillRectangle(fillcolor, New Rectangle(0, 0, Me.Width, Me.Height))
- pevent.Graphics.DrawRectangle(New Pen(Brushes.LightBlue, 4), pevent.ClipRectangle)
- End Select
- End If
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- MyBase.OnPaint(e)
- Dim flags As TextFormatFlags = TextFormatFlags.HorizontalCenter Or TextFormatFlags.VerticalCenter
- TextRenderer.DrawText(e.Graphics, Me.Text, Me.Font, e.ClipRectangle, Me.ForeColor, Color.Transparent, flags)
- End Sub
- Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
- MyBase.OnTextChanged(e)
- Me.Refresh()
- End Sub
- Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
- MyBase.OnMouseEnter(e)
- internalmouseover = True
- Me.Refresh()
- End Sub
- Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
- MyBase.OnMouseLeave(e)
- internalmouseover = False
- Me.Refresh()
- End Sub
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.UserPaint, True)
- End Sub
- End Class
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „MarcoQuinten“ ()