Anda di halaman 1dari 4

Public Class Form1 Inherits System.Windows.Forms.

Form Private WithEvents objWatcher As New clsFSW() Private rand As New Random Private sliceNum As Integer = 0

'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 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.Even tArgs) Handles MyBase.Load Dim value As Boolean value = Control.CheckForIllegalCrossThreadCalls Control.CheckForIllegalCrossThreadCalls = False cmdStop.Enabled = False With objWatcher

End With Me.Text = "Pegasus" End Sub

Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As System. EventArgs) Handles cmdStart.Click Dim sDir As String

sDir = txtFolder.Text If IO.Directory.Exists(sDir) Then objWatcher.FolderToMonitor = sDir objWatcher.StartWatch() cmdStop.Enabled = True cmdStart.Enabled = False chkSubFolders.Enabled = False Else MessageBox.Show("Folder does not exist!") End If Me.Text = "Pegasus Active" End Sub Private Sub cmdStop_Click(ByVal sender As System.Object, ByVal e As System.E ventArgs) Handles cmdStop.Click objWatcher.StopWatch() cmdStop.Enabled = False cmdStart.Enabled = True chkSubFolders.Enabled = True Me.Text = "Pegasus" End Sub

Private Sub chkSubFolders_CheckedChanged(ByVal sender As System.Object, ByVa l e As System.EventArgs) Handles chkSubFolders.CheckedChanged objWatcher.IncludeSubfolders = (chkSubFolders.Checked = True) End Sub Private Sub objWatcher_FileCreated(ByVal FullPath As String) Handles objWatc her.FileCreated TextBox1.Text &= "File Created: " & FullPath & " " & DateAndTime.Now & v bCrLf Dim ni As New NotifyIcon

ni.ShowBalloonTip(200, "test text", "My Text test only", ToolTipIcon.War ning) End Sub Private Sub objWatcher_FileDeleted(ByVal FullPath As String) Handles objWatc her.FileDeleted TextBox1.Text &= "File Deleted: " & FullPath & " " & DateAndTime.Now & v bCrLf End Sub Private Sub objWatcher_FileWatchError(ByVal ErrMsg As String) Handles objWat cher.FileWatchError TextBox1.Text &= "The following error occurred: " & ErrMsg & " " & DateA ndTime.Now & vbCrLf MsgBox("The following error occurred: " & ErrMsg & " " & DateAndTime.Now , MsgBoxStyle.Exclamation, "ERROR MESSAGE") End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.E ventArgs) Handles Button2.Click objWatcher.StopWatch() cmdStop.Enabled = False cmdStart.Enabled = True chkSubFolders.Enabled = True End End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.E ventArgs) Handles Button1.Click My.Computer.FileSystem.WriteAllText("C:\pegasus " & DateAndTime.DateStri ng & ".txt", TextBox1.Text, True) MsgBox("Saved to: C:\pegasus " & DateAndTime.DateString & ".txt", MsgBox Style.Information, "Report Saved") Dim ni As New NotifyIcon ni.ShowBalloonTip(2, "Report Saved.", "Save Report", ToolTipIcon.Info) End Sub

End Class

Anda mungkin juga menyukai