SHARE
TWEET

Reactor Combobox 2

Roland-2 Jan 26th, 2020 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Drawing.Drawing2D
  2.  
  3. '-------------------- [ /ComboBox ] ---------------------
  4. Public Class ReactorComboBox : Inherits ComboBox
  5.  
  6. #Region " Control Help - Properties & Flicker Control "
  7.     Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  8.     End Sub
  9.     Private _StartIndex As Integer = 0
  10.     Public Property StartIndex() As Integer
  11.         Get
  12.             Return _StartIndex
  13.         End Get
  14.         Set(ByVal value As Integer)
  15.             _StartIndex = value
  16.  
  17.             Try
  18.                 If Not MyBase.SelectedIndex <> Nothing Then
  19.                     MyBase.SelectedIndex = value
  20.                 End If
  21.  
  22.             Catch
  23.             End Try
  24.             Invalidate()
  25.         End Set
  26.     End Property
  27.     Private LightBlack As Color = Color.FromArgb(37, 37, 37)
  28.     Private LighterBlack As Color = Color.FromArgb(60, 60, 60)
  29.     Sub ReplaceItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Me.DrawItem
  30.         e.DrawBackground()
  31.         Try
  32.  
  33.  
  34.             If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  35.                 e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(255, 0, 36, 0)), e.Bounds) '37 37 37
  36.             End If
  37.             If e.Index > -1 Then
  38.                 Using b As New SolidBrush(e.ForeColor)
  39.                     e.Graphics.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), e.Font, b, e.Bounds)
  40.                 End Using
  41.             End If
  42.  
  43.  
  44.         Catch
  45.         End Try
  46.  
  47.         e.DrawFocusRectangle()
  48.     End Sub
  49.     Protected Sub DrawTriangle(ByVal Clr As Color, ByVal FirstPoint As Point, ByVal SecondPoint As Point, ByVal ThirdPoint As Point, ByVal G As Graphics)
  50.         Dim points As New List(Of Point)()
  51.         points.Add(FirstPoint)
  52.         points.Add(SecondPoint)
  53.         points.Add(ThirdPoint)
  54.         G.FillPolygon(New SolidBrush(Clr), points.ToArray)
  55.     End Sub
  56. #End Region
  57.  
  58.     Sub New()
  59.         MyBase.New()
  60.         SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  61.         ControlStyles.ResizeRedraw Or _
  62.         ControlStyles.UserPaint Or _
  63.         ControlStyles.DoubleBuffer, True)
  64.         DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  65.         BackColor = Color.Black
  66.         ForeColor = Color.White
  67.         DropDownStyle = ComboBoxStyle.DropDownList
  68.         DoubleBuffered = True
  69.         Invalidate()
  70.     End Sub
  71.  
  72.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  73.         MyBase.OnPaint(e)
  74.         Dim G As Graphics = e.Graphics
  75.         Dim T As LinearGradientBrush = New LinearGradientBrush(New Rectangle(0, 0, Width, 10), Color.FromArgb(62, Color.White), Color.FromArgb(30, Color.White), 90S)
  76.         Dim DrawCornersBrush As SolidBrush
  77.         DrawCornersBrush = New SolidBrush(Color.FromArgb(37, 37, 37))
  78.         Try
  79.             With G
  80.                 .SmoothingMode = SmoothingMode.HighQuality
  81.                 .Clear(Color.FromArgb(37, 37, 37))
  82.                 .FillRectangle(T, New Rectangle(Width - 20, 0, Width, 9))
  83.                 .DrawLine(Pens.Black, Width - 20, 0, Width - 20, Height)
  84.                 Try
  85.                     '.DrawString(Items(SelectedIndex).ToString, Font, Brushes.White, New Rectangle(New Point(3, 3), New Size(Width - 18, Height)))
  86.                     .DrawString(Text, Font, Brushes.White, New Rectangle(3, 0, Width - 20, Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
  87.                 Catch
  88.                 End Try
  89.  
  90.                 .DrawLine(New Pen(New SolidBrush(Color.FromArgb(37, 37, 37))), 0, 0, 0, 0)
  91.                 .DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(0, 0, 0))), New Rectangle(1, 1, Width - 3, Height - 3))
  92.  
  93.                 .DrawLine(New Pen(New SolidBrush(Color.FromArgb(45, 45, 45))), 0, 0, Width, 0)
  94.                 .DrawLine(New Pen(New SolidBrush(Color.FromArgb(45, 45, 45))), 0, 0, 0, Height)
  95.                 .DrawLine(New Pen(New SolidBrush(Color.FromArgb(45, 45, 45))), Width - 1, 0, Width - 1, Height)
  96.                 .DrawLine(New Pen(New SolidBrush(Color.FromArgb(70, 70, 70))), 0, Height - 1, Width, Height - 1)
  97.  
  98.                 DrawTriangle(Color.White, New Point(Width - 14, 8), New Point(Width - 7, 8), New Point(Width - 11, 11), G)
  99.             End With
  100.         Catch
  101.         End Try
  102.     End Sub
  103. End Class
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top