Public Class FrmScandir
    Inherits System.Windows.Forms.Form

    Private mObj As New NHenry.Scandir.ClsScandir

#Region " Code généré par le Concepteur Windows Form "

    Public Sub New()
        MyBase.New()

        'Cet appel est requis par le Concepteur Windows Form.
        InitializeComponent()

        'Ajoutez une initialisation quelconque après l'appel InitializeComponent()

    End Sub

    'La méthode substituée Dispose du formulaire pour nettoyer la liste des composants.
    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

    'Requis par le Concepteur Windows Form
    Private components As System.ComponentModel.IContainer

    'REMARQUE : la procédure suivante est requise par le Concepteur Windows Form
    'Elle peut être modifiée en utilisant le Concepteur Windows Form.  
    'Ne la modifiez pas en utilisant l'éditeur de code.
    Friend WithEvents CmdGo As System.Windows.Forms.Button
    Friend WithEvents CmdStop As System.Windows.Forms.Button
    Friend WithEvents Timer1 As System.Windows.Forms.Timer
    Friend WithEvents LblActDir As System.Windows.Forms.Label
    Friend WithEvents LblProgDir As System.Windows.Forms.Label
    Friend WithEvents LblProgFile As System.Windows.Forms.Label
    Friend WithEvents PBDir As System.Windows.Forms.ProgressBar
    Friend WithEvents PBFile As System.Windows.Forms.ProgressBar
    Friend WithEvents LstFile As System.Windows.Forms.ListBox
    Friend WithEvents TxtPaths As System.Windows.Forms.TextBox
    Friend WithEvents TxtInclude As System.Windows.Forms.TextBox
    Friend WithEvents TxtExclude As System.Windows.Forms.TextBox
    Friend WithEvents PanSup As System.Windows.Forms.Panel
    Friend WithEvents PanDir As System.Windows.Forms.Panel
    Friend WithEvents PanFile As System.Windows.Forms.Panel
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.LstFile = New System.Windows.Forms.ListBox
        Me.TxtPaths = New System.Windows.Forms.TextBox
        Me.CmdGo = New System.Windows.Forms.Button
        Me.CmdStop = New System.Windows.Forms.Button
        Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
        Me.LblActDir = New System.Windows.Forms.Label
        Me.LblProgDir = New System.Windows.Forms.Label
        Me.LblProgFile = New System.Windows.Forms.Label
        Me.PBDir = New System.Windows.Forms.ProgressBar
        Me.PBFile = New System.Windows.Forms.ProgressBar
        Me.TxtInclude = New System.Windows.Forms.TextBox
        Me.TxtExclude = New System.Windows.Forms.TextBox
        Me.PanSup = New System.Windows.Forms.Panel
        Me.PanDir = New System.Windows.Forms.Panel
        Me.PanFile = New System.Windows.Forms.Panel
        Me.PanSup.SuspendLayout()
        Me.PanDir.SuspendLayout()
        Me.PanFile.SuspendLayout()
        Me.SuspendLayout()
        '
        'LstFile
        '
        Me.LstFile.Dock = System.Windows.Forms.DockStyle.Fill
        Me.LstFile.Location = New System.Drawing.Point(0, 104)
        Me.LstFile.Name = "LstFile"
        Me.LstFile.Size = New System.Drawing.Size(584, 316)
        Me.LstFile.TabIndex = 0
        '
        'TxtPaths
        '
        Me.TxtPaths.Dock = System.Windows.Forms.DockStyle.Fill
        Me.TxtPaths.Location = New System.Drawing.Point(0, 0)
        Me.TxtPaths.Name = "TxtPaths"
        Me.TxtPaths.Size = New System.Drawing.Size(504, 20)
        Me.TxtPaths.TabIndex = 1
        Me.TxtPaths.Text = "C:\"
        '
        'CmdGo
        '
        Me.CmdGo.Dock = System.Windows.Forms.DockStyle.Right
        Me.CmdGo.Location = New System.Drawing.Point(504, 0)
        Me.CmdGo.Name = "CmdGo"
        Me.CmdGo.Size = New System.Drawing.Size(40, 24)
        Me.CmdGo.TabIndex = 2
        Me.CmdGo.Text = "&Go"
        '
        'CmdStop
        '
        Me.CmdStop.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.CmdStop.Dock = System.Windows.Forms.DockStyle.Right
        Me.CmdStop.Location = New System.Drawing.Point(544, 0)
        Me.CmdStop.Name = "CmdStop"
        Me.CmdStop.Size = New System.Drawing.Size(40, 24)
        Me.CmdStop.TabIndex = 3
        Me.CmdStop.Text = "&Stop"
        '
        'Timer1
        '
        Me.Timer1.Interval = 10
        '
        'LblActDir
        '
        Me.LblActDir.Dock = System.Windows.Forms.DockStyle.Top
        Me.LblActDir.Location = New System.Drawing.Point(0, 24)
        Me.LblActDir.Name = "LblActDir"
        Me.LblActDir.Size = New System.Drawing.Size(584, 16)
        Me.LblActDir.TabIndex = 4
        Me.LblActDir.Tag = "Dossier actuel : %1"
        Me.LblActDir.Text = "Dossier act"
        '
        'LblProgDir
        '
        Me.LblProgDir.Dock = System.Windows.Forms.DockStyle.Top
        Me.LblProgDir.Location = New System.Drawing.Point(0, 0)
        Me.LblProgDir.Name = "LblProgDir"
        Me.LblProgDir.Size = New System.Drawing.Size(584, 16)
        Me.LblProgDir.TabIndex = 5
        Me.LblProgDir.Tag = "Dossiers : %1/%2, tmps passé %3, estimé %4, total %5"
        Me.LblProgDir.Text = "ProgressionDir"
        '
        'LblProgFile
        '
        Me.LblProgFile.Dock = System.Windows.Forms.DockStyle.Top
        Me.LblProgFile.Location = New System.Drawing.Point(0, 0)
        Me.LblProgFile.Name = "LblProgFile"
        Me.LblProgFile.Size = New System.Drawing.Size(584, 16)
        Me.LblProgFile.TabIndex = 6
        Me.LblProgFile.Tag = "Fichiers : %1/%2, tmps passé %3, estimé %4, total %5"
        Me.LblProgFile.Text = "ProgressionFile"
        '
        'PBDir
        '
        Me.PBDir.Dock = System.Windows.Forms.DockStyle.Fill
        Me.PBDir.Location = New System.Drawing.Point(0, 16)
        Me.PBDir.Name = "PBDir"
        Me.PBDir.Size = New System.Drawing.Size(584, 16)
        Me.PBDir.TabIndex = 7
        '
        'PBFile
        '
        Me.PBFile.Dock = System.Windows.Forms.DockStyle.Fill
        Me.PBFile.Location = New System.Drawing.Point(0, 16)
        Me.PBFile.Name = "PBFile"
        Me.PBFile.Size = New System.Drawing.Size(584, 16)
        Me.PBFile.TabIndex = 8
        '
        'TxtInclude
        '
        Me.TxtInclude.Dock = System.Windows.Forms.DockStyle.Right
        Me.TxtInclude.Location = New System.Drawing.Point(296, 0)
        Me.TxtInclude.Name = "TxtInclude"
        Me.TxtInclude.Size = New System.Drawing.Size(104, 20)
        Me.TxtInclude.TabIndex = 9
        Me.TxtInclude.Text = "*"
        '
        'TxtExclude
        '
        Me.TxtExclude.Dock = System.Windows.Forms.DockStyle.Right
        Me.TxtExclude.Location = New System.Drawing.Point(400, 0)
        Me.TxtExclude.Name = "TxtExclude"
        Me.TxtExclude.Size = New System.Drawing.Size(104, 20)
        Me.TxtExclude.TabIndex = 10
        Me.TxtExclude.Text = ""
        '
        'PanSup
        '
        Me.PanSup.Controls.Add(Me.TxtInclude)
        Me.PanSup.Controls.Add(Me.TxtExclude)
        Me.PanSup.Controls.Add(Me.TxtPaths)
        Me.PanSup.Controls.Add(Me.CmdGo)
        Me.PanSup.Controls.Add(Me.CmdStop)
        Me.PanSup.Dock = System.Windows.Forms.DockStyle.Top
        Me.PanSup.Location = New System.Drawing.Point(0, 0)
        Me.PanSup.Name = "PanSup"
        Me.PanSup.Size = New System.Drawing.Size(584, 24)
        Me.PanSup.TabIndex = 11
        '
        'PanDir
        '
        Me.PanDir.Controls.Add(Me.PBDir)
        Me.PanDir.Controls.Add(Me.LblProgDir)
        Me.PanDir.Dock = System.Windows.Forms.DockStyle.Top
        Me.PanDir.Location = New System.Drawing.Point(0, 40)
        Me.PanDir.Name = "PanDir"
        Me.PanDir.Size = New System.Drawing.Size(584, 32)
        Me.PanDir.TabIndex = 12
        '
        'PanFile
        '
        Me.PanFile.Controls.Add(Me.PBFile)
        Me.PanFile.Controls.Add(Me.LblProgFile)
        Me.PanFile.Dock = System.Windows.Forms.DockStyle.Top
        Me.PanFile.Location = New System.Drawing.Point(0, 72)
        Me.PanFile.Name = "PanFile"
        Me.PanFile.Size = New System.Drawing.Size(584, 32)
        Me.PanFile.TabIndex = 13
        '
        'FrmScandir
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(584, 421)
        Me.Controls.Add(Me.LstFile)
        Me.Controls.Add(Me.PanFile)
        Me.Controls.Add(Me.PanDir)
        Me.Controls.Add(Me.LblActDir)
        Me.Controls.Add(Me.PanSup)
        Me.Name = "FrmScandir"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "FrmScandir"
        Me.PanSup.ResumeLayout(False)
        Me.PanDir.ResumeLayout(False)
        Me.PanFile.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub FrmScandir_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        mObj.Path = "c:\"
        mObj.ExtInclude = "*"



        'Timer1.Enabled = false

    End Sub

    Private Sub FrmScandir_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        mObj.StopAnalyse()
        mObj = Nothing
    End Sub

    Private Sub FrmScandir_Resize(ByVal sender As Object, ByVal e As System.EventArgs) ' Handles MyBase.Resize
        With TxtPaths
            .Height = LblActDir.Height
            .Top = 0
            .Left = 0
            .Width = CInt((Me.ClientSize.Width - CmdGo.Width - CmdStop.Width) / 3)
        End With
        With TxtInclude
            .Height = LblActDir.Height
            .Top = 0
            .Left = TxtPaths.Width
            .Width = TxtPaths.Width
        End With
        With TxtExclude
            .Height = LblActDir.Height
            .Top = 0
            .Left = TxtInclude.Left + TxtInclude.Width
            .Width = TxtPaths.Width
        End With
        With CmdGo
            .Height = LblActDir.Height
            .Top = 0
            .Left = TxtExclude.Left + TxtExclude.Width
        End With
        With CmdStop
            .Height = LblActDir.Height
            .Top = 0
            .Left = CmdGo.Left + CmdGo.Width
        End With
        With LblActDir
            .Top = CmdGo.Height
            .Left = 0
            .Width = Me.ClientSize.Width
        End With
        With LblProgDir
            .Height = LblActDir.Height
            .Top = LblActDir.Top + LblActDir.Height
            .Left = 0
            .Width = Me.ClientSize.Width
        End With
        With PBDir
            .Height = LblActDir.Height
            .Top = LblProgDir.Top + LblProgDir.Height
            .Left = 0
            .Width = Me.ClientSize.Width
        End With
        With LblProgFile
            .Height = LblActDir.Height
            .Top = PBDir.Top + PBDir.Height
            .Left = 0
            .Width = Me.ClientSize.Width
        End With
        With PBFile
            .Height = LblActDir.Height
            .Top = LblProgFile.Top + LblProgFile.Height
            .Left = 0
            .Width = Me.ClientSize.Width
        End With
        With LstFile
            .Height = Me.ClientSize.Height - PBFile.Height - PBFile.Top
            .Top = PBFile.Top + PBFile.Height
            .Left = 0
            .Width = Me.ClientSize.Width
        End With
    End Sub

    Private Sub CmdStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdStop.Click
        mObj.StopAnalyse()
        Timer1.Enabled = False
    End Sub

    Private Sub CmdGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdGo.Click
        mObj.Path = TxtPaths.Text
        mObj.ExtExclude = TxtExclude.Text
        mObj.ExtInclude = TxtInclude.Text
        mObj.StartAnalyse()
        LstFile.Items.Clear()
        Timer1.Enabled = True
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim TmpStr As String
        TmpStr = mObj.GetNext(False).FileName
        If TmpStr = "" Then
            Timer1.Enabled = False
        ElseIf TmpStr.Trim <> "" Then
            LstFile.Items.Add(TmpStr)
            LstFile.SelectedIndex = LstFile.Items.Count - 1
        End If
        With PBFile
            .Minimum = 0
            .Maximum = mObj.NbFileTotal
            .Value = mObj.NbFileElapsed
        End With
        With PBDir
            .Minimum = 0
            .Maximum = mObj.NbDirTotal
            .Value = mObj.NbDirElapsed
        End With
        LblActDir.Text = CType(LblActDir.Tag, String).Replace("%1", mObj.ActPath)
        LblProgDir.Text = CType(LblProgDir.Tag, String).Replace("%1", CStr(mObj.NbDirElapsed)).Replace("%2", CStr(mObj.NbDirTotal)).Replace("%3", NHenry.Scandir.SecToHMS(mObj.TimeDirElapsed)).Replace("%4", NHenry.Scandir.SecToHMS(mObj.TimeDirRemain)).Replace("%5", NHenry.Scandir.SecToHMS(mObj.TimeDirTotal))
        LblProgFile.Text = CType(LblProgFile.Tag, String).Replace("%1", CStr(mObj.NbFileElapsed)).Replace("%2", CStr(mObj.NbFileTotal)).Replace("%3", NHenry.Scandir.SecToHMS(mObj.TimeFileElapsed)).Replace("%4", NHenry.Scandir.SecToHMS(mObj.TimeFileRemain)).Replace("%5", NHenry.Scandir.SecToHMS(mObj.TimeFileTotal))
    End Sub
End Class
