Files
psg-oversight-app/LD-SysInfo/MainWindow.xaml
2025-10-10 12:06:35 +08:00

417 lines
18 KiB
XML

<Window x:Class="LD_SysInfo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LD_SysInfo"
xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:materialDesignAssist="clr-namespace:MaterialDesignThemes.Wpf;assembly=MaterialDesignThemes.Wpf"
mc:Ignorable="d"
Title="PSG - Oversight"
Height="500"
Width="400"
Icon="Assets/trayicon.ico"
WindowStyle="None"
AllowsTransparency="True"
Background="Transparent"
Foreground="{DynamicResource TextDarkBrush}">
<Window.Resources>
<ContextMenu x:Key="TrayMenu">
<MenuItem Header="Show Window" Click="ShowWindow_Click"/>
<MenuItem Header="Exit" Click="Exit_Click"/>
</ContextMenu>
<Style TargetType="TabControl">
<Setter Property="Background" Value="{DynamicResource BackgroundDarkBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Padding" Value="0" />
</Style>
<Style TargetType="TabItem">
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="MinWidth" Value="118" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabItem">
<Grid>
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="6"
Margin="2">
<ContentPresenter
HorizontalAlignment="Center"
VerticalAlignment="Center"
ContentSource="Header"
Margin="12,4"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<!-- Trigger for selected tab -->
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#4776cd" />
<!-- Selected Background -->
<Setter Property="BorderBrush" Value="#E5E4E2" />
<!-- Selected Border -->
<Setter Property="Foreground" Value="#E5E4E2" />
<!-- Selected Text Color -->
</Trigger>
<!-- Explicitly setting background and text for unselected tab -->
<Trigger Property="IsSelected" Value="False">
<Setter Property="Background" Value="#16408D" />
<!-- Unselected Background -->
<Setter Property="BorderBrush" Value="#E5E4E2" />
<!-- Unselected Border -->
<Setter Property="Foreground" Value="#E5E4E2" />
<!-- Unselected Text Color -->
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 🔵 Base Style for Minimize and Maximize buttons -->
<Style x:Key="WindowButtonStyle" TargetType="Button">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{DynamicResource TextLightBrush}"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="FontSize" Value="16"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}" CornerRadius="6">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource HoverBrush}"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 🔴 Special Style for the Close button -->
<Style x:Key="CloseButtonStyle" TargetType="Button">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{DynamicResource TextLightBrush}"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="FontSize" Value="16"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}" CornerRadius="6">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<!-- Hover Effect - Light Red -->
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#D32F2F"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
<!-- Pressed Effect - Darker Red -->
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="{DynamicResource DangerBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource DangerTextBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="TextBox">
<Setter Property="Foreground" Value="{DynamicResource TextDarkBrush}" />
<Setter Property="Background" Value="{DynamicResource PaperDarkBrush}" />
</Style>
<Style TargetType="PasswordBox">
<Setter Property="Foreground" Value="{DynamicResource TextDarkBrush}" />
<Setter Property="Background" Value="{DynamicResource PaperDarkBrush}" />
</Style>
</Window.Resources>
<!-- Wrap everything in a Grid to ensure Window has only one child -->
<Border CornerRadius="12"
Background="{DynamicResource BackgroundDarkBrush}"
SnapsToDevicePixels="True"
ClipToBounds="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<!-- Titlebar -->
<RowDefinition Height="Auto" />
<!-- Tabs + Theme -->
<RowDefinition Height="*" />
<!-- Tab Content -->
</Grid.RowDefinitions>
<!-- 🔹 Titlebar -->
<Border Grid.Row="0"
CornerRadius="12,12,0,0"
Background="{DynamicResource BackgroundDarkBrush}"
Margin="0,0,2,2">
<Grid MouseDown="TitleBar_MouseDown">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="10,0,0,0">
<TextBlock Text="PSG - Oversight"
FontSize="22"
FontWeight="Bold"
Foreground="{DynamicResource TitleBrush}" />
<TextBlock x:Name="VersionTextBlock"
Text="v0.0.0"
FontSize="12"
VerticalAlignment="Bottom"
Margin="8,0,0,3"
Foreground="{DynamicResource TitleBrush}"
Opacity="0.7" />
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Width="30" Height="30" Click="MinimizeWindow_Click" Style="{StaticResource WindowButtonStyle}">
<materialDesign:PackIcon Kind="WindowMinimize" Width="20" Height="20" />
</Button>
<Button Width="30" Height="30" Click="MaximizeRestoreWindow_Click" Style="{StaticResource WindowButtonStyle}">
<materialDesign:PackIcon Kind="WindowMaximize" Width="20" Height="20" />
</Button>
<Button Width="30" Height="30" Click="CloseWindow_Click" Style="{StaticResource CloseButtonStyle}">
<materialDesign:PackIcon Kind="WindowClose" Width="20" Height="20" />
</Button>
</StackPanel>
</Grid>
</Border>
<!-- 🔹 Tabs + Theme Toggle -->
<Grid Grid.Row="1" Background="{DynamicResource BackgroundDarkBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<!-- MainTabControl with headers visible -->
<TabControl x:Name="MainTabControl"
Grid.Column="0"
Background="{DynamicResource BackgroundDarkBrush}"
BorderThickness="0"
TabStripPlacement="Top"
SelectedIndex="0"
IsTabStop="False"
Padding="0">
<TabItem Header="SysInfo" FontSize="16"/>
<TabItem Header="InstalledApps" FontSize="16"/>
<TabItem Header="Status" FontSize="16"/>
</TabControl>
<!--
<Button Grid.Column="1"
x:Name="ThemeToggleButton"
Style="{StaticResource SmallSquareButtonStyle}"
ToolTip="Toggle Theme"
Click="ThemeToggleButton_Click">
<materialDesign:PackIcon x:Name="ThemeIcon"
Kind="WeatherSunny"
Width="20" Height="20"
VerticalAlignment="Center"
HorizontalAlignment="Center" />
</Button>
-->
</Grid>
<Border Grid.Row="2"
CornerRadius="0,0,12,12"
Background="Transparent"
ClipToBounds="True">
<!-- 🔹 Tab Content -->
<TabControl x:Name="MainTabContentControl"
Background="Transparent"
BorderThickness="0"
SelectedIndex="{Binding SelectedIndex, ElementName=MainTabControl, Mode=TwoWay}"
Margin="0" Padding="0,0,0,0"
>
<!-- 👇 Hides the TabItem headers -->
<TabControl.Resources>
<Style TargetType="TabItem">
<Setter Property="Visibility" Value="Collapsed" />
</Style>
</TabControl.Resources>
<!-- 🔹 SysInfo Tab -->
<TabItem Header="SysInfo">
<StackPanel Margin="5,0,5,0" VerticalAlignment="Top">
<TextBlock x:Name="HostnameTextBlock" Text="Hostname" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" />
<TextBlock x:Name="OSNameTextBlock" Text="OS Name" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" />
<TextBlock x:Name="OSVersionTextBlock" Text="OS Version" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" />
<TextBlock x:Name="WindowsVersionTextBlock" Text="Windows Version" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" />
<TextBlock x:Name="WindowsBuildTextBlock" Text="Windows Build" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" />
<TextBlock x:Name="OSArchitectureTextBlock" Text="OS Architecture" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" />
<TextBlock x:Name="ProcessorNameTextBlock" Text="Processor Name" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" />
<TextBlock x:Name="ProcessorArchitectureTextBlock" Text="Processor Architecture" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" />
<Button Content="Export to CSV"
Style="{StaticResource CustomRaisedButton}"
Background="{DynamicResource PrimaryBrush}"
Foreground="{DynamicResource SelectedLightBrush}"
Click="ExportToCsvButton_Click"
Width="200"
Margin="5"
HorizontalAlignment="Left" />
<Button Content="Save System Info"
Style="{StaticResource CustomRaisedButton}"
Background="{DynamicResource PrimaryBrush}"
Foreground="{DynamicResource SelectedLightBrush}"
Click="StoreSystemInfoButton_Click"
Width="200"
Margin="5"
HorizontalAlignment="Left" />
<CheckBox
x:Name="IncludeInstalledAppsCheckBox"
Content="Include installed Apps?"
FontSize="14"
Margin="5"
Foreground="{DynamicResource TextDarkBrush}"
Style="{StaticResource MaterialDesignCheckBox}" />
<TextBlock x:Name="StatusTextBlock"
FontSize="14"
FontWeight="SemiBold"
Margin="10,5"
Foreground="{DynamicResource ErrorBrush}" />
</StackPanel>
</TabItem>
<!-- 🔹 InstalledApps Tab -->
<TabItem Header="InstalledApps">
<StackPanel Margin="10">
<ListBox x:Name="InstalledAppsListBox" Height="300" Width="350" Margin="5">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Name}" FontWeight="Bold" />
<TextBlock Text="{Binding Version}" FontStyle="Italic" />
<TextBlock Text="{Binding Publisher}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Content="Load Installed Applications"
Style="{StaticResource CustomRaisedButton}"
Background="{DynamicResource PrimaryBrush}"
Foreground="{DynamicResource SelectedLightBrush}"
Click="LoadInstalledAppsButton_Click"
Width="200"
Margin="5"
HorizontalAlignment="Left" />
</StackPanel>
</TabItem>
<!-- 🔹 Status Tab -->
<TabItem Header="Status">
<StackPanel Margin="10">
<TextBlock Text="Server Connectivity Status:"
FontSize="14"
FontWeight="SemiBold"
Margin="5"
Foreground="{DynamicResource TextDarkBrush}" />
<TextBlock x:Name="ConnectionStatusTextBlock"
Text="Connected to Server (Ping)"
Foreground="{DynamicResource StatusConnectedBrush}"
FontSize="14"
FontWeight="Bold" />
<StackPanel Orientation="Vertical" Margin="0,10,0,0">
<TextBox x:Name="txtUsername"
Width="200"
Margin="5"
HorizontalAlignment="Left"
/>
<PasswordBox x:Name="pwdPassword"
Width="200"
Margin="5"
HorizontalAlignment="Left" />
</StackPanel>
<Button x:Name="AuthenticateButton"
Content="Login"
Style="{StaticResource CustomRaisedButton}"
Background="{DynamicResource PrimaryBrush}"
Foreground="{DynamicResource SelectedLightBrush}"
Click="AuthenticateButton_Click"
Width="200"
Margin="5"
HorizontalAlignment="Left"
/>
<Separator Margin="10" />
<TextBlock Text="Diagnostic Logs:"
FontSize="14"
FontWeight="SemiBold"
Margin="5"
Foreground="{DynamicResource TextDarkBrush}" />
<Button Content="Generate Logs"
Style="{StaticResource CustomRaisedButton}"
Background="{DynamicResource PrimaryBrush}"
Foreground="{DynamicResource SelectedLightBrush}"
Click="GenerateLogsButton_Click"
Width="200"
Margin="5"
HorizontalAlignment="Left" />
</StackPanel>
</TabItem>
</TabControl>
</Border>
<!-- ✅ Tray Icon (not inside Grid) -->
<tb:TaskbarIcon x:Name="TrayIcon"
ToolTipText="LD SysInfo Running"
ContextMenu="{StaticResource TrayMenu}"
IconSource="/Assets/trayicon.ico" />
</Grid>
</Border>
</Window>