Rabu, 29 Februari 2012

BIKIN POP UP VB.NET

PREVIEW


CODE :


Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        textBoxContent.Text = "This is a sample content, it can spread on multiple lines"
        textBoxTitle.Text = "Title"
        textBoxDelayShowing.Text = "500"
        textBoxDelayStaying.Text = "3000"
        textBoxDelayHiding.Text = "500"
        checkBoxSelectionRectangle.Checked = True
        checkBoxTitleClickable.Checked = False
        checkBoxContentClickable.Checked = True
        checkBoxCloseClickable.Checked = True
        checkBoxKeepVisibleOnMouseOver.Checked = True
        checkBoxReShowOnMouseOver.Checked = False

        taskbarNotifier1 = New TaskBarNotifier()
        taskbarNotifier1.SetBackgroundBitmap(New Bitmap(MyClass.GetType(), "skin.bmp"), Color.FromArgb(255, 0, 255))
        taskbarNotifier1.SetCloseBitmap(New Bitmap(MyClass.GetType(), "close.bmp"), Color.FromArgb(255, 0, 255), New Point(127, 8))
        taskbarNotifier1.TitleRectangle = New Rectangle(40, 9, 70, 25)
        taskbarNotifier1.TextRectangle = New Rectangle(8, 41, 133, 68)

        taskbarNotifier2 = New TaskBarNotifier()
        taskbarNotifier2.SetBackgroundBitmap(New Bitmap(MyClass.GetType(), "skin2.bmp"), Color.FromArgb(255, 0, 255))
        taskbarNotifier2.SetCloseBitmap(New Bitmap(MyClass.GetType(), "close2.bmp"), Color.FromArgb(255, 0, 255), New Point(300, 74))
        taskbarNotifier2.TitleRectangle = New Rectangle(123, 80, 176, 16)
        taskbarNotifier2.TextRectangle = New Rectangle(116, 97, 197, 22)

        taskbarNotifier3 = New TaskBarNotifier()
        taskbarNotifier3.SetBackgroundBitmap(New Bitmap(MyClass.GetType(), "skin3.bmp"), Color.FromArgb(255, 0, 255))
        taskbarNotifier3.SetCloseBitmap(New Bitmap(MyClass.GetType(), "close.bmp"), Color.FromArgb(255, 0, 255), New Point(280, 57))
        taskbarNotifier3.TitleRectangle = New Rectangle(150, 57, 125, 28)
        taskbarNotifier3.TextRectangle = New Rectangle(75, 92, 215, 55)

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer. 
    'Do not modify it using the code editor.
    Friend WithEvents groupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents label2 As System.Windows.Forms.Label
    Friend WithEvents label1 As System.Windows.Forms.Label
    Friend WithEvents textBoxContent As System.Windows.Forms.TextBox
    Friend WithEvents textBoxTitle As System.Windows.Forms.TextBox
    Friend WithEvents groupBox2 As System.Windows.Forms.GroupBox
    Friend WithEvents label5 As System.Windows.Forms.Label
    Friend WithEvents label4 As System.Windows.Forms.Label
    Friend WithEvents label3 As System.Windows.Forms.Label
    Friend WithEvents textBoxDelayShowing As System.Windows.Forms.TextBox
    Friend WithEvents textBoxDelayStaying As System.Windows.Forms.TextBox
    Friend WithEvents textBoxDelayHiding As System.Windows.Forms.TextBox
    Friend WithEvents groupBox3 As System.Windows.Forms.GroupBox
    Friend WithEvents checkBoxCloseClickable As System.Windows.Forms.CheckBox
    Friend WithEvents checkBoxContentClickable As System.Windows.Forms.CheckBox
    Friend WithEvents checkBoxTitleClickable As System.Windows.Forms.CheckBox
    Friend WithEvents checkBoxSelectionRectangle As System.Windows.Forms.CheckBox
    Friend WithEvents ButtonShowPopup2 As System.Windows.Forms.Button
    Friend WithEvents ButtonShowPopup1 As System.Windows.Forms.Button
    Friend WithEvents ButtonShowPopup3 As System.Windows.Forms.Button
    Friend WithEvents checkBoxKeepVisibleOnMouseOver As System.Windows.Forms.CheckBox
    Friend WithEvents checkBoxReShowOnMouseOver As System.Windows.Forms.CheckBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.groupBox1 = New System.Windows.Forms.GroupBox()
        Me.label2 = New System.Windows.Forms.Label()
        Me.label1 = New System.Windows.Forms.Label()
        Me.textBoxContent = New System.Windows.Forms.TextBox()
        Me.textBoxTitle = New System.Windows.Forms.TextBox()
        Me.groupBox2 = New System.Windows.Forms.GroupBox()
        Me.label5 = New System.Windows.Forms.Label()
        Me.label4 = New System.Windows.Forms.Label()
        Me.label3 = New System.Windows.Forms.Label()
        Me.textBoxDelayShowing = New System.Windows.Forms.TextBox()
        Me.textBoxDelayStaying = New System.Windows.Forms.TextBox()
        Me.textBoxDelayHiding = New System.Windows.Forms.TextBox()
        Me.groupBox3 = New System.Windows.Forms.GroupBox()
        Me.checkBoxCloseClickable = New System.Windows.Forms.CheckBox()
        Me.checkBoxContentClickable = New System.Windows.Forms.CheckBox()
        Me.checkBoxTitleClickable = New System.Windows.Forms.CheckBox()
        Me.checkBoxSelectionRectangle = New System.Windows.Forms.CheckBox()
        Me.ButtonShowPopup2 = New System.Windows.Forms.Button()
        Me.ButtonShowPopup1 = New System.Windows.Forms.Button()
        Me.ButtonShowPopup3 = New System.Windows.Forms.Button()
        Me.checkBoxKeepVisibleOnMouseOver = New System.Windows.Forms.CheckBox()
        Me.checkBoxReShowOnMouseOver = New System.Windows.Forms.CheckBox()
        Me.groupBox1.SuspendLayout()
        Me.groupBox2.SuspendLayout()
        Me.groupBox3.SuspendLayout()
        Me.SuspendLayout()
        '
        'groupBox1
        '
        Me.groupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.label2, Me.label1, Me.textBoxContent, Me.textBoxTitle})
        Me.groupBox1.Location = New System.Drawing.Point(4, 4)
        Me.groupBox1.Name = "groupBox1"
        Me.groupBox1.Size = New System.Drawing.Size(296, 88)
        Me.groupBox1.TabIndex = 8
        Me.groupBox1.TabStop = False
        Me.groupBox1.Text = "Text"
        '
        'label2
        '
        Me.label2.Location = New System.Drawing.Point(12, 52)
        Me.label2.Name = "label2"
        Me.label2.Size = New System.Drawing.Size(48, 16)
        Me.label2.TabIndex = 10
        Me.label2.Text = "Content"
        '
        'label1
        '
        Me.label1.Location = New System.Drawing.Point(12, 20)
        Me.label1.Name = "label1"
        Me.label1.Size = New System.Drawing.Size(40, 16)
        Me.label1.TabIndex = 9
        Me.label1.Text = "Title"
        '
        'textBoxContent
        '
        Me.textBoxContent.Location = New System.Drawing.Point(60, 52)
        Me.textBoxContent.Name = "textBoxContent"
        Me.textBoxContent.Size = New System.Drawing.Size(224, 20)
        Me.textBoxContent.TabIndex = 8
        Me.textBoxContent.Text = "textBoxContent"
        '
        'textBoxTitle
        '
        Me.textBoxTitle.Location = New System.Drawing.Point(60, 20)
        Me.textBoxTitle.Name = "textBoxTitle"
        Me.textBoxTitle.Size = New System.Drawing.Size(224, 20)
        Me.textBoxTitle.TabIndex = 7
        Me.textBoxTitle.Text = "textBoxTitle"
        '
        'groupBox2
        '
        Me.groupBox2.Controls.AddRange(New System.Windows.Forms.Control() {Me.label5, Me.label4, Me.label3, Me.textBoxDelayShowing, Me.textBoxDelayStaying, Me.textBoxDelayHiding})
        Me.groupBox2.Location = New System.Drawing.Point(4, 100)
        Me.groupBox2.Name = "groupBox2"
        Me.groupBox2.Size = New System.Drawing.Size(296, 88)
        Me.groupBox2.TabIndex = 15
        Me.groupBox2.TabStop = False
        Me.groupBox2.Text = "Animation Delays (ms)"
        '
        'label5
        '
        Me.label5.Location = New System.Drawing.Point(200, 28)
        Me.label5.Name = "label5"
        Me.label5.Size = New System.Drawing.Size(80, 16)
        Me.label5.TabIndex = 19
        Me.label5.Text = "Delay Hiding"
        '
        'label4
        '
        Me.label4.Location = New System.Drawing.Point(112, 28)
        Me.label4.Name = "label4"
        Me.label4.Size = New System.Drawing.Size(80, 16)
        Me.label4.TabIndex = 18
        Me.label4.Text = "Delay Staying"
        '
        'label3
        '
        Me.label3.Location = New System.Drawing.Point(16, 28)
        Me.label3.Name = "label3"
        Me.label3.Size = New System.Drawing.Size(80, 16)
        Me.label3.TabIndex = 17
        Me.label3.Text = "Delay Showing"
        '
        'textBoxDelayShowing
        '
        Me.textBoxDelayShowing.Location = New System.Drawing.Point(24, 52)
        Me.textBoxDelayShowing.Name = "textBoxDelayShowing"
        Me.textBoxDelayShowing.Size = New System.Drawing.Size(56, 20)
        Me.textBoxDelayShowing.TabIndex = 16
        Me.textBoxDelayShowing.Text = "textBoxDelayShowing"
        '
        'textBoxDelayStaying
        '
        Me.textBoxDelayStaying.Location = New System.Drawing.Point(120, 52)
        Me.textBoxDelayStaying.Name = "textBoxDelayStaying"
        Me.textBoxDelayStaying.Size = New System.Drawing.Size(56, 20)
        Me.textBoxDelayStaying.TabIndex = 15
        Me.textBoxDelayStaying.Text = "textBoxDelayStaying"
        '
        'textBoxDelayHiding
        '
        Me.textBoxDelayHiding.Location = New System.Drawing.Point(208, 52)
        Me.textBoxDelayHiding.Name = "textBoxDelayHiding"
        Me.textBoxDelayHiding.Size = New System.Drawing.Size(56, 20)
        Me.textBoxDelayHiding.TabIndex = 14
        Me.textBoxDelayHiding.Text = "textBoxDelayHiding"
        '
        'groupBox3
        '
        Me.groupBox3.Controls.AddRange(New System.Windows.Forms.Control() {Me.checkBoxReShowOnMouseOver, Me.checkBoxKeepVisibleOnMouseOver, Me.checkBoxCloseClickable, Me.checkBoxContentClickable, Me.checkBoxTitleClickable, Me.checkBoxSelectionRectangle})
        Me.groupBox3.Location = New System.Drawing.Point(4, 192)
        Me.groupBox3.Name = "groupBox3"
        Me.groupBox3.Size = New System.Drawing.Size(296, 116)
        Me.groupBox3.TabIndex = 16
        Me.groupBox3.TabStop = False
        Me.groupBox3.Text = "Options"
        '
        'checkBoxCloseClickable
        '
        Me.checkBoxCloseClickable.Location = New System.Drawing.Point(16, 48)
        Me.checkBoxCloseClickable.Name = "checkBoxCloseClickable"
        Me.checkBoxCloseClickable.Size = New System.Drawing.Size(104, 16)
        Me.checkBoxCloseClickable.TabIndex = 3
        Me.checkBoxCloseClickable.Text = "Close Clickable"
        '
        'checkBoxContentClickable
        '
        Me.checkBoxContentClickable.Location = New System.Drawing.Point(128, 24)
        Me.checkBoxContentClickable.Name = "checkBoxContentClickable"
        Me.checkBoxContentClickable.Size = New System.Drawing.Size(112, 16)
        Me.checkBoxContentClickable.TabIndex = 1
        Me.checkBoxContentClickable.Text = "Content Clickable"
        '
        'checkBoxTitleClickable
        '
        Me.checkBoxTitleClickable.Location = New System.Drawing.Point(16, 24)
        Me.checkBoxTitleClickable.Name = "checkBoxTitleClickable"
        Me.checkBoxTitleClickable.Size = New System.Drawing.Size(96, 16)
        Me.checkBoxTitleClickable.TabIndex = 0
        Me.checkBoxTitleClickable.Text = "Title Clickable"
        '
        'checkBoxSelectionRectangle
        '
        Me.checkBoxSelectionRectangle.Location = New System.Drawing.Point(128, 48)
        Me.checkBoxSelectionRectangle.Name = "checkBoxSelectionRectangle"
        Me.checkBoxSelectionRectangle.Size = New System.Drawing.Size(160, 16)
        Me.checkBoxSelectionRectangle.TabIndex = 2
        Me.checkBoxSelectionRectangle.Text = "Show Selection Rectangle"
        '
        'ButtonShowPopup2
        '
        Me.ButtonShowPopup2.Location = New System.Drawing.Point(108, 316)
        Me.ButtonShowPopup2.Name = "ButtonShowPopup2"
        Me.ButtonShowPopup2.Size = New System.Drawing.Size(88, 23)
        Me.ButtonShowPopup2.TabIndex = 18
        Me.ButtonShowPopup2.Text = "Show popup 2"
        '
        'ButtonShowPopup1
        '
        Me.ButtonShowPopup1.Location = New System.Drawing.Point(8, 316)
        Me.ButtonShowPopup1.Name = "ButtonShowPopup1"
        Me.ButtonShowPopup1.Size = New System.Drawing.Size(88, 23)
        Me.ButtonShowPopup1.TabIndex = 17
        Me.ButtonShowPopup1.Text = "Show popup 1"
        '
        'ButtonShowPopup3
        '
        Me.ButtonShowPopup3.Location = New System.Drawing.Point(208, 316)
        Me.ButtonShowPopup3.Name = "ButtonShowPopup3"
        Me.ButtonShowPopup3.Size = New System.Drawing.Size(88, 23)
        Me.ButtonShowPopup3.TabIndex = 19
        Me.ButtonShowPopup3.Text = "Show popup 3"
        '
        'checkBoxKeepVisibleOnMouseOver
        '
        Me.checkBoxKeepVisibleOnMouseOver.Location = New System.Drawing.Point(16, 72)
        Me.checkBoxKeepVisibleOnMouseOver.Name = "checkBoxKeepVisibleOnMouseOver"
        Me.checkBoxKeepVisibleOnMouseOver.Size = New System.Drawing.Size(272, 16)
        Me.checkBoxKeepVisibleOnMouseOver.TabIndex = 4
        Me.checkBoxKeepVisibleOnMouseOver.Text = "Keep Visible when Mouse over window"
        '
        'checkBoxReShowOnMouseOver
        '
        Me.checkBoxReShowOnMouseOver.Location = New System.Drawing.Point(16, 92)
        Me.checkBoxReShowOnMouseOver.Name = "checkBoxReShowOnMouseOver"
        Me.checkBoxReShowOnMouseOver.Size = New System.Drawing.Size(272, 16)
        Me.checkBoxReShowOnMouseOver.TabIndex = 5
        Me.checkBoxReShowOnMouseOver.Text = "Re-show when Mouse over window when hiding"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(304, 349)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.ButtonShowPopup3, Me.ButtonShowPopup2, Me.ButtonShowPopup1, Me.groupBox3, Me.groupBox2, Me.groupBox1})
        Me.Name = "Form1"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "VB.NET TaskBarNotifier Demo"
        Me.groupBox1.ResumeLayout(False)
        Me.groupBox2.ResumeLayout(False)
        Me.groupBox3.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private WithEvents taskbarNotifier1 As TaskBarNotifier
    Private WithEvents taskbarNotifier2 As TaskBarNotifier
    Private WithEvents taskbarNotifier3 As TaskBarNotifier


    Private Sub Notifier_CloseButtonClick(ByVal sender As Object, ByVal e As System.EventArgs) _
                                                            Handles taskbarNotifier1.CloseButtonClick, _
                                                                    taskbarNotifier2.CloseButtonClick, _
                                                                    taskbarNotifier3.CloseButtonClick

        Dim taskbarSender As TaskBarNotifier = DirectCast(sender, TaskBarNotifier)

        If taskbarSender.Equals(taskbarNotifier1) Then
            MsgBox("TaskBarNotifier 1: CloseButton was clicked")
        End If

        If taskbarSender.Equals(taskbarNotifier2) Then
            MsgBox("TaskBarNotifier 2: CloseButton was clicked")
        End If

        If taskbarSender.Equals(taskbarNotifier3) Then
            MsgBox("TaskBarNotifier 3: CloseButton was clicked")
        End If

    End Sub

    Private Sub Notifier_TitleClick(ByVal sender As Object, ByVal e As System.EventArgs) _
                                                            Handles taskbarNotifier1.TitleClick, _
                                                                    taskbarNotifier2.TitleClick, _
                                                                    taskbarNotifier3.TitleClick

        Dim taskbarSender As TaskBarNotifier = DirectCast(sender, TaskBarNotifier)

        If taskbarSender.Equals(taskbarNotifier1) Then
            MsgBox("TaskBarNotifier 1: Title was clicked")
        End If

        If taskbarSender.Equals(taskbarNotifier2) Then
            MsgBox("TaskBarNotifier 2: Title was clicked")
        End If

        If taskbarSender.Equals(taskbarNotifier3) Then
            MsgBox("TaskBarNotifier 3: Title was clicked")
        End If

    End Sub

    Private Sub Notifier_TextClick(ByVal sender As Object, ByVal e As System.EventArgs) _
                                                            Handles taskbarNotifier1.TextClick, _
                                                                    taskbarNotifier2.TextClick, _
                                                                    taskbarNotifier3.TextClick

        Dim taskbarSender As TaskBarNotifier = DirectCast(sender, TaskBarNotifier)

        If taskbarSender.Equals(taskbarNotifier1) Then
            MsgBox("TaskBarNotifier 1: TextZone was clicked")
        End If

        If taskbarSender.Equals(taskbarNotifier2) Then
            MsgBox("TaskBarNotifier 2: TextZone was clicked")
        End If

        If taskbarSender.Equals(taskbarNotifier3) Then
            MsgBox("TaskBarNotifier 3: TextZone was clicked")
        End If

    End Sub

    Private Sub ButtonShowPopup1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonShowPopup1.Click

        If (textBoxTitle.Text.Length = 0 OrElse textBoxContent.Text.Length = 0) Then
            MsgBox("Enter a title and a content Text")
            Exit Sub
        End If

        If Not IsNumeric(textBoxDelayShowing.Text) OrElse _
           Not IsNumeric(textBoxDelayStaying.Text) OrElse _
           Not IsNumeric(textBoxDelayHiding.Text) Then
            MsgBox("Enter valid Delays (integers)")
            Exit Sub
        End If

        With taskbarNotifier1
            .CloseButtonClickEnabled = checkBoxCloseClickable.Checked
            .TitleClickEnabled = checkBoxTitleClickable.Checked
            .TextClickEnabled = checkBoxContentClickable.Checked
            .DrawTextFocusRect = checkBoxSelectionRectangle.Checked
            .KeepVisibleOnMouseOver = checkBoxKeepVisibleOnMouseOver.Checked
            .ReShowOnMouseOver = checkBoxReShowOnMouseOver.Checked
            .Show(textBoxTitle.Text, _
                  textBoxContent.Text, _
                  Integer.Parse(textBoxDelayShowing.Text), _
                  Integer.Parse(textBoxDelayStaying.Text), _
                  Integer.Parse(textBoxDelayHiding.Text))
        End With

    End Sub

    Private Sub ButtonShowPopup2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonShowPopup2.Click

        If (textBoxTitle.Text.Length = 0 OrElse textBoxContent.Text.Length = 0) Then
            MsgBox("Enter a title and a content Text")
            Exit Sub
        End If

        If Not IsNumeric(textBoxDelayShowing.Text) OrElse _
           Not IsNumeric(textBoxDelayStaying.Text) OrElse _
           Not IsNumeric(textBoxDelayHiding.Text) Then
            MsgBox("Enter valid Delays (integers)")
            Exit Sub
        End If

        With taskbarNotifier2
            .CloseButtonClickEnabled = checkBoxCloseClickable.Checked
            .TitleClickEnabled = checkBoxTitleClickable.Checked
            .TextClickEnabled = checkBoxContentClickable.Checked
            .DrawTextFocusRect = checkBoxSelectionRectangle.Checked
            .KeepVisibleOnMouseOver = checkBoxKeepVisibleOnMouseOver.Checked
            .ReShowOnMouseOver = checkBoxReShowOnMouseOver.Checked
            .Show(textBoxTitle.Text, _
                  textBoxContent.Text, _
                  Integer.Parse(textBoxDelayShowing.Text), _
                  Integer.Parse(textBoxDelayStaying.Text), _
                  Integer.Parse(textBoxDelayHiding.Text))
        End With
    End Sub

    Private Sub ButtonShowPopup3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonShowPopup3.Click

        'This is an addition TaskbarNotifier window.
        'Made this in order to see how 'easy' it is to create my own custom skin.

        ' Believe me... If you know your way around in a bitmap editor...It's EASY !!! :-)

        If (textBoxTitle.Text.Length = 0 OrElse textBoxContent.Text.Length = 0) Then
            MsgBox("Enter a title and a content Text")
            Exit Sub
        End If

        If Not IsNumeric(textBoxDelayShowing.Text) OrElse _
           Not IsNumeric(textBoxDelayStaying.Text) OrElse _
           Not IsNumeric(textBoxDelayHiding.Text) Then
            MsgBox("Enter valid Delays (integers)")
            Exit Sub
        End If

        With taskbarNotifier3
            .NormalTitleColor = Color.Black
            .HoverTitleColor = Color.Black
            .NormalContentColor = Color.Yellow
            .HoverContentColor = Color.White
            .CloseButtonClickEnabled = checkBoxCloseClickable.Checked
            .TitleClickEnabled = checkBoxTitleClickable.Checked
            .TextClickEnabled = checkBoxContentClickable.Checked
            .DrawTextFocusRect = checkBoxSelectionRectangle.Checked
            .KeepVisibleOnMouseOver = checkBoxKeepVisibleOnMouseOver.Checked
            .ReShowOnMouseOver = checkBoxReShowOnMouseOver.Checked
            .Show(textBoxTitle.Text, _
                  textBoxContent.Text, _
                  Integer.Parse(textBoxDelayShowing.Text), _
                  Integer.Parse(textBoxDelayStaying.Text), _
                  Integer.Parse(textBoxDelayHiding.Text))
        End With

    End Sub

End Class
 


Tidak ada komentar:

Posting Komentar