textfield custom name for shortcut
This commit is contained in:
parent
9abe201389
commit
347ffa1c2e
|
|
@ -127,7 +127,7 @@ function Show-UserSelectionDialog {
|
|||
|
||||
$form = New-Object System.Windows.Forms.Form
|
||||
$form.Text = "Benutzer ausw$([char]0x00E4)hlen - Freigabe"
|
||||
$form.Size = New-Object System.Drawing.Size(450, 530)
|
||||
$form.Size = New-Object System.Drawing.Size(450, 570)
|
||||
$form.StartPosition = "CenterScreen"
|
||||
$form.FormBorderStyle = "FixedDialog"
|
||||
$form.MaximizeBox = $false
|
||||
|
|
@ -165,24 +165,63 @@ function Show-UserSelectionDialog {
|
|||
}
|
||||
})
|
||||
|
||||
$chkFullPath = New-Object System.Windows.Forms.CheckBox
|
||||
$chkFullPath.Text = "Kompletten Pfad in Verkn$([char]0x00FC)pfungsname schreiben"
|
||||
$chkFullPath.Location = New-Object System.Drawing.Point(10, 385)
|
||||
$chkFullPath.Size = New-Object System.Drawing.Size(410, 25)
|
||||
$chkFullPath.Font = New-Object System.Drawing.Font("Segoe UI", 9)
|
||||
$form.Controls.Add($chkFullPath)
|
||||
# Gruppierung fuer Verknuepfungsname
|
||||
$grpName = New-Object System.Windows.Forms.GroupBox
|
||||
$grpName.Text = "Verkn$([char]0x00FC)pfungsname"
|
||||
$grpName.Location = New-Object System.Drawing.Point(10, 380)
|
||||
$grpName.Size = New-Object System.Drawing.Size(410, 105)
|
||||
$grpName.Font = New-Object System.Drawing.Font("Segoe UI", 9)
|
||||
$form.Controls.Add($grpName)
|
||||
|
||||
$lblExample = New-Object System.Windows.Forms.Label
|
||||
$lblExample.Text = "(z.B. 'Mandanten - S - Schmidt - Lohn' statt nur 'Lohn')"
|
||||
$lblExample.Location = New-Object System.Drawing.Point(27, 408)
|
||||
$lblExample.Size = New-Object System.Drawing.Size(400, 20)
|
||||
$lblExample.ForeColor = [System.Drawing.Color]::Gray
|
||||
$lblExample.Font = New-Object System.Drawing.Font("Segoe UI", 8)
|
||||
$form.Controls.Add($lblExample)
|
||||
# Radio: Standard (Ordnername)
|
||||
$rbStandard = New-Object System.Windows.Forms.RadioButton
|
||||
$rbStandard.Text = "Ordnername (Standard)"
|
||||
$rbStandard.Location = New-Object System.Drawing.Point(10, 20)
|
||||
$rbStandard.Size = New-Object System.Drawing.Size(180, 22)
|
||||
$rbStandard.Checked = $true
|
||||
$grpName.Controls.Add($rbStandard)
|
||||
|
||||
# Radio: Kompletter Pfad
|
||||
$rbFullPath = New-Object System.Windows.Forms.RadioButton
|
||||
$rbFullPath.Text = "Kompletter Pfad"
|
||||
$rbFullPath.Location = New-Object System.Drawing.Point(200, 20)
|
||||
$rbFullPath.Size = New-Object System.Drawing.Size(180, 22)
|
||||
$grpName.Controls.Add($rbFullPath)
|
||||
|
||||
# Radio: Eigener Name
|
||||
$rbCustom = New-Object System.Windows.Forms.RadioButton
|
||||
$rbCustom.Text = "Eigener Name:"
|
||||
$rbCustom.Location = New-Object System.Drawing.Point(10, 50)
|
||||
$rbCustom.Size = New-Object System.Drawing.Size(110, 22)
|
||||
$grpName.Controls.Add($rbCustom)
|
||||
|
||||
# Textfeld fuer eigenen Namen
|
||||
$txtCustomName = New-Object System.Windows.Forms.TextBox
|
||||
$txtCustomName.Location = New-Object System.Drawing.Point(125, 50)
|
||||
$txtCustomName.Size = New-Object System.Drawing.Size(270, 22)
|
||||
$txtCustomName.Enabled = $false
|
||||
$grpName.Controls.Add($txtCustomName)
|
||||
|
||||
# Hinweistext
|
||||
$lblHint = New-Object System.Windows.Forms.Label
|
||||
$lblHint.Text = "Kompletter Pfad: z.B. 'Mandanten - S - Schmidt - Lohn'"
|
||||
$lblHint.Location = New-Object System.Drawing.Point(10, 78)
|
||||
$lblHint.Size = New-Object System.Drawing.Size(390, 18)
|
||||
$lblHint.ForeColor = [System.Drawing.Color]::Gray
|
||||
$lblHint.Font = New-Object System.Drawing.Font("Segoe UI", 8)
|
||||
$grpName.Controls.Add($lblHint)
|
||||
|
||||
# Event: Textfeld aktivieren wenn "Eigener Name" gewaehlt
|
||||
$rbCustom.Add_CheckedChanged({
|
||||
$txtCustomName.Enabled = $rbCustom.Checked
|
||||
if ($rbCustom.Checked) {
|
||||
$txtCustomName.Focus()
|
||||
}
|
||||
})
|
||||
|
||||
$okBtn = New-Object System.Windows.Forms.Button
|
||||
$okBtn.Text = "Freigeben"
|
||||
$okBtn.Location = New-Object System.Drawing.Point(240, 450)
|
||||
$okBtn.Location = New-Object System.Drawing.Point(240, 495)
|
||||
$okBtn.Size = New-Object System.Drawing.Size(85, 30)
|
||||
$okBtn.Enabled = $false
|
||||
$okBtn.DialogResult = [System.Windows.Forms.DialogResult]::OK
|
||||
|
|
@ -191,7 +230,7 @@ function Show-UserSelectionDialog {
|
|||
|
||||
$cancelBtn = New-Object System.Windows.Forms.Button
|
||||
$cancelBtn.Text = "Abbrechen"
|
||||
$cancelBtn.Location = New-Object System.Drawing.Point(335, 450)
|
||||
$cancelBtn.Location = New-Object System.Drawing.Point(335, 495)
|
||||
$cancelBtn.Size = New-Object System.Drawing.Size(85, 30)
|
||||
$cancelBtn.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
|
||||
$form.CancelButton = $cancelBtn
|
||||
|
|
@ -209,17 +248,25 @@ function Show-UserSelectionDialog {
|
|||
})
|
||||
|
||||
$script:selectedUser = $null
|
||||
$script:useFullPath = $false
|
||||
$script:nameMode = "standard"
|
||||
$script:customName = ""
|
||||
|
||||
if ($form.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK -and $listBox.SelectedIndex -ge 0) {
|
||||
$selectedText = $listBox.SelectedItem
|
||||
$script:selectedUser = $script:allUsers | Where-Object { $_.FullName -eq $selectedText } | Select-Object -First 1
|
||||
$script:useFullPath = $chkFullPath.Checked
|
||||
|
||||
if ($rbFullPath.Checked) {
|
||||
$script:nameMode = "fullpath"
|
||||
} elseif ($rbCustom.Checked) {
|
||||
$script:nameMode = "custom"
|
||||
$script:customName = $txtCustomName.Text.Trim()
|
||||
}
|
||||
}
|
||||
|
||||
return @{
|
||||
User = $script:selectedUser
|
||||
UseFullPath = $script:useFullPath
|
||||
NameMode = $script:nameMode
|
||||
CustomName = $script:customName
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -315,7 +362,8 @@ try {
|
|||
}
|
||||
|
||||
$selectedUser = $dialogResult.User
|
||||
$useFullPath = $dialogResult.UseFullPath
|
||||
$nameMode = $dialogResult.NameMode
|
||||
$customName = $dialogResult.CustomName
|
||||
|
||||
$userName = $selectedUser.SamAccountName
|
||||
$userFolder = Join-Path $basePath $userName
|
||||
|
|
@ -327,7 +375,8 @@ try {
|
|||
$uncPath = Get-UNCPath -LocalPath $Path
|
||||
|
||||
# Verknuepfungsname erstellen
|
||||
if ($useFullPath) {
|
||||
switch ($nameMode) {
|
||||
"fullpath" {
|
||||
# Kompletten Pfad verwenden: \\server\Mandanten\S\Schmidt\Lohn -> Mandanten - S - Schmidt - Lohn
|
||||
$pathForName = $uncPath
|
||||
# UNC-Prefix und Servernamen entfernen
|
||||
|
|
@ -336,8 +385,19 @@ try {
|
|||
}
|
||||
# Backslashes durch " - " ersetzen
|
||||
$itemName = $pathForName -replace '\\', ' - '
|
||||
} else {
|
||||
}
|
||||
"custom" {
|
||||
# Eigener Name vom Benutzer
|
||||
if ([string]::IsNullOrWhiteSpace($customName)) {
|
||||
$itemName = Split-Path -Path $Path -Leaf
|
||||
} else {
|
||||
$itemName = $customName
|
||||
}
|
||||
}
|
||||
default {
|
||||
# Standard: nur Ordnername
|
||||
$itemName = Split-Path -Path $Path -Leaf
|
||||
}
|
||||
}
|
||||
|
||||
# Ungueltige Zeichen fuer Dateinamen entfernen/ersetzen
|
||||
|
|
|
|||
Loading…
Reference in New Issue