'------------------------------------------------------------------
'
' Title: MultiConv Wrapper
'
' Created By: Kris Brixon (krisbrixon@hotmail.com)
' Created On: 06-28-2002
' Created With: VB.NET
'
' Description: This is a Windows GUI to run the DOS version of
'              MultiConv from http://www.ruijiang.com 
'              The only enhancement is to be able to save your
'              settings so you can recall then the next time
'              you open this wrapper.
'
'              Do not ask me for enhancements, unless the free
'              version of MultiConv changes. If you would like
'              anything extra then see http://www.ruijiang.com, 
'              he has a true Windows version (for sale) that has
'              a number of nice features. All I am doing is making
'              a "face" for the DOS command line version. I do
'              not have access to the actual code that runs the
'              conversion.
'
' Why I did this: 1. An excuse to work with VB.NET. 
'                 2. I liked the batch capability of this program,
'                    but I knew I would get tired of typing the 
'                    whole command line each time I wanted to use it.
'                 
' How To Use: Copy this EXE into the same directory as MultiConv
'             and run this exe.
'
'------------------------------------------------------------------

Imports System.IO
Public Class frmMCW
    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

    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 lblCapSourcePath As System.Windows.Forms.Label
    Friend WithEvents tbSource As System.Windows.Forms.TextBox
    Friend WithEvents tbDestination As System.Windows.Forms.TextBox
    Friend WithEvents lblCapDestPath As System.Windows.Forms.Label
    Friend WithEvents tbFileType As System.Windows.Forms.TextBox
    Friend WithEvents lblCapType As System.Windows.Forms.Label
    Friend WithEvents rbResize As System.Windows.Forms.RadioButton
    Friend WithEvents rbCHKR As System.Windows.Forms.RadioButton
    Friend WithEvents rbCWKR As System.Windows.Forms.RadioButton
    Friend WithEvents rbCH As System.Windows.Forms.RadioButton
    Friend WithEvents rbCW As System.Windows.Forms.RadioButton
    Friend WithEvents rbAWH As System.Windows.Forms.RadioButton
    Friend WithEvents rbNoResize As System.Windows.Forms.RadioButton
    Friend WithEvents tbWidth As System.Windows.Forms.TextBox
    Friend WithEvents lblCapNewWidth As System.Windows.Forms.Label
    Friend WithEvents tbHeight As System.Windows.Forms.TextBox
    Friend WithEvents lblCapNewHeight As System.Windows.Forms.Label
    Friend WithEvents tbRatio As System.Windows.Forms.TextBox
    Friend WithEvents lblCapResizeRatio As System.Windows.Forms.Label
    Friend WithEvents tbPre As System.Windows.Forms.TextBox
    Friend WithEvents lblCapPre As System.Windows.Forms.Label
    Friend WithEvents tbSuf As System.Windows.Forms.TextBox
    Friend WithEvents lblCapSuf As System.Windows.Forms.Label
    Friend WithEvents cbOverwrite As System.Windows.Forms.CheckBox
    Friend WithEvents cbDir As System.Windows.Forms.CheckBox
    Friend WithEvents bSaveSettings As System.Windows.Forms.Button
    Friend WithEvents bLoadSettings As System.Windows.Forms.Button
    Friend WithEvents bRun As System.Windows.Forms.Button
    Friend WithEvents bClearScreen As System.Windows.Forms.Button
    Friend WithEvents bExit As System.Windows.Forms.Button
    Friend WithEvents tbZP As System.Windows.Forms.TextBox
    Friend WithEvents lblCapZeroPad As System.Windows.Forms.Label
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents LinkLabel1 As System.Windows.Forms.LinkLabel
    Friend WithEvents LinkLabel2 As System.Windows.Forms.LinkLabel
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmMCW))
        Me.lblCapSourcePath = New System.Windows.Forms.Label()
        Me.tbSource = New System.Windows.Forms.TextBox()
        Me.tbDestination = New System.Windows.Forms.TextBox()
        Me.lblCapDestPath = New System.Windows.Forms.Label()
        Me.tbFileType = New System.Windows.Forms.TextBox()
        Me.lblCapType = New System.Windows.Forms.Label()
        Me.GroupBox1 = New System.Windows.Forms.GroupBox()
        Me.rbResize = New System.Windows.Forms.RadioButton()
        Me.rbCHKR = New System.Windows.Forms.RadioButton()
        Me.rbCWKR = New System.Windows.Forms.RadioButton()
        Me.rbCH = New System.Windows.Forms.RadioButton()
        Me.rbCW = New System.Windows.Forms.RadioButton()
        Me.rbAWH = New System.Windows.Forms.RadioButton()
        Me.rbNoResize = New System.Windows.Forms.RadioButton()
        Me.tbWidth = New System.Windows.Forms.TextBox()
        Me.lblCapNewWidth = New System.Windows.Forms.Label()
        Me.tbHeight = New System.Windows.Forms.TextBox()
        Me.lblCapNewHeight = New System.Windows.Forms.Label()
        Me.tbRatio = New System.Windows.Forms.TextBox()
        Me.lblCapResizeRatio = New System.Windows.Forms.Label()
        Me.tbPre = New System.Windows.Forms.TextBox()
        Me.lblCapPre = New System.Windows.Forms.Label()
        Me.tbSuf = New System.Windows.Forms.TextBox()
        Me.lblCapSuf = New System.Windows.Forms.Label()
        Me.cbOverwrite = New System.Windows.Forms.CheckBox()
        Me.cbDir = New System.Windows.Forms.CheckBox()
        Me.bSaveSettings = New System.Windows.Forms.Button()
        Me.bLoadSettings = New System.Windows.Forms.Button()
        Me.bRun = New System.Windows.Forms.Button()
        Me.bClearScreen = New System.Windows.Forms.Button()
        Me.bExit = New System.Windows.Forms.Button()
        Me.tbZP = New System.Windows.Forms.TextBox()
        Me.lblCapZeroPad = New System.Windows.Forms.Label()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.LinkLabel1 = New System.Windows.Forms.LinkLabel()
        Me.LinkLabel2 = New System.Windows.Forms.LinkLabel()
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        '
        'lblCapSourcePath
        '
        Me.lblCapSourcePath.Location = New System.Drawing.Point(48, 24)
        Me.lblCapSourcePath.Name = "lblCapSourcePath"
        Me.lblCapSourcePath.Size = New System.Drawing.Size(184, 16)
        Me.lblCapSourcePath.TabIndex = 0
        Me.lblCapSourcePath.Text = "Source Image File/Directory Name:"
        Me.lblCapSourcePath.TextAlign = System.Drawing.ContentAlignment.BottomLeft
        '
        'tbSource
        '
        Me.tbSource.Location = New System.Drawing.Point(48, 40)
        Me.tbSource.Name = "tbSource"
        Me.tbSource.Size = New System.Drawing.Size(216, 20)
        Me.tbSource.TabIndex = 0
        Me.tbSource.Text = ""
        '
        'tbDestination
        '
        Me.tbDestination.Location = New System.Drawing.Point(48, 88)
        Me.tbDestination.Name = "tbDestination"
        Me.tbDestination.Size = New System.Drawing.Size(216, 20)
        Me.tbDestination.TabIndex = 1
        Me.tbDestination.Text = ""
        '
        'lblCapDestPath
        '
        Me.lblCapDestPath.Location = New System.Drawing.Point(48, 72)
        Me.lblCapDestPath.Name = "lblCapDestPath"
        Me.lblCapDestPath.Size = New System.Drawing.Size(184, 16)
        Me.lblCapDestPath.TabIndex = 2
        Me.lblCapDestPath.Text = "Destination Path:"
        Me.lblCapDestPath.TextAlign = System.Drawing.ContentAlignment.BottomLeft
        '
        'tbFileType
        '
        Me.tbFileType.Location = New System.Drawing.Point(48, 136)
        Me.tbFileType.Name = "tbFileType"
        Me.tbFileType.Size = New System.Drawing.Size(48, 20)
        Me.tbFileType.TabIndex = 2
        Me.tbFileType.Text = "jpg"
        '
        'lblCapType
        '
        Me.lblCapType.Location = New System.Drawing.Point(48, 120)
        Me.lblCapType.Name = "lblCapType"
        Me.lblCapType.Size = New System.Drawing.Size(184, 16)
        Me.lblCapType.TabIndex = 4
        Me.lblCapType.Text = "Destination File Type. Default: jpg"
        Me.lblCapType.TextAlign = System.Drawing.ContentAlignment.BottomLeft
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.rbResize, Me.rbCHKR, Me.rbCWKR, Me.rbCH, Me.rbCW, Me.rbAWH, Me.rbNoResize})
        Me.GroupBox1.Location = New System.Drawing.Point(48, 224)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(208, 152)
        Me.GroupBox1.TabIndex = 6
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "Resize Mode"
        '
        'rbResize
        '
        Me.rbResize.Location = New System.Drawing.Point(16, 120)
        Me.rbResize.Name = "rbResize"
        Me.rbResize.Size = New System.Drawing.Size(152, 16)
        Me.rbResize.TabIndex = 6
        Me.rbResize.Text = "Resize According to Ratio"
        '
        'rbCHKR
        '
        Me.rbCHKR.Location = New System.Drawing.Point(16, 104)
        Me.rbCHKR.Name = "rbCHKR"
        Me.rbCHKR.Size = New System.Drawing.Size(184, 16)
        Me.rbCHKR.TabIndex = 5
        Me.rbCHKR.Text = "Change Height, and Keep Ratio"
        '
        'rbCWKR
        '
        Me.rbCWKR.Location = New System.Drawing.Point(16, 88)
        Me.rbCWKR.Name = "rbCWKR"
        Me.rbCWKR.Size = New System.Drawing.Size(184, 16)
        Me.rbCWKR.TabIndex = 4
        Me.rbCWKR.Text = "Change Width, and Keep Ratio"
        '
        'rbCH
        '
        Me.rbCH.Location = New System.Drawing.Point(16, 72)
        Me.rbCH.Name = "rbCH"
        Me.rbCH.Size = New System.Drawing.Size(152, 16)
        Me.rbCH.TabIndex = 3
        Me.rbCH.Text = "Change Height Only"
        '
        'rbCW
        '
        Me.rbCW.Location = New System.Drawing.Point(16, 56)
        Me.rbCW.Name = "rbCW"
        Me.rbCW.Size = New System.Drawing.Size(152, 16)
        Me.rbCW.TabIndex = 2
        Me.rbCW.Text = "Change Width Only"
        '
        'rbAWH
        '
        Me.rbAWH.Location = New System.Drawing.Point(16, 40)
        Me.rbAWH.Name = "rbAWH"
        Me.rbAWH.Size = New System.Drawing.Size(168, 16)
        Me.rbAWH.TabIndex = 1
        Me.rbAWH.Text = "Absolute Width and Height"
        '
        'rbNoResize
        '
        Me.rbNoResize.Checked = True
        Me.rbNoResize.Location = New System.Drawing.Point(16, 24)
        Me.rbNoResize.Name = "rbNoResize"
        Me.rbNoResize.Size = New System.Drawing.Size(152, 16)
        Me.rbNoResize.TabIndex = 0
        Me.rbNoResize.TabStop = True
        Me.rbNoResize.Text = "No Resize"
        '
        'tbWidth
        '
        Me.tbWidth.Location = New System.Drawing.Point(360, 232)
        Me.tbWidth.Name = "tbWidth"
        Me.tbWidth.Size = New System.Drawing.Size(48, 20)
        Me.tbWidth.TabIndex = 5
        Me.tbWidth.Text = ""
        '
        'lblCapNewWidth
        '
        Me.lblCapNewWidth.Location = New System.Drawing.Point(272, 232)
        Me.lblCapNewWidth.Name = "lblCapNewWidth"
        Me.lblCapNewWidth.Size = New System.Drawing.Size(80, 16)
        Me.lblCapNewWidth.TabIndex = 7
        Me.lblCapNewWidth.Text = "New Width"
        Me.lblCapNewWidth.TextAlign = System.Drawing.ContentAlignment.BottomRight
        '
        'tbHeight
        '
        Me.tbHeight.Location = New System.Drawing.Point(360, 256)
        Me.tbHeight.Name = "tbHeight"
        Me.tbHeight.Size = New System.Drawing.Size(48, 20)
        Me.tbHeight.TabIndex = 6
        Me.tbHeight.Text = ""
        '
        'lblCapNewHeight
        '
        Me.lblCapNewHeight.Location = New System.Drawing.Point(272, 256)
        Me.lblCapNewHeight.Name = "lblCapNewHeight"
        Me.lblCapNewHeight.Size = New System.Drawing.Size(80, 16)
        Me.lblCapNewHeight.TabIndex = 9
        Me.lblCapNewHeight.Text = "New Height"
        Me.lblCapNewHeight.TextAlign = System.Drawing.ContentAlignment.BottomRight
        '
        'tbRatio
        '
        Me.tbRatio.Location = New System.Drawing.Point(360, 280)
        Me.tbRatio.Name = "tbRatio"
        Me.tbRatio.Size = New System.Drawing.Size(48, 20)
        Me.tbRatio.TabIndex = 7
        Me.tbRatio.Text = ""
        '
        'lblCapResizeRatio
        '
        Me.lblCapResizeRatio.Location = New System.Drawing.Point(272, 280)
        Me.lblCapResizeRatio.Name = "lblCapResizeRatio"
        Me.lblCapResizeRatio.Size = New System.Drawing.Size(80, 16)
        Me.lblCapResizeRatio.TabIndex = 11
        Me.lblCapResizeRatio.Text = "Resize Ratio"
        Me.lblCapResizeRatio.TextAlign = System.Drawing.ContentAlignment.BottomRight
        '
        'tbPre
        '
        Me.tbPre.Location = New System.Drawing.Point(360, 312)
        Me.tbPre.Name = "tbPre"
        Me.tbPre.Size = New System.Drawing.Size(48, 20)
        Me.tbPre.TabIndex = 8
        Me.tbPre.Text = ""
        '
        'lblCapPre
        '
        Me.lblCapPre.Location = New System.Drawing.Point(272, 312)
        Me.lblCapPre.Name = "lblCapPre"
        Me.lblCapPre.Size = New System.Drawing.Size(80, 16)
        Me.lblCapPre.TabIndex = 13
        Me.lblCapPre.Text = "Prefix"
        Me.lblCapPre.TextAlign = System.Drawing.ContentAlignment.BottomRight
        '
        'tbSuf
        '
        Me.tbSuf.Location = New System.Drawing.Point(360, 336)
        Me.tbSuf.Name = "tbSuf"
        Me.tbSuf.Size = New System.Drawing.Size(48, 20)
        Me.tbSuf.TabIndex = 9
        Me.tbSuf.Text = ""
        '
        'lblCapSuf
        '
        Me.lblCapSuf.Location = New System.Drawing.Point(272, 336)
        Me.lblCapSuf.Name = "lblCapSuf"
        Me.lblCapSuf.Size = New System.Drawing.Size(80, 16)
        Me.lblCapSuf.TabIndex = 15
        Me.lblCapSuf.Text = "Suffix"
        Me.lblCapSuf.TextAlign = System.Drawing.ContentAlignment.BottomRight
        '
        'cbOverwrite
        '
        Me.cbOverwrite.Location = New System.Drawing.Point(48, 168)
        Me.cbOverwrite.Name = "cbOverwrite"
        Me.cbOverwrite.Size = New System.Drawing.Size(200, 16)
        Me.cbOverwrite.TabIndex = 3
        Me.cbOverwrite.Text = "Overwrite If Destination File Exists"
        '
        'cbDir
        '
        Me.cbDir.Checked = True
        Me.cbDir.CheckState = System.Windows.Forms.CheckState.Checked
        Me.cbDir.Location = New System.Drawing.Point(48, 192)
        Me.cbDir.Name = "cbDir"
        Me.cbDir.Size = New System.Drawing.Size(280, 16)
        Me.cbDir.TabIndex = 4
        Me.cbDir.Text = "Do Not Recursively Traverse The Whole Directory."
        '
        'bSaveSettings
        '
        Me.bSaveSettings.Location = New System.Drawing.Point(344, 32)
        Me.bSaveSettings.Name = "bSaveSettings"
        Me.bSaveSettings.Size = New System.Drawing.Size(96, 24)
        Me.bSaveSettings.TabIndex = 14
        Me.bSaveSettings.Text = "Save Settings"
        '
        'bLoadSettings
        '
        Me.bLoadSettings.Location = New System.Drawing.Point(344, 56)
        Me.bLoadSettings.Name = "bLoadSettings"
        Me.bLoadSettings.Size = New System.Drawing.Size(96, 24)
        Me.bLoadSettings.TabIndex = 15
        Me.bLoadSettings.Text = "Load Settings"
        '
        'bRun
        '
        Me.bRun.Location = New System.Drawing.Point(176, 408)
        Me.bRun.Name = "bRun"
        Me.bRun.Size = New System.Drawing.Size(96, 24)
        Me.bRun.TabIndex = 12
        Me.bRun.Text = "Run"
        '
        'bClearScreen
        '
        Me.bClearScreen.Location = New System.Drawing.Point(64, 408)
        Me.bClearScreen.Name = "bClearScreen"
        Me.bClearScreen.Size = New System.Drawing.Size(96, 24)
        Me.bClearScreen.TabIndex = 11
        Me.bClearScreen.Text = "Clear Screen"
        '
        'bExit
        '
        Me.bExit.Location = New System.Drawing.Point(288, 408)
        Me.bExit.Name = "bExit"
        Me.bExit.Size = New System.Drawing.Size(96, 24)
        Me.bExit.TabIndex = 13
        Me.bExit.Text = "Exit"
        '
        'tbZP
        '
        Me.tbZP.Location = New System.Drawing.Point(360, 360)
        Me.tbZP.MaxLength = 2
        Me.tbZP.Name = "tbZP"
        Me.tbZP.Size = New System.Drawing.Size(48, 20)
        Me.tbZP.TabIndex = 10
        Me.tbZP.Text = "2"
        '
        'lblCapZeroPad
        '
        Me.lblCapZeroPad.Location = New System.Drawing.Point(272, 360)
        Me.lblCapZeroPad.Name = "lblCapZeroPad"
        Me.lblCapZeroPad.Size = New System.Drawing.Size(80, 16)
        Me.lblCapZeroPad.TabIndex = 24
        Me.lblCapZeroPad.Text = "Zero Padding"
        Me.lblCapZeroPad.TextAlign = System.Drawing.ContentAlignment.BottomRight
        '
        'Label1
        '
        Me.Label1.BackColor = System.Drawing.Color.Black
        Me.Label1.Location = New System.Drawing.Point(8, 456)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(448, 1)
        Me.Label1.TabIndex = 25
        '
        'LinkLabel1
        '
        Me.LinkLabel1.Location = New System.Drawing.Point(8, 464)
        Me.LinkLabel1.Name = "LinkLabel1"
        Me.LinkLabel1.Size = New System.Drawing.Size(112, 16)
        Me.LinkLabel1.TabIndex = 26
        Me.LinkLabel1.TabStop = True
        Me.LinkLabel1.Text = "MultiConv Website"
        '
        'LinkLabel2
        '
        Me.LinkLabel2.Location = New System.Drawing.Point(304, 464)
        Me.LinkLabel2.Name = "LinkLabel2"
        Me.LinkLabel2.Size = New System.Drawing.Size(152, 16)
        Me.LinkLabel2.TabIndex = 27
        Me.LinkLabel2.TabStop = True
        Me.LinkLabel2.Text = "MultiConv Wrapper Website"
        Me.LinkLabel2.TextAlign = System.Drawing.ContentAlignment.TopRight
        '
        'frmMCW
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(472, 485)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.LinkLabel2, Me.LinkLabel1, Me.Label1, Me.tbZP, Me.lblCapZeroPad, Me.bExit, Me.bClearScreen, Me.bRun, Me.bLoadSettings, Me.bSaveSettings, Me.cbDir, Me.cbOverwrite, Me.tbSuf, Me.lblCapSuf, Me.tbPre, Me.lblCapPre, Me.tbRatio, Me.lblCapResizeRatio, Me.tbHeight, Me.lblCapNewHeight, Me.tbWidth, Me.lblCapNewWidth, Me.GroupBox1, Me.tbFileType, Me.lblCapType, Me.tbDestination, Me.lblCapDestPath, Me.tbSource, Me.lblCapSourcePath})
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.Name = "frmMCW"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "MultiConv Wrapper"
        Me.GroupBox1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub frmMCW_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadDefaults()
    End Sub

    Private Sub LoadDefaults()
        tbSource.Text = ""
        tbDestination.Text = ""
        tbFileType.Text = "jpg"
        tbZP.Text = "2"
        tbPre.Text = ""
        tbSuf.Text = ""

        cbOverwrite.Checked = False
        cbDir.Checked = True
        rbNoResize.Checked = True

        ResetEnabled()
    End Sub

    Private Sub ResetEnabled()
        'Clear out and disable the Width,Height,Ratio fields

        tbWidth.Text = ""
        tbHeight.Text = ""
        tbRatio.Text = ""
        lblCapNewWidth.Enabled = False
        lblCapNewHeight.Enabled = False
        lblCapResizeRatio.Enabled = False
        tbWidth.Enabled = False
        tbHeight.Enabled = False
        tbRatio.Enabled = False
    End Sub

    Private Sub rbNoResize_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbNoResize.CheckedChanged
        If rbNoResize.Checked = True Then
            'If you are not resizing them disable all the fields,
            'you are probably only adding a Prefix and/or Suffix.
            ResetEnabled()
        End If
    End Sub

    Private Sub rbAWH_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbAWH.CheckedChanged
        If rbAWH.Checked = True Then
            'Show Width and Height
            ResetEnabled()
            lblCapNewWidth.Enabled = True
            lblCapNewHeight.Enabled = True
            tbWidth.Enabled = True
            tbHeight.Enabled = True
            tbWidth.Focus()
        End If
    End Sub

    Private Sub rbCW_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbCW.CheckedChanged
        If rbCW.Checked = True Then
            'Show Just Width
            ResetEnabled()
            lblCapNewWidth.Enabled = True
            tbWidth.Enabled = True
            tbWidth.Focus()
        End If
    End Sub

    Private Sub rbCH_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbCH.CheckedChanged
        If rbCH.Checked = True Then
            'Show Just Height.
            ResetEnabled()
            lblCapNewHeight.Enabled = True
            tbHeight.Enabled = True
            tbHeight.Focus()
        End If
    End Sub

    Private Sub rbCWKR_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbCWKR.CheckedChanged
        If rbCWKR.Checked = True Then
            'Show Just Width.
            ResetEnabled()
            lblCapNewWidth.Enabled = True
            tbWidth.Enabled = True
            tbWidth.Focus()
        End If
    End Sub

    Private Sub rbCHKR_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbCHKR.CheckedChanged
        If rbCHKR.Checked = True Then
            'Show Just Height.
            ResetEnabled()
            lblCapNewHeight.Enabled = True
            tbHeight.Enabled = True
            tbHeight.Focus()
        End If
    End Sub

    Private Sub rbResize_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbResize.CheckedChanged
        If rbResize.Checked = True Then
            'Show Just Ratio.
            ResetEnabled()
            lblCapResizeRatio.Enabled = True
            tbRatio.Enabled = True
            tbRatio.Focus()
        End If
    End Sub

    Private Sub bClearScreen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bClearScreen.Click
        LoadDefaults()
    End Sub

    Private Sub bExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bExit.Click
        Application.Exit()
    End Sub

    Private Function CheckFields() As Boolean
        Dim sError As String

        If Not tbSource.Text.Length > 0 Then
            sError = sError & "Please Fill in 'Source Image File/Directory Name:'" & Chr(13) & Chr(13)
        Else
            If Mid(tbSource.Text, Len(tbSource.Text)) = "\" Then
                tbSource.Text = Mid(tbSource.Text, 1, Len(tbSource.Text) - 1)
            End If
        End If

        If Not tbDestination.Text.Length > 0 Then
            sError = sError & "Please Fill in 'Destination Path:'" & Chr(13) & Chr(13)
        Else
            If Mid(tbDestination.Text, Len(tbDestination.Text)) = "\" Then
                tbDestination.Text = Mid(tbDestination.Text, 1, Len(tbDestination.Text) - 1)
            End If
        End If

        If Not tbFileType.Text.Length > 0 Then
            sError = sError & "Please Fill in 'Destination File Type'" & Chr(13) & Chr(13)
        Else
            Dim bOK As Boolean = False
            Select Case Trim(tbFileType.Text.ToUpper)
                Case "JPG"
                    bOK = True
                Case "JPEG"
                    bOK = True
                Case "BMP"
                    bOK = True
                Case "ICO"
                    bOK = True
                Case "PCX"
                    bOK = True
                Case "PNG"
                    bOK = True
                Case "TGA"
                    bOK = True
                Case "TIF"
                    bOK = True
                Case "TIFF"
                    bOK = True
            End Select
            If bOK = False Then
                sError = sError & "Valid Entries for Destination File Type are: jpg,jpeg,bmp,ico,pcx,png,tga,tif,tiff" & Chr(13) & Chr(13)
            End If
        End If

        If rbAWH.Checked = True Then
            If Not tbWidth.Text.Length > 0 And Not tbHeight.Text.Length > 0 Then
                sError = sError & "If 'Absolute Width and Height' is selected then 'New Width' and 'New Height' must be filled in." & Chr(13) & Chr(13)
            End If
        End If

        If rbCW.Checked = True Then
            If Not tbWidth.Text.Length > 0 Then
                sError = sError & "If 'Change Width Only' is selected then 'New Width' must be filled in." & Chr(13) & Chr(13)
            End If
        End If

        If rbCH.Checked = True Then
            If Not tbHeight.Text.Length > 0 Then
                sError = sError & "If 'Change Height Only' is selected then 'New Height' must be filled in." & Chr(13) & Chr(13)
            End If
        End If

        If rbCWKR.Checked = True Then
            If Not tbWidth.Text.Length > 0 Then
                sError = sError & "If 'Change Width, and Keep Ratio' is selected then 'New Width' must be filled in." & Chr(13) & Chr(13)
            End If
        End If

        If rbCHKR.Checked = True Then
            If Not tbHeight.Text.Length > 0 Then
                sError = sError & "If 'Change Height, and Keep Ratio' is selected then 'New Height' must be filled in." & Chr(13) & Chr(13)
            End If
        End If

        If rbResize.Checked = True Then
            If Not tbRatio.Text.Length > 0 Then
                sError = sError & "If 'Resize According to Ratio' is selected then 'Resize Ratio' must be filled in." & Chr(13) & Chr(13)
            End If
        End If

        If IsNumeric(tbZP.Text) = True Then
            If CInt(tbZP.Text) > 99 Or CInt(tbZP.Text) < 1 Then
                sError = sError & "Valid numbers for 'Zero Padding' are: 1-99" & Chr(13) & Chr(13)
            End If
        Else
            sError = sError & "The field 'Zero Padding' should be a numeric field with values between 1-99" & Chr(13) & Chr(13)
        End If

        If tbWidth.Enabled = True And IsNumeric(tbWidth.Text) = False Then
            sError = sError & "New Width is a numeric field. (Number of Pixels)" & Chr(13) & Chr(13)
        End If

        If tbHeight.Enabled = True And IsNumeric(tbHeight.Text) = False Then
            sError = sError & "New Height is a numeric field. (Number of Pixels)" & Chr(13) & Chr(13)
        End If

        If tbRatio.Enabled = True And IsNumeric(tbRatio.Text) = False Then
            sError = sError & "Resize Ratio is a numeric field. (Percentage in decimal form) (50% = .5)" & Chr(13) & Chr(13)
        End If

        If Len(sError) > 0 Then
            MsgBox(sError, MsgBoxStyle.OKOnly, "MultiConv Wrapper")
            Return False
        Else
            Return True
        End If
    End Function

    Private Sub bRun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bRun.Click

        If CheckFields() = False Then
            Exit Sub
        End If

        Dim sCmdLine As String

        sCmdLine = "multiconv"
        sCmdLine = sCmdLine & " /s:" & Trim(tbSource.Text)
        sCmdLine = sCmdLine & " /d:" & Trim(tbDestination.Text)
        If tbFileType.Text <> "jpg" Then
            sCmdLine = sCmdLine & " /x:" & Trim(tbFileType.Text)
        End If
        If rbNoResize.Checked = True Then
            sCmdLine = sCmdLine & " /m:n"
        End If
        If rbAWH.Checked = True Then
            sCmdLine = sCmdLine & " /m:a"
        End If
        If rbCW.Checked = True Then
            sCmdLine = sCmdLine & " /m:w"
        End If
        If rbCH.Checked = True Then
            sCmdLine = sCmdLine & " /m:h"
        End If
        If rbCWKR.Checked = True Then
            sCmdLine = sCmdLine & " /m:wr"
        End If
        If rbCHKR.Checked = True Then
            sCmdLine = sCmdLine & " /m:hr"
        End If
        If tbWidth.Enabled = True Then
            sCmdLine = sCmdLine & " /w:" & Trim(tbWidth.Text)
        End If
        If tbHeight.Enabled = True Then
            sCmdLine = sCmdLine & " /h:" & Trim(tbHeight.Text)
        End If
        If tbRatio.Enabled = True Then
            sCmdLine = sCmdLine & " /r:" & Trim(tbRatio.Text)
        End If
        If cbOverwrite.Checked = True Then
            sCmdLine = sCmdLine & " /o"
        End If
        If cbDir.Checked = True Then
            sCmdLine = sCmdLine & " /nr"
        End If
        If Len(tbPre.Text) > 0 Then
            sCmdLine = sCmdLine & " /pre:" & Trim(tbPre.Text)
        End If
        If Len(tbSuf.Text) > 0 Then
            sCmdLine = sCmdLine & " /suf:" & Trim(tbSuf.Text)
        End If
        sCmdLine = sCmdLine & " /zp:" & Trim(tbZP.Text)

        Call Shell(sCmdLine, AppWinStyle.NormalFocus)

    End Sub

    Private Sub bSaveSettings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bSaveSettings.Click
        Dim SW As StreamWriter
        Dim FS As FileStream

        FS = New FileStream("SAVESET.INI", FileMode.Create)
        SW = New StreamWriter(FS)

        SW.WriteLine("SOURCE" & tbSource.Text)
        SW.WriteLine("DESTIN" & tbDestination.Text)
        SW.WriteLine("FITYPE" & tbFileType.Text)

        If cbOverwrite.Checked = True Then
            SW.WriteLine("OVERWRT")
        Else
            SW.WriteLine("OVERWRF")
        End If

        If cbDir.Checked = True Then
            SW.WriteLine("RECURST")
        Else
            SW.WriteLine("RECURSF")
        End If

        If rbNoResize.Checked = True Then
            SW.WriteLine("NORESIT")
        Else
            SW.WriteLine("NORESIF")
        End If

        If rbAWH.Checked = True Then
            SW.WriteLine("ABSWAHT")
        Else
            SW.WriteLine("ABSWAHF")
        End If

        If rbCW.Checked = True Then
            SW.WriteLine("WIDTHOT")
        Else
            SW.WriteLine("WIDTHOF")
        End If

        If rbCH.Checked = True Then
            SW.WriteLine("HEIGHOT")
        Else
            SW.WriteLine("HEIGHOF")
        End If

        If rbCWKR.Checked = True Then
            SW.WriteLine("WIDTHRT")
        Else
            SW.WriteLine("WIDTHRF")
        End If

        If rbCHKR.Checked = True Then
            SW.WriteLine("HEIGHRT")
        Else
            SW.WriteLine("HEIGHRF")
        End If

        If rbResize.Checked = True Then
            SW.WriteLine("RRATIOT")
        Else
            SW.WriteLine("RRATIOF")
        End If

        SW.WriteLine("NWIDTH" & tbWidth.Text)
        SW.WriteLine("NHEIGH" & tbHeight.Text)
        SW.WriteLine("RATION" & tbRatio.Text)
        SW.WriteLine("PREFIX" & tbPre.Text)
        SW.WriteLine("SUFFIX" & tbSuf.Text)
        SW.WriteLine("ZEROPD" & tbZP.Text)

        MsgBox("Settings Saved.", MsgBoxStyle.OKOnly, "MultiConv Wrapper")

        SW.Close()
        FS.Close()
    End Sub

    Private Sub bLoadSettings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bLoadSettings.Click
        Dim SR As StreamReader
        Dim FS As FileStream

        FS = New FileStream("SAVESET.INI", FileMode.Open)
        SR = New StreamReader(FS)

        Dim itm As String

        itm = SR.ReadLine()
        While Not itm = Nothing
            Select Case Mid(itm, 1, 6)
                Case "SOURCE"
                    tbSource.Text = Mid(itm, 7, Len(itm))
                Case "DESTIN"
                    tbDestination.Text = Mid(itm, 7, Len(itm))
                Case "FITYPE"
                    tbFileType.Text = Mid(itm, 7, Len(itm))
                Case "OVERWR"
                    If Mid(itm, 7, Len(itm)) = "T" Then
                        cbOverwrite.Checked = True
                    Else
                        cbOverwrite.Checked = False
                    End If
                Case "RECURS"
                    If Mid(itm, 7, Len(itm)) = "T" Then
                        cbDir.Checked = True
                    Else
                        cbDir.Checked = False
                    End If
                Case "NORESI"
                    If Mid(itm, 7, Len(itm)) = "T" Then
                        rbNoResize.Checked = True
                    Else
                        rbNoResize.Checked = False
                    End If
                Case "ABSWAH"
                    If Mid(itm, 7, Len(itm)) = "T" Then
                        rbAWH.Checked = True
                    Else
                        rbAWH.Checked = False
                    End If
                Case "WIDTHO"
                    If Mid(itm, 7, Len(itm)) = "T" Then
                        rbCW.Checked = True
                    Else
                        rbCW.Checked = False
                    End If
                Case "HEIGHO"
                    If Mid(itm, 7, Len(itm)) = "T" Then
                        rbCH.Checked = True
                    Else
                        rbCH.Checked = False
                    End If
                Case "WIDTHR"
                    If Mid(itm, 7, Len(itm)) = "T" Then
                        rbCWKR.Checked = True
                    Else
                        rbCWKR.Checked = False
                    End If
                Case "HEIGHR"
                    If Mid(itm, 7, Len(itm)) = "T" Then
                        rbCHKR.Checked = True
                    Else
                        rbCHKR.Checked = False
                    End If
                Case "RRATIO"
                    If Mid(itm, 7, Len(itm)) = "T" Then
                        rbResize.Checked = True
                    Else
                        rbResize.Checked = False
                    End If
                Case "NWIDTH"
                    tbWidth.Text = Mid(itm, 7, Len(itm))
                Case "NHEIGH"
                    tbHeight.Text = Mid(itm, 7, Len(itm))
                Case "RATION"
                    tbRatio.Text = Mid(itm, 7, Len(itm))
                Case "PREFIX"
                    tbPre.Text = Mid(itm, 7, Len(itm))
                Case "SUFFIX"
                    tbSuf.Text = Mid(itm, 7, Len(itm))
                Case "ZEROPD"
                    tbZP.Text = Mid(itm, 7, Len(itm))
            End Select
            itm = SR.ReadLine()
        End While

        SR.Close()
        FS.Close()
    End Sub

    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        System.Diagnostics.Process.Start("http://www.ruijiang.com")
    End Sub

    Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked
        System.Diagnostics.Process.Start("http://brixon.freewebspace.com/MultiConvWrapper/MultiConvWrapper.html")
    End Sub
End Class