Files
FS_Admin_Panel/GUIS/confirm.ps1
Florian Späth afb2f418fc init
2025-01-31 01:49:31 +01:00

98 lines
3.8 KiB
PowerShell

function Load_confirm {
param ($root)
[XML]$Form = @"
<?xaml encoding="utf-8"?>
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Name="Window" Title="HDS Admin Panel - Confirm" Height="276" Width="509" Icon="{Binding Icon}" ResizeMode="NoResize" WindowStyle="None">
<Grid Background="#00344E">
<Button Name="btnstop" Content="BACK" HorizontalAlignment="Left" Margin="122,215,0,0" VerticalAlignment="Top" Width="100" Height="36" BorderThickness="0" Background="DarkGreen" Foreground="White">
<Button.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="2"/>
</Style>
</Button.Resources>
<Button.Style>
<Style TargetType="Button">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Red"/>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<Label Content="Confirm" HorizontalAlignment="Left" VerticalAlignment="Top" Width="509" HorizontalContentAlignment="Center" Foreground="White" FontSize="20" FontWeight="Bold"/>
<Label Name="choosen3" Content="Confirm the action and press the button again" HorizontalAlignment="Center" Margin="0,42,0,0" VerticalAlignment="Top" Width="270" Height="34" FontSize="12" FontWeight="Bold" Foreground="White"/>
<TextBox Name="text" Text="TEXT" BorderThickness="0" HorizontalAlignment="Center" Height="113" TextWrapping="Wrap" VerticalAlignment="Center" Width="412" Background="#013C5A" HorizontalContentAlignment="Center" Foreground="White" FontSize="14" IsTabStop="False"/>
<Button Name="btngo" Content="GO!" HorizontalAlignment="Left" Margin="286,215,0,0" VerticalAlignment="Top" Width="100" Height="36" BorderThickness="0" Background="DarkRed" Foreground="White">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="2"/>
</Style>
</Button.Resources>
<Button.Style>
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Red"/>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</Grid>
</Window>
"@
# Lädt das Fenster
$window=[Windows.Markup.XamlReader]::Load((New-Object System.Xml.XmlNodeReader $Form))
$NR=(New-Object System.Xml.XmlNodeReader $Form)
$window=[Windows.Markup.XamlReader]::Load($NR)
# Objekt - Variablen Verknüpfung
$Script:confirmtext = $window.FindName("text")
$Script:confirmok = $window.findName("btngo")
$Script:confirmstop = $window.findName("btnstop")
# Verknüpft feste Elemente
$window.Title = $Script:Version
$window.icon="$root/Source/Logo.png"
return $window
}
function confirm {
param (
[String]$text
)
Write-Admin-Log "Confirm funkction triggered"
if ($null -ne $text) {
$Script:Confirmtext.text = $text
$confirm.ShowDialog() | Out-Null
if ($Script:GO) {
return $true
}
}
}
$Script:confirm = Load_confirm $args[0] # Variable: $confirm
$confirmok.Add_Click({
Write-Admin-Log "Confirm success"
$Script:GO = $true
$confirm.Hide()
})
$confirm.Add_MouseLeftButtonDown({
$confirm.DragMove()
})
$confirmstop.Add_Click({
Write-Admin-Log "Confirm denial"
$Script:GO = $false
$confirm.Hide()
})