refactor: Reposition status textbox and add DataGridView in MainForm.ps1
This commit is contained in:
parent
aed44fc07d
commit
2c18235425
33
MainForm.ps1
33
MainForm.ps1
@ -10,7 +10,7 @@ Import-Module Microsoft.Graph.Files
|
|||||||
# Create main form
|
# Create main form
|
||||||
$form = New-Object System.Windows.Forms.Form
|
$form = New-Object System.Windows.Forms.Form
|
||||||
$form.Text = "SharePoint XLS Converter"
|
$form.Text = "SharePoint XLS Converter"
|
||||||
$form.Size = New-Object System.Drawing.Size(600,500)
|
$form.Size = New-Object System.Drawing.Size(800, 600) # Increased form size
|
||||||
|
|
||||||
# Set AutoScaleMode to Dpi
|
# Set AutoScaleMode to Dpi
|
||||||
$form.AutoScaleMode = [System.Windows.Forms.AutoScaleMode]::Dpi
|
$form.AutoScaleMode = [System.Windows.Forms.AutoScaleMode]::Dpi
|
||||||
@ -65,17 +65,33 @@ $btnMove.Size = New-Object System.Drawing.Size(120,30)
|
|||||||
$btnMove.Text = "Move Files"
|
$btnMove.Text = "Move Files"
|
||||||
$form.Controls.Add($btnMove)
|
$form.Controls.Add($btnMove)
|
||||||
|
|
||||||
|
# Create Status TextBox (Top Right)
|
||||||
$txtStatus = New-Object System.Windows.Forms.TextBox
|
$txtStatus = New-Object System.Windows.Forms.TextBox
|
||||||
$txtStatus.Location = New-Object System.Drawing.Point(20,210)
|
$txtStatus.Location = New-Object System.Drawing.Point(450, 20) # Top Right Corner
|
||||||
$txtStatus.Size = New-Object System.Drawing.Size(540,240)
|
$txtStatus.Size = New-Object System.Drawing.Size(330, 180) # Adjusted size
|
||||||
$txtStatus.Multiline = $true
|
$txtStatus.Multiline = $true
|
||||||
$txtStatus.ScrollBars = "Vertical"
|
$txtStatus.ScrollBars = "Vertical"
|
||||||
# Anchor the textbox to the form's edges
|
|
||||||
$txtStatus.Anchor = [System.Windows.Forms.AnchorStyles]::Top -bor `
|
$txtStatus.Anchor = [System.Windows.Forms.AnchorStyles]::Top -bor `
|
||||||
[System.Windows.Forms.AnchorStyles]::Bottom -bor `
|
|
||||||
[System.Windows.Forms.AnchorStyles]::Left -bor `
|
|
||||||
[System.Windows.Forms.AnchorStyles]::Right
|
[System.Windows.Forms.AnchorStyles]::Right
|
||||||
$form.Controls.Add($txtStatus)
|
$form.Controls.Add($txtStatus)
|
||||||
|
|
||||||
|
# Create DataGridView (Lower 2/3)
|
||||||
|
$dataGridView = New-Object System.Windows.Forms.DataGridView
|
||||||
|
$dataGridView.Location = New-Object System.Drawing.Point(20, 210)
|
||||||
|
$dataGridView.Size = New-Object System.Drawing.Size(760, 340) # Lower 2/3 of the form
|
||||||
|
$dataGridView.Anchor = [System.Windows.Forms.AnchorStyles]::Bottom -bor `
|
||||||
|
[System.Windows.Forms.AnchorStyles]::Left -bor `
|
||||||
|
[System.Windows.Forms.AnchorStyles]::Right -bor `
|
||||||
|
[System.Windows.Forms.AnchorStyles]::Top
|
||||||
|
$dataGridView.AutoSizeColumnsMode = [System.Windows.Forms.DataGridViewAutoSizeColumnsMode]::Fill
|
||||||
|
$form.Controls.Add($dataGridView)
|
||||||
|
|
||||||
|
# Add columns to DataGridView
|
||||||
|
$dataGridView.ColumnCount = 3
|
||||||
|
$dataGridView.Columns[0].Name = "Original Path"
|
||||||
|
$dataGridView.Columns[1].Name = "Original File Name"
|
||||||
|
$dataGridView.Columns[2].Name = "Temp Path"
|
||||||
|
|
||||||
# Add Save Config button
|
# Add Save Config button
|
||||||
$btnSaveConfig = New-Object System.Windows.Forms.Button
|
$btnSaveConfig = New-Object System.Windows.Forms.Button
|
||||||
$btnSaveConfig.Location = New-Object System.Drawing.Point(230, 40)
|
$btnSaveConfig.Location = New-Object System.Drawing.Point(230, 40)
|
||||||
@ -133,7 +149,6 @@ $btnBrowse.Add_Click({
|
|||||||
if ($selectedFolder) {
|
if ($selectedFolder) {
|
||||||
# Use the ServerRelativeUrl directly from the folder browser
|
# Use the ServerRelativeUrl directly from the folder browser
|
||||||
$script:txtFolder.Text = $selectedFolder.ServerRelativeUrl
|
$script:txtFolder.Text = $selectedFolder.ServerRelativeUrl
|
||||||
$script:txtStatus.Text += "Selected folder: $($selectedFolder.ServerRelativeUrl)`n"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
@ -141,6 +156,10 @@ $btnBrowse.Add_Click({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Store the DataGridView and txtStatus in script scope
|
||||||
|
$script:dataGridView = $dataGridView
|
||||||
|
$script:txtStatus = $txtStatus
|
||||||
|
|
||||||
# Show form
|
# Show form
|
||||||
$form.Add_Shown({ $form.Activate() })
|
$form.Add_Shown({ $form.Activate() })
|
||||||
[void]$form.ShowDialog()
|
[void]$form.ShowDialog()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user