Imports System.Text

Public Class Processing

    Private m_progressCounter As Integer = 0
    Private m_keywordsLeft As Integer = 0
    Private m_urls As Integer = 0
    Public Event StopRequest(sender As Object, e As EventArgs)

    Public Property KeywordsLeft As Integer
        Get
            Return m_keywordsLeft
        End Get
        Set(value As Integer)
            m_keywordsLeft = value

            lblKeywords.Text = String.Format("Keywords Left to Inspect: {0}", m_keywordsLeft)
        End Set
    End Property

    Public Property UrlsInspected As Integer
        Get
            Return m_urls
        End Get
        Set(value As Integer)
            m_urls = value

            lblUrls.Text = String.Format("URLs Inspected So Far: {0}", m_urls)
        End Set
    End Property

    Public Property CurrentState As String
        Get
            Return Me.lblTask.Text
        End Get
        Set(value As String)
            Me.lblTask.Text = value
        End Set
    End Property

    Private Sub Processing_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        tmrProgressUpdate.Start()
    End Sub

    Private Sub tmrProgressUpdate_Tick(sender As System.Object, e As System.EventArgs) Handles tmrProgressUpdate.Tick
        Dim sb As New StringBuilder(". . . . . . .")
        sb(m_progressCounter) = " "

        m_progressCounter += 2
        If m_progressCounter > sb.Length Then
            m_progressCounter = 0
        End If

        sb(m_progressCounter) = "."
        lblProgress.Text = sb.ToString()
    End Sub

    Private Sub btnStop_Click(sender As System.Object, e As System.EventArgs) Handles btnStop.Click
        btnStop.Enabled = False
        lblKeywords.Visible = False
        lblUrls.Visible = False
        lblProgress.Visible = False
        lblTask.Text = "Stopping Collection..."

        RaiseEvent StopRequest(Me, e)

    End Sub

    Private Sub Processing_VisibleChanged(sender As Object, e As System.EventArgs) Handles Me.VisibleChanged
        'Me.Left = (Me.Parent.Width / 2) - (Me.Width / 2)
        'Me.Top = (Me.Parent.Height / 2) - (Me.Height / 2)
        'Me.Anchor = AnchorStyles.None
    End Sub
End Class
