63 lines
2.1 KiB
PowerShell
63 lines
2.1 KiB
PowerShell
Add-Type -AssemblyName System.Windows.Forms
|
|
Import-Module PnP.PowerShell
|
|
|
|
# Import our components
|
|
. "$PSScriptRoot\SharePointFunctions.ps1"
|
|
. "$PSScriptRoot\EventHandlers.ps1"
|
|
|
|
# Create main form
|
|
$form = New-Object System.Windows.Forms.Form
|
|
$form.Text = "SharePoint XLS Converter"
|
|
$form.Size = New-Object System.Drawing.Size(600,400)
|
|
|
|
# Add controls
|
|
$txtSiteUrl = New-Object System.Windows.Forms.TextBox
|
|
$txtSiteUrl.Location = New-Object System.Drawing.Point(20,120)
|
|
$txtSiteUrl.Size = New-Object System.Drawing.Size(200,20)
|
|
|
|
$btnSaveConfig = New-Object System.Windows.Forms.Button
|
|
$btnSaveConfig.Location = New-Object System.Drawing.Point(230,120)
|
|
$btnSaveConfig.Size = New-Object System.Drawing.Size(80,20)
|
|
$btnSaveConfig.Text = "Save Config"
|
|
|
|
$btnList = New-Object System.Windows.Forms.Button
|
|
$btnList.Location = New-Object System.Drawing.Point(20,20)
|
|
$btnList.Size = New-Object System.Drawing.Size(120,30)
|
|
$btnList.Text = "List XLS Files"
|
|
$form.Controls.Add($btnList)
|
|
|
|
$btnConvert = New-Object System.Windows.Forms.Button
|
|
$btnConvert.Location = New-Object System.Drawing.Point(160,20)
|
|
$btnConvert.Size = New-Object System.Drawing.Size(120,30)
|
|
$btnConvert.Text = "Convert to XLSX"
|
|
$form.Controls.Add($btnConvert)
|
|
|
|
$btnMove = New-Object System.Windows.Forms.Button
|
|
$btnMove.Location = New-Object System.Drawing.Point(300,20)
|
|
$btnMove.Size = New-Object System.Drawing.Size(120,30)
|
|
$btnMove.Text = "Move Files"
|
|
$form.Controls.Add($btnMove)
|
|
|
|
$txtStatus = New-Object System.Windows.Forms.TextBox
|
|
$txtStatus.Location = New-Object System.Drawing.Point(20,70)
|
|
$txtStatus.Size = New-Object System.Drawing.Size(540,280)
|
|
$txtStatus.Multiline = $true
|
|
$txtStatus.ScrollBars = "Vertical"
|
|
$form.Controls.Add($txtStatus)
|
|
$form.Controls.Add($txtSiteUrl)
|
|
$form.Controls.Add($btnSaveConfig)
|
|
|
|
# Load configuration
|
|
if (-not (Load-Config)) {
|
|
[System.Windows.Forms.MessageBox]::Show("Configuration missing! Please enter settings.")
|
|
}
|
|
|
|
# Attach event handlers
|
|
$btnList.Add_Click({ List-XlsFiles })
|
|
$btnConvert.Add_Click({ Convert-Files })
|
|
$btnMove.Add_Click({ Move-Files })
|
|
|
|
# Show form
|
|
$form.Add_Shown({$form.Activate()})
|
|
[void]$form.ShowDialog()
|