Advertisement
netrosly

PopUp - GDI Control

Mar 28th, 2015
900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 5.75 KB | None | 0 0
  1. '///////////\\\\\\\\\\\\
  2. '|By Nettro from HF    |
  3. '|Completed 3/28/2015  |
  4. '|@5:43PM              |
  5. '|Enjoy please         |
  6. '///////////\\\\\\\\\\\\
  7. Public Class PopUp
  8.     Inherits Control
  9.     Property Description As String = "This is a description no longer than 155 characters."
  10.     Property Image As Image
  11.     Property Type As Kind
  12.     Enum Kind
  13.         Comp
  14.         Info
  15.         Warn
  16.         Erro
  17.     End Enum
  18.     Sub New()
  19.         Me.DoubleBuffered = True
  20.     End Sub
  21.  
  22.     Private Sub PopUp_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
  23.         '3d
  24.         e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(205, 205, 205)), New Rectangle(7, 8, Me.Width - 10, 55))
  25.         If Type = Kind.Comp Then
  26.             'front box
  27.             e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(102, 175, 82)), New Rectangle(0, 0, 60, 60))
  28.             e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(114, 181, 95)), New Rectangle(-1, 1, 60, 59))
  29.             'End color
  30.             e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(107, 177, 88)), New Rectangle(Me.Width - 3, 0, 3, 60))
  31.             'box
  32.             e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(61, 0, Me.Width - 65, 60))
  33.             'lips
  34.             e.Graphics.DrawLine(New Pen(Color.FromArgb(183, 218, 173)), New Point(60, 0), New Point(60, 59))
  35.             e.Graphics.DrawLine(New Pen(Color.FromArgb(183, 218, 173)), New Point(Me.Width - 4, 0), New Point(Me.Width - 4, 59))
  36.             'text
  37.             e.Graphics.DrawString(CheckLength(Me.Text, 25), New Font("Arial", 13, FontStyle.Regular), New SolidBrush(Color.FromArgb(110, 179, 90)), New Rectangle(75, 10, Me.Width - 85, 22))
  38.         ElseIf Type = Kind.Erro Then
  39.             'front box
  40.             e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(213, 26, 26)), New Rectangle(0, 0, 60, 60))
  41.             e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(216, 43, 43)), New Rectangle(-1, 1, 60, 59))
  42.             'End color
  43.             e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(216, 41, 41)), New Rectangle(Me.Width - 3, 0, 3, 60))
  44.             'box
  45.             e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(61, 0, Me.Width - 65, 60))
  46.             'lips
  47.             e.Graphics.DrawLine(New Pen(Color.FromArgb(235, 149, 149)), New Point(60, 0), New Point(60, 59))
  48.             e.Graphics.DrawLine(New Pen(Color.FromArgb(235, 149, 149)), New Point(Me.Width - 4, 0), New Point(Me.Width - 4, 59))
  49.             'text
  50.             e.Graphics.DrawString(CheckLength(Me.Text, 25), New Font("Arial", 13, FontStyle.Regular), New SolidBrush(Color.FromArgb(216, 43, 43)), New Rectangle(75, 10, Me.Width - 85, 22))
  51.         ElseIf Type = Kind.Warn Then
  52.             'front box
  53.             e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(244, 120, 23)), New Rectangle(0, 0, 60, 60))
  54.             e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(244, 130, 41)), New Rectangle(-1, 1, 60, 59))
  55.             'End color
  56.             e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(242, 124, 32)), New Rectangle(Me.Width - 3, 0, 3, 60))
  57.             'box
  58.             e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(61, 0, Me.Width - 65, 60))
  59.             'lips
  60.             e.Graphics.DrawLine(New Pen(Color.FromArgb(250, 192, 148)), New Point(60, 0), New Point(60, 59))
  61.             e.Graphics.DrawLine(New Pen(Color.FromArgb(250, 192, 148)), New Point(Me.Width - 4, 0), New Point(Me.Width - 4, 59))
  62.             'text
  63.             e.Graphics.DrawString(CheckLength(Me.Text, 25), New Font("Arial", 13, FontStyle.Regular), New SolidBrush(Color.FromArgb(245, 131, 49)), New Rectangle(75, 10, Me.Width - 85, 22))
  64.         ElseIf Type = Kind.Info Then
  65.             'front box
  66.             e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(17, 178, 170)), New Rectangle(0, 0, 60, 60))
  67.             e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(35, 184, 176)), New Rectangle(-1, 1, 60, 59))
  68.             'End color
  69.             e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(25, 179, 172)), New Rectangle(Me.Width - 3, 0, 3, 60))
  70.             'box
  71.             e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(61, 0, Me.Width - 65, 60))
  72.             'lips
  73.             e.Graphics.DrawLine(New Pen(Color.FromArgb(145, 219, 215)), New Point(60, 0), New Point(60, 59))
  74.             e.Graphics.DrawLine(New Pen(Color.FromArgb(145, 219, 215)), New Point(Me.Width - 4, 0), New Point(Me.Width - 4, 59))
  75.             'text
  76.             e.Graphics.DrawString(CheckLength(Me.Text, 25), New Font("Arial", 13, FontStyle.Regular), New SolidBrush(Color.FromArgb(54, 189, 181)), New Rectangle(75, 10, Me.Width - 85, 22))
  77.         End If
  78.  
  79.         'Desc
  80.         e.Graphics.DrawString(CheckLength(Description, 95), New Font("Arial", 10, FontStyle.Regular), New SolidBrush(Color.FromArgb(139, 139, 139)), New Rectangle(65, 30, Me.Width - 52, 26))
  81.         'Image
  82.         Try
  83.             e.Graphics.DrawImage(Image, New Rectangle(5, 5, 50, 50))
  84.         Catch ex As Exception
  85.         End Try
  86.     End Sub
  87.     Public Shared Function CheckLength(Text As String, Max As Integer)
  88.         Dim i As Integer = 0
  89.         Dim returnstr As String = ""
  90.         Dim wentover As Integer = 0
  91.         For Each Ch As String In Text
  92.             i += 1
  93.             If i <= Max Then
  94.                 returnstr += Ch
  95.             Else
  96.                 wentover += 1
  97.                 Ch = ""
  98.                 returnstr += Ch
  99.             End If
  100.         Next
  101.         If wentover > 0 Then
  102.             Return returnstr & "..."
  103.         Else
  104.             Return returnstr
  105.         End If
  106.     End Function
  107. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement