Files
psg-oversight-app/LD-SysInfo/MainWindow.xaml

620 lines
29 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"
SizeToContent="Height"
Width="420"
MinHeight="400"
MinWidth="350"
MaxHeight="800"
Icon="Assets/trayicon.ico"
WindowStyle="None"
AllowsTransparency="True"
ResizeMode="CanResizeWithGrip"
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>
<!-- 🔵 Small Rounded Button Style for Service Tab -->
<Style x:Key="SmallRoundedButtonStyle" TargetType="Button">
<Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource TextLightBrush}"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Padding" Value="12,8"/>
<Setter Property="Margin" Value="4"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
CornerRadius="8"
Padding="{TemplateBinding Padding}">
<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="#2E5FA8"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="#808080"/>
<Setter Property="Foreground" Value="#C0C0C0"/>
</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"/>
<TabItem Header="Osquery" FontSize="16"/>
<TabItem Header="Service" 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">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<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}" />
<!-- New fields -->
<TextBlock x:Name="MemoryTextBlock" Text="Total Memory" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" />
<TextBlock x:Name="GpuTextBlock" Text="GPU(s)" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" TextWrapping="Wrap" />
<TextBlock x:Name="IpTextBlock" Text="IP Addresses" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" TextWrapping="Wrap" />
<TextBlock x:Name="CollectedAtTextBlock" Text="Last updated: N/A" FontSize="12" Margin="8,10,5,5" Foreground="{DynamicResource TextDarkBrush}" FontStyle="Italic" />
<StackPanel Orientation="Horizontal" Margin="5,8,5,5" HorizontalAlignment="Left">
<Button Content="Refresh now"
Style="{StaticResource CustomRaisedButton}"
Background="{DynamicResource PrimaryBrush}"
Foreground="{DynamicResource SelectedLightBrush}"
Click="RefreshButton_Click"
Width="120"
Margin="0,0,8,0" />
<Button Content="Export to CSV"
Style="{StaticResource CustomRaisedButton}"
Background="{DynamicResource PrimaryBrush}"
Foreground="{DynamicResource SelectedLightBrush}"
Click="ExportToCsvButton_Click"
Width="120"
Margin="0,0,8,0" />
<Button Content="Save System Info"
Style="{StaticResource CustomRaisedButton}"
Background="{DynamicResource PrimaryBrush}"
Foreground="{DynamicResource SelectedLightBrush}"
Click="StoreSystemInfoButton_Click"
Width="120" />
</StackPanel>
<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>
</ScrollViewer>
</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>
<!-- 🔹 Osquery Console Tab -->
<TabItem Header="Osquery">
<Grid Background="{DynamicResource BackgroundDarkBrush}" Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="Enter Osquery SQL:" FontWeight="Bold" Margin="0,0,0,4" Foreground="{DynamicResource TextLightBrush}"/>
<TextBox x:Name="OsqueryQueryBox"
Grid.Row="1"
Height="60"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto"
Background="#252526"
Foreground="White"
FontFamily="Consolas"
FontSize="14"
AcceptsReturn="True"
Text="SELECT * FROM system_info;" />
<Button Grid.Row="1"
Content="Run Query"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Width="120"
Margin="0,4,0,0"
Click="RunOsqueryQuery_Click"/>
<TextBox x:Name="OsqueryOutputBox"
Grid.Row="2"
Margin="0,10,0,0"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto"
Background="#1e1e1e"
Foreground="#dcdcdc"
FontFamily="Consolas"
FontSize="13"
AcceptsReturn="True"
IsReadOnly="True"
Text="Results will appear here..." />
</Grid>
</TabItem>
<!-- 🔹 Service Tab -->
<TabItem Header="Service">
<Grid Background="{DynamicResource BackgroundDarkBrush}" Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Service Status Section -->
<Border Grid.Row="0" Background="{DynamicResource CardBackgroundBrush}"
CornerRadius="8" Padding="15" Margin="0,0,0,15">
<StackPanel>
<TextBlock Text="PSG-Oversight Service Status"
FontSize="16" FontWeight="Bold"
Foreground="{DynamicResource TextDarkBrush}"
Margin="0,0,0,10"/>
<StackPanel Orientation="Horizontal" Margin="0,5">
<TextBlock Text="Status:" FontWeight="Bold" Width="100"
Foreground="{DynamicResource TextDarkBrush}"/>
<TextBlock x:Name="ServiceStatusText" Text="Unknown"
Foreground="{DynamicResource AccentBrush}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,5">
<TextBlock Text="Last Check:" FontWeight="Bold" Width="100"
Foreground="{DynamicResource TextDarkBrush}"/>
<TextBlock x:Name="ServiceLastCheckText" Text="Never"
Foreground="{DynamicResource TextDarkBrush}"/>
</StackPanel>
<WrapPanel Margin="0,10,0,0">
<Button Content="Refresh Status" Click="RefreshServiceStatus_Click"
Style="{StaticResource SmallRoundedButtonStyle}"
Width="150" HorizontalAlignment="Left"/>
<Button Content="Install Service" Click="InstallService_Click"
Style="{StaticResource SmallRoundedButtonStyle}"
Width="150" HorizontalAlignment="Left"/>
<Button Content="Uninstall Service" Click="UninstallService_Click"
Style="{StaticResource SmallRoundedButtonStyle}"
Width="150" HorizontalAlignment="Left"/>
<Button Content="Start Service" Click="StartService_Click"
Style="{StaticResource SmallRoundedButtonStyle}"
Width="150" HorizontalAlignment="Left"/>
<Button Content="Stop Service" Click="StopService_Click"
Style="{StaticResource SmallRoundedButtonStyle}"
Width="150" HorizontalAlignment="Left"/>
</WrapPanel>
</StackPanel>
</Border>
<!-- Test Operations Section -->
<Border Grid.Row="1" Background="{DynamicResource CardBackgroundBrush}"
CornerRadius="8" Padding="15" Margin="0,0,0,15">
<StackPanel>
<TextBlock Text="Test Operations"
FontSize="16" FontWeight="Bold"
Foreground="{DynamicResource TextDarkBrush}"
Margin="0,0,0,10"/>
<TextBlock Text="Click buttons below to test service operations:"
TextWrapping="Wrap"
Foreground="{DynamicResource TextDarkBrush}"
Margin="0,0,0,10"/>
<Button Content="🔍 Run Patch Compliance Check Now"
Click="TestPatchCompliance_Click"
Style="{StaticResource SmallRoundedButtonStyle}"
Margin="0,5" Width="280" HorizontalAlignment="Left"/>
<Button Content="📊 View Task Scheduler State"
Click="ViewSchedulerState_Click"
Style="{StaticResource SmallRoundedButtonStyle}"
Margin="0,5" Width="280" HorizontalAlignment="Left"/>
<Button Content="🔄 Test API Connection"
Click="TestAPIConnection_Click"
Style="{StaticResource SmallRoundedButtonStyle}"
Margin="0,5" Width="280" HorizontalAlignment="Left"/>
</StackPanel>
</Border>
<!-- Log Output Section -->
<Border Grid.Row="2" Background="{DynamicResource CardBackgroundBrush}"
CornerRadius="8" Padding="15">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Service Logs"
FontSize="14" FontWeight="Bold"
Foreground="{DynamicResource TextDarkBrush}"
Margin="0,0,0,10"/>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<TextBox x:Name="ServiceLogOutput"
Background="#1e1e1e"
Foreground="#dcdcdc"
FontFamily="Consolas"
FontSize="12"
AcceptsReturn="True"
IsReadOnly="True"
TextWrapping="Wrap"
MinHeight="200"
Text="Service logs will appear here..."/>
</ScrollViewer>
</Grid>
</Border>
</Grid>
</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>