RazerX

FlatUI MsgBox

Jan 11th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 10.31 KB | None | 0 0
  1. ''' <summary>
  2. ''' Just A Simple MsgBox Copy
  3. '''
  4. ''' Made By SubGenius
  5. ''' Your project must include the FlatUI skin by iSynthesis
  6. ''' http://www.hackforums.net/showthread.php?tid=3559385
  7. '''
  8. ''' Change the "yourappname" to your applciation name
  9. ''' </summary>
  10. ''' <remarks></remarks>
  11. #Region "Form Design"
  12. <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
  13. Partial Class frmMessageBox
  14.     Inherits System.Windows.Forms.Form
  15.  
  16.     'Form overrides dispose to clean up the component list.
  17.     <System.Diagnostics.DebuggerNonUserCode()> _
  18.     Protected Overrides Sub Dispose(ByVal disposing As Boolean)
  19.         Try
  20.             If disposing AndAlso components IsNot Nothing Then
  21.                 components.Dispose()
  22.             End If
  23.         Finally
  24.             MyBase.Dispose(disposing)
  25.         End Try
  26.     End Sub
  27.  
  28.     'Required by the Windows Form Designer
  29.     Private components As System.ComponentModel.IContainer
  30.  
  31.     'NOTE: The following procedure is required by the Windows Form Designer
  32.     'It can be modified using the Windows Form Designer.  
  33.     'Do not modify it using the code editor.
  34.     <System.Diagnostics.DebuggerStepThrough()> _
  35.     Private Sub InitializeComponent()
  36.         Me.TitleLabel = New System.Windows.Forms.Label()
  37.         Me.MessageBox = New System.Windows.Forms.TextBox()
  38.         Me.YesButton = New yourappname.FlatButton()
  39.         Me.NoButton = New yourappname.FlatButton()
  40.         Me.Cancel_ExitButton = New yourappname.FlatButton()
  41.         Me.SuspendLayout()
  42.         '
  43.         'TitleLabel
  44.         '
  45.         Me.TitleLabel.AutoSize = True
  46.         Me.TitleLabel.Font = New System.Drawing.Font("Century", 20.0!)
  47.         Me.TitleLabel.Location = New System.Drawing.Point(4, 4)
  48.         Me.TitleLabel.Name = "TitleLabel"
  49.         Me.TitleLabel.Size = New System.Drawing.Size(248, 33)
  50.         Me.TitleLabel.TabIndex = 0
  51.         Me.TitleLabel.Text = "The Msgbox Label"
  52.         '
  53.         'MessageBox
  54.         '
  55.         Me.MessageBox.BackColor = System.Drawing.Color.FromArgb(CType(CType(32, Byte), Integer), CType(CType(32, Byte), Integer), CType(CType(39, Byte), Integer))
  56.         Me.MessageBox.BorderStyle = System.Windows.Forms.BorderStyle.None
  57.         Me.MessageBox.Cursor = System.Windows.Forms.Cursors.Arrow
  58.         Me.MessageBox.Enabled = False
  59.         Me.MessageBox.Font = New System.Drawing.Font("Century Gothic", 9.75!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(161, Byte))
  60.         Me.MessageBox.ForeColor = System.Drawing.Color.White
  61.         Me.MessageBox.HideSelection = False
  62.         Me.MessageBox.Location = New System.Drawing.Point(12, 40)
  63.         Me.MessageBox.Multiline = True
  64.         Me.MessageBox.Name = "MessageBox"
  65.         Me.MessageBox.ReadOnly = True
  66.         Me.MessageBox.Size = New System.Drawing.Size(549, 69)
  67.         Me.MessageBox.TabIndex = 10
  68.         '
  69.         'YesButton
  70.         '
  71.         Me.YesButton.BackColor = System.Drawing.Color.Transparent
  72.         Me.YesButton.BaseColor = System.Drawing.Color.Crimson
  73.         Me.YesButton.Cursor = System.Windows.Forms.Cursors.Hand
  74.         Me.YesButton.Font = New System.Drawing.Font("Segoe UI", 12.0!)
  75.         Me.YesButton.Location = New System.Drawing.Point(343, 115)
  76.         Me.YesButton.Name = "YesButton"
  77.         Me.YesButton.Rounded = False
  78.         Me.YesButton.Size = New System.Drawing.Size(106, 32)
  79.         Me.YesButton.TabIndex = 11
  80.         Me.YesButton.Text = "Yes"
  81.         Me.YesButton.TextColor = System.Drawing.Color.FromArgb(CType(CType(243, Byte), Integer), CType(CType(243, Byte), Integer), CType(CType(243, Byte), Integer))
  82.         Me.YesButton.Visible = False
  83.         '
  84.         'NoButton
  85.         '
  86.         Me.NoButton.BackColor = System.Drawing.Color.Transparent
  87.         Me.NoButton.BaseColor = System.Drawing.Color.Crimson
  88.         Me.NoButton.Cursor = System.Windows.Forms.Cursors.Hand
  89.         Me.NoButton.Font = New System.Drawing.Font("Segoe UI", 12.0!)
  90.         Me.NoButton.Location = New System.Drawing.Point(455, 115)
  91.         Me.NoButton.Name = "NoButton"
  92.         Me.NoButton.Rounded = False
  93.         Me.NoButton.Size = New System.Drawing.Size(106, 32)
  94.         Me.NoButton.TabIndex = 12
  95.         Me.NoButton.Text = "No"
  96.         Me.NoButton.TextColor = System.Drawing.Color.FromArgb(CType(CType(243, Byte), Integer), CType(CType(243, Byte), Integer), CType(CType(243, Byte), Integer))
  97.         Me.NoButton.Visible = False
  98.         '
  99.         'Cancel_ExitButton
  100.         '
  101.         Me.Cancel_ExitButton.BackColor = System.Drawing.Color.Transparent
  102.         Me.Cancel_ExitButton.BaseColor = System.Drawing.Color.Crimson
  103.         Me.Cancel_ExitButton.Cursor = System.Windows.Forms.Cursors.Hand
  104.         Me.Cancel_ExitButton.Font = New System.Drawing.Font("Segoe UI", 12.0!)
  105.         Me.Cancel_ExitButton.Location = New System.Drawing.Point(12, 115)
  106.         Me.Cancel_ExitButton.Name = "Cancel_ExitButton"
  107.         Me.Cancel_ExitButton.Rounded = False
  108.         Me.Cancel_ExitButton.Size = New System.Drawing.Size(106, 32)
  109.         Me.Cancel_ExitButton.TabIndex = 13
  110.         Me.Cancel_ExitButton.Text = "Cancel"
  111.         Me.Cancel_ExitButton.TextColor = System.Drawing.Color.FromArgb(CType(CType(243, Byte), Integer), CType(CType(243, Byte), Integer), CType(CType(243, Byte), Integer))
  112.         Me.Cancel_ExitButton.Visible = False
  113.         '
  114.         'frmMessageBox
  115.         '
  116.         Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None
  117.         Me.BackColor = System.Drawing.Color.FromArgb(CType(CType(22, Byte), Integer), CType(CType(22, Byte), Integer), CType(CType(29, Byte), Integer))
  118.         Me.ClientSize = New System.Drawing.Size(573, 151)
  119.         Me.Controls.Add(Me.YesButton)
  120.         Me.Controls.Add(Me.NoButton)
  121.         Me.Controls.Add(Me.Cancel_ExitButton)
  122.         Me.Controls.Add(Me.MessageBox)
  123.         Me.Controls.Add(Me.TitleLabel)
  124.         Me.Font = New System.Drawing.Font("Century", 10.0!)
  125.         Me.ForeColor = System.Drawing.Color.White
  126.         Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
  127.         Me.Name = "frmMessageBox"
  128.         Me.ShowIcon = False
  129.         Me.ShowInTaskbar = False
  130.         Me.Text = "yourappname - Message"
  131.         Me.ResumeLayout(False)
  132.         Me.PerformLayout()
  133.  
  134.     End Sub
  135.     Friend WithEvents TitleLabel As System.Windows.Forms.Label
  136.     Friend WithEvents MessageBox As System.Windows.Forms.TextBox
  137.     Friend WithEvents YesButton As yourappname.FlatButton
  138.     Friend WithEvents NoButton As yourappname.FlatButton
  139.     Friend WithEvents Cancel_ExitButton As yourappname.FlatButton
  140. End Class
  141. #End Region
  142.  
  143. #Region "Code"
  144. Public Class frmMessageBox
  145. #Region "Form Movment"
  146.  
  147.     Dim offset_x As Integer
  148.     Dim offset_y As Integer
  149.     Dim Form_location As Point
  150.     Dim ej As System.Windows.Forms.MouseEventArgs
  151.     Private IsFormBeingDragged As Boolean = False
  152.     Private MouseDownX As Integer
  153.     Private MouseDownY As Integer
  154.  
  155.     Private Sub FormRibbon_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown, TitleLabel.MouseDown
  156.         If e.Button = MouseButtons.Left Then
  157.             IsFormBeingDragged = True
  158.             MouseDownX = e.X
  159.             MouseDownY = e.Y
  160.         End If
  161.  
  162.     End Sub
  163.  
  164.     Private Sub FormRibbon_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove, TitleLabel.MouseMove
  165.         If IsFormBeingDragged Then
  166.             Dim temp As Point = New Point()
  167.  
  168.             temp.X = Me.Location.X + (e.X - MouseDownX)
  169.             temp.Y = Me.Location.Y + (e.Y - MouseDownY)
  170.             Me.Location = temp
  171.             temp = Nothing
  172.         End If
  173.     End Sub
  174.  
  175.     Private Sub FormRibbon_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp, TitleLabel.MouseUp
  176.         If e.Button = MouseButtons.Left Then
  177.             IsFormBeingDragged = False
  178.         End If
  179.     End Sub
  180. #End Region
  181.  
  182.  
  183.     Enum MessageBoxResponse
  184.         _Yes
  185.         _No
  186.         _Cancel
  187.         _Exit
  188.     End Enum
  189.     Enum VisibleButtons
  190.         Yes_No
  191.         Yes_No_Exit
  192.         Yes_No_Cancel
  193.         Cancel
  194.         _Exit
  195.     End Enum
  196.     Public Response As MessageBoxResponse
  197.  
  198.  
  199.     ''' <summary>
  200.     ''' Throw A MsgBox Message
  201.     ''' </summary>
  202.     ''' <param name="Title">Message Title</param>
  203.     ''' <param name="Message">Message Iner Message</param>
  204.     ''' <param name="type">Select The Visible Buttons</param>
  205.     ''' <returns></returns>
  206.     ''' <remarks></remarks>
  207.     Public Function ShowMessageBox(ByRef Title As String, ByRef Message As String, ByVal type As VisibleButtons) As MessageBoxResponse
  208.         TitleLabel.Text = Title
  209.         MessageBox.Text = Message
  210.         HideAll()
  211.         Select Case type
  212.             Case VisibleButtons.Cancel
  213.                 Cancel_ExitButton.Visible = True
  214.             Case VisibleButtons.Yes_No
  215.                 YesButton.Visible = True
  216.                 NoButton.Visible = True
  217.             Case VisibleButtons.Yes_No_Cancel
  218.                 YesButton.Visible = True
  219.                 NoButton.Visible = True
  220.                 Cancel_ExitButton.Visible = True
  221.             Case VisibleButtons.Yes_No_Exit
  222.                 YesButton.Visible = True
  223.                 NoButton.Visible = True
  224.                 Cancel_ExitButton.Visible = True
  225.                 Cancel_ExitButton.Text = "Exit"
  226.             Case VisibleButtons._Exit
  227.                 Cancel_ExitButton.Visible = True
  228.                 Cancel_ExitButton.Text = "Exit"
  229.         End Select
  230.         Me.ShowDialog()
  231.         Return Response
  232.     End Function
  233.  
  234.     Private Sub YesButton_Click(sender As Object, e As EventArgs) Handles YesButton.Click
  235.         Response = MessageBoxResponse._Yes
  236.         Me.Close()
  237.     End Sub
  238.  
  239.     Private Sub NoButton_Click(sender As Object, e As EventArgs) Handles NoButton.Click
  240.         Response = MessageBoxResponse._No
  241.         Me.Close()
  242.     End Sub
  243.  
  244.     Private Sub CancelButton_Click(sender As Object, e As EventArgs) Handles Cancel_ExitButton.Click
  245.         If Cancel_ExitButton.Text = "Cancel" Then
  246.             Response = MessageBoxResponse._Cancel
  247.         Else
  248.             Response = MessageBoxResponse._Exit
  249.         End If
  250.         Me.Close()
  251.     End Sub
  252.  
  253.     Sub HideAll()
  254.         YesButton.Visible = False
  255.         NoButton.Visible = False
  256.         Cancel_ExitButton.Visible = False
  257.     End Sub
  258. End Class
  259.  
  260. #End Region
Advertisement
Add Comment
Please, Sign In to add comment