Você está na página 1de 5

Imports System.Runtime.

InteropServices
Imports System.IO
Public Class Form1
Public rowz = 50
'HANDLES MOUSE EVENTS WHEN MOUSE MOVES OVER AN ICON ON BAR
Private Sub Lab_MouseEnter(ByVal sender As System.Object, ByVal e As
System.EventArgs)
CType(sender, PictureBox).Size = New Size(40, 40)
CType(sender, PictureBox).Location = New Point(sender.Location.X - 5,
sender.Location.Y)
End Sub

Private Sub Lab_MouseLeave(ByVal sender As System.Object, ByVal e As


System.EventArgs)
CType(sender, PictureBox).Size = New Size(30, 30)
CType(sender, PictureBox).Location = New Point(sender.Location.X + 5,
sender.Location.Y)
End Sub

'THIS IS WHAT HAPPENS WHEN YOU CLICK AN ICON ON THE BAR - OPENS or
DELETES
Private Sub Fclick(ByVal sender As System.Object, ByVal e As System.EventArgs)
If CheckBox1.Checked = TrueThen
Dim findlink As String = CType(sender, PictureBox).Tag.ToString
Dim replace As String = ""
Dim indx As Integer = RichTextBox1.Find(findlink)
If indx <> -1 Then

RichTextBox1.Select(indx, findlink.Length)
If RichTextBox1.SelectedText <> ""Then
RichTextBox1.SelectedText = replace
End If
End If
CType(sender, PictureBox).Dispose()
saveme()
Else
Dim w = CType(sender, PictureBox).Tag.ToString
System.Diagnostics.Process.Start(w)
End If
End Sub

'READS SAVED ICONS AND LOADS THEM AT STARTUP INTO THE BAR
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If My.Computer.FileSystem.FileExists(Application.StartupPath + "\Settings.bar") Then
Dim lines = IO.File.ReadAllLines(Application.StartupPath + "\Settings.bar")
For Each line As String In lines
If line <> ""Then
RichTextBox1.AppendText(line + vbNewLine)
Dim w As New PictureBox
Try
Using ico As Icon = Drawing.Icon.ExtractAssociatedIcon(line)
Dim s = ico.ToBitmap
w.Image = s
End Using

Catch
w.BackColor = Color.Aqua
End Try
w.Location = New Point(rowz, 5)
w.Size = New Size(30, 30)
w.Tag = line
w.BackColor = Color.Transparent
w.SizeMode = PictureBoxSizeMode.StretchImage
AddHandler w.Click, AddressOf Fclick
AddHandler w.MouseEnter, AddressOf Lab_MouseEnter
AddHandler w.MouseLeave, AddressOf Lab_MouseLeave
Me.Width += 40
Me.Controls.Add(w)
rowz += 40
End If
Next
End If
Me.CenterToScreen()
Me.Top = Screen.PrimaryScreen.Bounds.X
End Sub

'DETECTS PROGRAM DRAGGED ONTO BAR AND ADDs IT and SHOWS ITS ICON
Private Sub Form1_DragDrop(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles MyBase.DragDrop
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
Dim draggedFiles As String() = CType(e.Data.GetData(DataFormats.FileDrop),
String())

ForEach filename As String In draggedFiles


RichTextBox1.AppendText(filename + vbNewLine)
Dim w As New PictureBox
Using ico As Icon = Drawing.Icon.ExtractAssociatedIcon(filename)
Dim s = ico.ToBitmap
w.Image = s
End Using
w.Location = New Point(rowz, 5)
w.Size = New Size(30, 30)
w.Tag = filename
w.BackColor = Color.Transparent
AddHandler w.Click, AddressOf Fclick
AddHandler w.MouseEnter, AddressOf Lab_MouseEnter
AddHandler w.MouseLeave, AddressOf Lab_MouseLeave
Me.Controls.Add(w)
Me.Width += 40
rowz += 40
Next
Me.CenterToScreen()
Me.Top = Screen.PrimaryScreen.Bounds.X
saveme()
End If
End Sub

'CHECKS TO MAKE SURE ITEM DRAGGED IS A FILE


Private Sub Form1_DragEnter(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles MyBase.DragEnter

If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.Copy
End If
End Sub

'SAVES THE SHORTCUTS


Public Sub saveme()
If My.Computer.FileSystem.FileExists(Application.StartupPath + "\Settings.bar") Then
My.Computer.FileSystem.DeleteFile(Application.StartupPath + "\Settings.bar",
FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
End If
My.Computer.FileSystem.WriteAllText(Application.StartupPath + "\Settings.bar",
RichTextBox1.Text, True)
End Sub

Private Sub Form1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDoubleClick
Me.Close()
End Sub

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = False Then
Application.Restart()
End If
End Sub
End Class

Você também pode gostar