Enhance system information retrieval and GUI styling

- Improved error handling in Get-SystemInfo function for OS and computer system retrieval.
- Enhanced license status detection with clearer status messages.
- Updated GUI dimensions for better layout.
- Adjusted font sizes and padding for navigation buttons and action cards.
- Added drop shadow effect to card styles for improved visual depth.
- Increased icon font size for better visibility.
This commit is contained in:
Mykola08 2026-01-15 22:03:59 +01:00
parent 135aa20d5a
commit 27b9140dbc
3 changed files with 37 additions and 4882 deletions

File diff suppressed because it is too large Load diff

View file

@ -21,18 +21,33 @@ Add-Type -AssemblyName System.Drawing
# --- Helper: Get System Info --- # --- Helper: Get System Info ---
function Get-SystemInfo { function Get-SystemInfo {
try { try {
$os = Get-CimInstance Win32_OperatingSystem $os = Get-CimInstance Win32_OperatingSystem -ErrorAction Stops
$comp = Get-CimInstance Win32_ComputerSystem $comp = Get-CimInstance Win32_ComputerSystem -ErrorAction Stop
$edition = $os.Caption -replace "Microsoft ", "" $edition = $os.Caption -replace "Microsoft ", ""
$version = $os.Version $version = $os.Version
$build = $os.BuildNumber $build = $os.BuildNumber
# Simple Activation Check (Partial) # Simple Activation Check (Partial)
# 1=Licensed try {
$license = Get-CimInstance SoftwareLicensingProduct | Where-Object { $_.PartialProductKey -and $_.Name -like "Windows*" } | Select-Object -First 1 # 1=Licensed
$status = if ($license.LicenseStatus -eq 1) { "Permanently Activated" } else { "Not Activated / check details" } $license = Get-CimInstance SoftwareLicensingProduct -ErrorAction SilentlyContinue | Where-Object { $_.PartialProductKey -and $_.Name -like "Windows*" } | Select-Object -First 1
if ($license.LicenseStatus -eq 1 -and $license.GracePeriodRemaining -gt 0) { $status = "Volume/KMS Activated" } $status = "Unknown / Check manually"
if ($null -ne $license) {
if ($license.LicenseStatus -eq 1) {
$status = "Permanently Activated"
if ($license.GracePeriodRemaining -gt 0 -and $license.GracePeriodRemaining -lt 40000) {
# KMS usually has grace period in minutes ~ 259200 (180 days)
$status = "Volume/KMS Activated"
}
} else {
$status = "Not Activated"
}
}
} catch {
$status = "Detection Failed"
}
return @{ return @{
Edition = $edition Edition = $edition
@ -41,7 +56,7 @@ function Get-SystemInfo {
PCName = $comp.Name PCName = $comp.Name
} }
} catch { } catch {
return @{ Edition = "Unknown"; Version = ""; Status = "Unknown"; PCName = "Unknown" } return @{ Edition = "Unknown"; Version = "Unknown"; Status = "Unknown"; PCName = "Unknown" }
} }
} }
@ -51,7 +66,7 @@ $sysInfo = Get-SystemInfo
[xml]$xaml = @" [xml]$xaml = @"
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Microsoft Activation Scripts" Height="600" Width="950" Title="Microsoft Activation Scripts" Height="650" Width="1000"
WindowStartupLocation="CenterScreen" ResizeMode="CanResize" WindowStartupLocation="CenterScreen" ResizeMode="CanResize"
Background="#202020" Foreground="#FFFFFF" FontFamily="Segoe UI Variable Display, Segoe UI, sans-serif"> Background="#202020" Foreground="#FFFFFF" FontFamily="Segoe UI Variable Display, Segoe UI, sans-serif">
@ -96,28 +111,24 @@ $sysInfo = Get-SystemInfo
</Style> </Style>
<!-- Navigation RadioButton Style --> <!-- Navigation RadioButton Style -->
<!-- We use RadioButtons for tabs to simulate NavigationView properly -->
<Style x:Key="NavButtonStyle" TargetType="RadioButton"> <Style x:Key="NavButtonStyle" TargetType="RadioButton">
<Setter Property="Background" Value="Transparent"/> <Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="#D0D0D0"/> <Setter Property="Foreground" Value="#D0D0D0"/>
<Setter Property="FontSize" Value="14"/> <Setter Property="FontSize" Value="15"/>
<Setter Property="Margin" Value="5,2"/> <Setter Property="Margin" Value="5,2"/>
<Setter Property="Padding" Value="10,8"/> <Setter Property="Padding" Value="16,10"/>
<Setter Property="Cursor" Value="Hand"/> <Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="RadioButton"> <ControlTemplate TargetType="RadioButton">
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="4"> <Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="4"/> <ColumnDefinition Width="4"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<!-- Active Indicator -->
<Rectangle x:Name="indicator" Grid.Column="0" Fill="{StaticResource AccentColor}" Height="16" RadiusX="2" RadiusY="2" Visibility="Collapsed" Margin="0,0,0,0"/> <Rectangle x:Name="indicator" Grid.Column="0" Fill="{StaticResource AccentColor}" Height="16" RadiusX="2" RadiusY="2" Visibility="Collapsed" Margin="0,0,0,0"/>
<ContentPresenter Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="12,0,0,0"/>
<ContentPresenter Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0"/>
</Grid> </Grid>
</Border> </Border>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
@ -126,7 +137,7 @@ $sysInfo = Get-SystemInfo
<Setter Property="Foreground" Value="White"/> <Setter Property="Foreground" Value="White"/>
</Trigger> </Trigger>
<Trigger Property="IsChecked" Value="True"> <Trigger Property="IsChecked" Value="True">
<Setter TargetName="border" Property="Background" Value="#303030"/> <Setter TargetName="border" Property="Background" Value="#333333"/>
<Setter Property="Foreground" Value="White"/> <Setter Property="Foreground" Value="White"/>
<Setter TargetName="indicator" Property="Visibility" Value="Visible"/> <Setter TargetName="indicator" Property="Visibility" Value="Visible"/>
</Trigger> </Trigger>
@ -142,8 +153,13 @@ $sysInfo = Get-SystemInfo
<Setter Property="BorderBrush" Value="{StaticResource CardBorder}"/> <Setter Property="BorderBrush" Value="{StaticResource CardBorder}"/>
<Setter Property="BorderThickness" Value="1"/> <Setter Property="BorderThickness" Value="1"/>
<Setter Property="CornerRadius" Value="8"/> <Setter Property="CornerRadius" Value="8"/>
<Setter Property="Padding" Value="20"/> <Setter Property="Padding" Value="24"/>
<Setter Property="Margin" Value="0,0,0,15"/> <Setter Property="Margin" Value="0,0,0,15"/>
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="10" ShadowDepth="2" Direction="270" Color="Black" Opacity="0.2"/>
</Setter.Value>
</Setter>
</Style> </Style>
<!-- Action Card Style --> <!-- Action Card Style -->
@ -151,17 +167,18 @@ $sysInfo = Get-SystemInfo
<Setter Property="Background" Value="{StaticResource CardBackground}"/> <Setter Property="Background" Value="{StaticResource CardBackground}"/>
<Setter Property="Height" Value="Auto"/> <Setter Property="Height" Value="Auto"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/> <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="Margin" Value="0,0,0,15"/>
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="Button"> <ControlTemplate TargetType="Button">
<Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{StaticResource CardBorder}" BorderThickness="1" CornerRadius="8" Padding="20"> <Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{StaticResource CardBorder}" BorderThickness="1" CornerRadius="8" Padding="24">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<ContentPresenter Grid.Column="0" HorizontalAlignment="Left"/> <ContentPresenter Grid.Column="0" HorizontalAlignment="Left"/>
<TextBlock Grid.Column="1" Text="&#xE76C;" FontFamily="Segoe Fluent Icons, Segoe MDL2 Assets" FontSize="16" Foreground="{StaticResource AccentColor}" VerticalAlignment="Center"/> <TextBlock Grid.Column="1" Text="&#xE76C;" FontFamily="Segoe Fluent Icons, Segoe MDL2 Assets" FontSize="18" Foreground="{StaticResource AccentColor}" VerticalAlignment="Center"/>
</Grid> </Grid>
</Border> </Border>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>