Private/Show-LeanODBLogFileUI.ps1

function Show-LeanODBLogFileUI {
    Add-Type -AssemblyName System.Windows.Forms
    Add-Type -AssemblyName System.Drawing

    # --- Form ---
    $form                 = [System.Windows.Forms.Form]::new()
    $form.Text            = 'New-LeanODBLogFile'
    $form.Size            = [System.Drawing.Size]::new(460, 220)
    $form.StartPosition   = 'CenterScreen'
    $form.FormBorderStyle = 'FixedDialog'
    $form.MaximizeBox     = $false

    # --- Path ---
    $lblPath          = [System.Windows.Forms.Label]::new()
    $lblPath.Text     = 'Path'
    $lblPath.Location = [System.Drawing.Point]::new(12, 12)
    $lblPath.Size     = [System.Drawing.Size]::new(200, 16)

    $txtPath          = [System.Windows.Forms.TextBox]::new()
    $txtPath.Location = [System.Drawing.Point]::new(12, 30)
    $txtPath.Size     = [System.Drawing.Size]::new(330, 22)

    $btnBrowse          = [System.Windows.Forms.Button]::new()
    $btnBrowse.Text     = 'Browse'
    $btnBrowse.Location = [System.Drawing.Point]::new(348, 29)
    $btnBrowse.Size     = [System.Drawing.Size]::new(84, 24)
    $btnBrowse.Add_Click({
        $dlg = [System.Windows.Forms.OpenFileDialog]::new()
        $dlg.Filter = if ($radWindows.Checked) {
            'Windows log archive (*.cab)|*.cab'
        } else {
            'Mac log archive (*.zip)|*.zip'
        }
        if ($dlg.ShowDialog() -eq 'OK') { $txtPath.Text = $dlg.FileName }
    })

    # --- Date ---
    $lblDate          = [System.Windows.Forms.Label]::new()
    $lblDate.Text     = 'Date'
    $lblDate.Location = [System.Drawing.Point]::new(12, 65)
    $lblDate.Size     = [System.Drawing.Size]::new(140, 16)

    $dtpDate          = [System.Windows.Forms.DateTimePicker]::new()
    $dtpDate.Location = [System.Drawing.Point]::new(12, 83)
    $dtpDate.Size     = [System.Drawing.Size]::new(145, 22)
    $dtpDate.Format   = 'Short'
    $dtpDate.Value    = (Get-Date)

    # --- Platform (GroupBox + RadioButtons) ---
    $grpPlat          = [System.Windows.Forms.GroupBox]::new()
    $grpPlat.Text     = 'Platform'
    $grpPlat.Location = [System.Drawing.Point]::new(165, 58)
    $grpPlat.Size     = [System.Drawing.Size]::new(165, 50)

    $radWindows           = [System.Windows.Forms.RadioButton]::new()
    $radWindows.Text      = 'Windows'
    $radWindows.Location  = [System.Drawing.Point]::new(8, 18)
    $radWindows.Size      = [System.Drawing.Size]::new(72, 20)
    $radWindows.Checked   = $true

    $radMac           = [System.Windows.Forms.RadioButton]::new()
    $radMac.Text      = 'Mac'
    $radMac.Location  = [System.Drawing.Point]::new(90, 18)
    $radMac.Size      = [System.Drawing.Size]::new(50, 20)

    $grpPlat.Controls.AddRange(@($radWindows, $radMac))

    # --- Split checkbox ---
    $chkSplit          = [System.Windows.Forms.CheckBox]::new()
    $chkSplit.Text     = 'Do not split parsed log over 15 MB'
    $chkSplit.Location = [System.Drawing.Point]::new(12, 120)
    $chkSplit.Size     = [System.Drawing.Size]::new(220, 22)

    # --- Buttons ---
    $btnCancel              = [System.Windows.Forms.Button]::new()
    $btnCancel.Text         = 'Cancel'
    $btnCancel.Location     = [System.Drawing.Point]::new(260, 148)
    $btnCancel.Size         = [System.Drawing.Size]::new(80, 28)
    $btnCancel.DialogResult = 'Cancel'
    $form.CancelButton      = $btnCancel

    $btnRun          = [System.Windows.Forms.Button]::new()
    $btnRun.Text     = 'Run'
    $btnRun.Location = [System.Drawing.Point]::new(348, 148)
    $btnRun.Size     = [System.Drawing.Size]::new(84, 28)
    $btnRun.Add_Click({
        $ext         = [System.IO.Path]::GetExtension($txtPath.Text).ToLower()
        $expectedExt = if ($radWindows.Checked) { '.cab' } else { '.zip' }
        if ($txtPath.Text -ne '' -and $ext -ne $expectedExt) {
            [void][System.Windows.Forms.MessageBox]::Show(
                "Only log files generated with CollectSyncLogs.bat are supported.`nTherefore, a *.cab is expected for Windows and a *.zip for Mac.",
                'Invalid File Type',
                [System.Windows.Forms.MessageBoxButtons]::OK,
                [System.Windows.Forms.MessageBoxIcon]::Warning
            )
            return
        }
        $form.DialogResult = [System.Windows.Forms.DialogResult]::OK
    })
    $form.AcceptButton = $btnRun

    $form.Controls.AddRange(@(
        $lblPath, $txtPath, $btnBrowse,
        $lblDate, $dtpDate,
        $grpPlat,
        $chkSplit,
        $btnCancel, $btnRun
    ))

    if ($form.ShowDialog() -ne 'OK') { return $null }

    return @{
        Path     = $txtPath.Text.Trim()
        Date     = $dtpDate.Value.ToString('yyyy-MM-dd')
        Platform = if ($radWindows.Checked) { 'Windows' } else { 'Mac' }
        NoSplit  = $chkSplit.Checked
    }
}