Initial WIP commit
Some checks failed
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Failing after 9s
Some checks failed
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Failing after 9s
This commit is contained in:
20
StatusWindow/SettingsWindow/AboutSettingsPanel.xaml
Normal file
20
StatusWindow/SettingsWindow/AboutSettingsPanel.xaml
Normal file
@@ -0,0 +1,20 @@
|
||||
<windows:CategoryPanelBase x:Class="HardwareMonitorStatusWindow.StatusWindow.SettingsWindow.AboutSettingsPanel"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:windows="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.CategoryWindow"
|
||||
xmlns:window="clr-namespace:HardwareMonitorStatusWindow.StatusWindow"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="150"
|
||||
d:DesignWidth="300">
|
||||
<Grid>
|
||||
<StackPanel windows:Spacing.Vertical="10">
|
||||
<TextBlock Text="{x:Static window:Resources.ApplicationName}"
|
||||
FontWeight="Bold" />
|
||||
<TextBlock Text="{Binding Source={x:Static window:UpdateCheck.LocalVersion}, StringFormat={x:Static window:Resources.Version}}"
|
||||
Name="VersionLabel" />
|
||||
<TextBlock Text="Chris Kaczor" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</windows:CategoryPanelBase>
|
||||
12
StatusWindow/SettingsWindow/AboutSettingsPanel.xaml.cs
Normal file
12
StatusWindow/SettingsWindow/AboutSettingsPanel.xaml.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace HardwareMonitorStatusWindow.StatusWindow.SettingsWindow
|
||||
{
|
||||
public partial class AboutSettingsPanel
|
||||
{
|
||||
public AboutSettingsPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public override string CategoryName => StatusWindow.Resources.optionCategoryAbout;
|
||||
}
|
||||
}
|
||||
16
StatusWindow/SettingsWindow/GeneralSettingsPanel.xaml
Normal file
16
StatusWindow/SettingsWindow/GeneralSettingsPanel.xaml
Normal file
@@ -0,0 +1,16 @@
|
||||
<windows:CategoryPanelBase x:Class="HardwareMonitorStatusWindow.StatusWindow.SettingsWindow.GeneralSettingsPanel"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:windows="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.CategoryWindow"
|
||||
xmlns:properties="clr-namespace:HardwareMonitorStatusWindow.StatusWindow"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="300">
|
||||
<StackPanel windows:Spacing.Vertical="10">
|
||||
<CheckBox Content="{x:Static properties:Resources.startWithWindowsCheckBox}"
|
||||
IsChecked="{Binding Source={x:Static properties:Settings.Default}, Path=AutoStart}"
|
||||
Click="OnSaveSettings" />
|
||||
</StackPanel>
|
||||
</windows:CategoryPanelBase>
|
||||
35
StatusWindow/SettingsWindow/GeneralSettingsPanel.xaml.cs
Normal file
35
StatusWindow/SettingsWindow/GeneralSettingsPanel.xaml.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Windows;
|
||||
using ChrisKaczor.Wpf.Application;
|
||||
|
||||
namespace HardwareMonitorStatusWindow.StatusWindow.SettingsWindow;
|
||||
|
||||
public partial class GeneralSettingsPanel
|
||||
{
|
||||
public GeneralSettingsPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public override string CategoryName => StatusWindow.Resources.optionCategoryGeneral;
|
||||
|
||||
public override void LoadPanel(Window parentWindow)
|
||||
{
|
||||
base.LoadPanel(parentWindow);
|
||||
|
||||
MarkLoaded();
|
||||
}
|
||||
|
||||
private void OnSaveSettings(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
private void SaveSettings()
|
||||
{
|
||||
if (!HasLoaded) return;
|
||||
|
||||
Settings.Default.Save();
|
||||
|
||||
Application.Current.SetStartWithWindows(Settings.Default.AutoStart);
|
||||
}
|
||||
}
|
||||
126
StatusWindow/SettingsWindow/HardwareSettingsPanel.xaml
Normal file
126
StatusWindow/SettingsWindow/HardwareSettingsPanel.xaml
Normal file
@@ -0,0 +1,126 @@
|
||||
<windows:CategoryPanelBase
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:hardwareMonitorStatusWindow="clr-namespace:HardwareMonitorStatusWindow.StatusWindow"
|
||||
xmlns:windows="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.CategoryWindow"
|
||||
xmlns:controls="clr-namespace:ChrisKaczor.Wpf.Controls;assembly=ChrisKaczor.Wpf.Controls.Link"
|
||||
xmlns:dd="urn:gong-wpf-dragdrop"
|
||||
x:Class="HardwareMonitorStatusWindow.StatusWindow.SettingsWindow.HardwareSettingsPanel"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="300">
|
||||
<windows:CategoryPanelBase.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
|
||||
<ResourceDictionary
|
||||
Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.FlatButton.xaml" />
|
||||
<ResourceDictionary
|
||||
Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/light.cobalt.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</windows:CategoryPanelBase.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<DataGrid Name="SensorDataGrid"
|
||||
SelectionMode="Extended"
|
||||
Grid.Column="0"
|
||||
Grid.Row="0"
|
||||
AutoGenerateColumns="False"
|
||||
GridLinesVisibility="None"
|
||||
CanUserResizeRows="False"
|
||||
IsReadOnly="True"
|
||||
CanUserSortColumns="False"
|
||||
SelectionUnit="FullRow"
|
||||
HeadersVisibility="Column"
|
||||
BorderThickness="1,1,1,1"
|
||||
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"
|
||||
Background="{x:Null}"
|
||||
SelectionChanged="HandleSensorDataGridSelectionChanged"
|
||||
d:DataContext="{d:DesignInstance hardwareMonitorStatusWindow:SensorEntry }"
|
||||
dd:DragDrop.IsDragSource="True"
|
||||
dd:DragDrop.IsDropTarget="True">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Binding="{Binding Path=Label}"
|
||||
Header="{x:Static hardwareMonitorStatusWindow:Resources.LabelColumnHeader}"
|
||||
Width="*" />
|
||||
<DataGridTemplateColumn Header="{x:Static hardwareMonitorStatusWindow:Resources.HardwareColumnHeader}"
|
||||
Width="*">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Path=Hardware.Type}"
|
||||
Height="Auto"
|
||||
FontSize="10"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,2,0,2" />
|
||||
<TextBlock Text="{Binding Path=Hardware.Name}"
|
||||
Height="Auto"
|
||||
VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="{x:Static hardwareMonitorStatusWindow:Resources.SensorColumnHeader}"
|
||||
Width="*">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Path=Sensor.Type}"
|
||||
Height="Auto"
|
||||
FontSize="10"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,2,0,2" />
|
||||
<TextBlock Text="{Binding Path=Sensor.Name}"
|
||||
Height="Auto"
|
||||
VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
<DataGrid.RowStyle>
|
||||
<Style TargetType="DataGridRow"
|
||||
BasedOn="{StaticResource MahApps.Styles.DataGridRow}">
|
||||
<EventSetter Event="MouseDoubleClick"
|
||||
Handler="HandleSensorDataGridRowMouseDoubleClick" />
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
</DataGrid>
|
||||
<Border Grid.Column="0"
|
||||
Grid.Row="1"
|
||||
BorderThickness="1,0,1,1"
|
||||
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}">
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
|
||||
<controls:Link Name="AddSensorButton"
|
||||
Margin="2"
|
||||
Click="HandleAddSensorButtonClick"
|
||||
Text="{x:Static hardwareMonitorStatusWindow:Resources.AddSensorLink}"
|
||||
ToolTip="{x:Static hardwareMonitorStatusWindow:Resources.AddSensorToolTip}">
|
||||
</controls:Link>
|
||||
<controls:Link Name="EditSensorButton"
|
||||
Margin="2"
|
||||
Click="HandleEditSensorButtonClick"
|
||||
Text="{x:Static hardwareMonitorStatusWindow:Resources.EditSensorLink}"
|
||||
ToolTip="{x:Static hardwareMonitorStatusWindow:Resources.EditSensorToolTip}">
|
||||
</controls:Link>
|
||||
<controls:Link Name="DeleteSensorButton"
|
||||
Margin="2"
|
||||
Click="HandleDeleteSensorButtonClick"
|
||||
Text="{x:Static hardwareMonitorStatusWindow:Resources.DeleteSensorLink}"
|
||||
ToolTip="{x:Static hardwareMonitorStatusWindow:Resources.DeleteSensorToolTip}">
|
||||
</controls:Link>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</windows:CategoryPanelBase>
|
||||
112
StatusWindow/SettingsWindow/HardwareSettingsPanel.xaml.cs
Normal file
112
StatusWindow/SettingsWindow/HardwareSettingsPanel.xaml.cs
Normal file
@@ -0,0 +1,112 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace HardwareMonitorStatusWindow.StatusWindow.SettingsWindow;
|
||||
|
||||
public partial class HardwareSettingsPanel
|
||||
{
|
||||
private CollectionViewSource _collectionViewSource;
|
||||
|
||||
public HardwareSettingsPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public override string CategoryName => StatusWindow.Resources.optionCategorySensors;
|
||||
|
||||
public override void LoadPanel(Window parentWindow)
|
||||
{
|
||||
base.LoadPanel(parentWindow);
|
||||
|
||||
if (_collectionViewSource == null)
|
||||
{
|
||||
_collectionViewSource = new CollectionViewSource { Source = Data.SensorEntries };
|
||||
|
||||
SensorDataGrid.ItemsSource = _collectionViewSource.View;
|
||||
}
|
||||
|
||||
_collectionViewSource.View.Refresh();
|
||||
|
||||
if (SensorDataGrid.Items.Count > 0)
|
||||
SensorDataGrid.SelectedIndex = 0;
|
||||
|
||||
SetSensorButtonStates();
|
||||
}
|
||||
|
||||
private void HandleSensorDataGridSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
SetSensorButtonStates();
|
||||
}
|
||||
|
||||
private void SetSensorButtonStates()
|
||||
{
|
||||
AddSensorButton.IsEnabled = true;
|
||||
EditSensorButton.IsEnabled = SensorDataGrid.SelectedItems.Count == 1;
|
||||
DeleteSensorButton.IsEnabled = SensorDataGrid.SelectedItems.Count > 0;
|
||||
}
|
||||
|
||||
private void HandleAddSensorButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AddSensor();
|
||||
}
|
||||
|
||||
private void HandleEditSensorButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
EditSelectedSensor();
|
||||
}
|
||||
|
||||
private void HandleDeleteSensorButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DeleteSelectedSensors();
|
||||
}
|
||||
|
||||
private void HandleSensorDataGridRowMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
EditSelectedSensor();
|
||||
}
|
||||
|
||||
private void AddSensor()
|
||||
{
|
||||
var sensorEntry = new SensorEntry();
|
||||
|
||||
var sensorWindow = new SensorWindow();
|
||||
|
||||
var result = sensorWindow.Display(sensorEntry, Window.GetWindow(this));
|
||||
|
||||
if (!result.HasValue || !result.Value)
|
||||
return;
|
||||
|
||||
SensorDataGrid.SelectedItem = sensorEntry;
|
||||
|
||||
SetSensorButtonStates();
|
||||
}
|
||||
|
||||
private void EditSelectedSensor()
|
||||
{
|
||||
if (SensorDataGrid.SelectedItem == null)
|
||||
return;
|
||||
|
||||
var sensorEntry = (SensorEntry)SensorDataGrid.SelectedItem;
|
||||
|
||||
var sensorWindow = new SensorWindow();
|
||||
|
||||
sensorWindow.Display(sensorEntry, Window.GetWindow(this));
|
||||
}
|
||||
|
||||
private void DeleteSelectedSensors()
|
||||
{
|
||||
if (MessageBox.Show(ParentWindow!, StatusWindow.Resources.ConfirmDeleteSensors, StatusWindow.Resources.ConfirmDeleteTitle, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
|
||||
return;
|
||||
|
||||
var selectedItems = new SensorEntry[SensorDataGrid.SelectedItems.Count];
|
||||
|
||||
SensorDataGrid.SelectedItems.CopyTo(selectedItems, 0);
|
||||
|
||||
foreach (var sensorEntry in selectedItems)
|
||||
Data.SensorEntries.Remove(sensorEntry);
|
||||
|
||||
SetSensorButtonStates();
|
||||
}
|
||||
}
|
||||
10
StatusWindow/SettingsWindow/HardwareTypeItem.cs
Normal file
10
StatusWindow/SettingsWindow/HardwareTypeItem.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
using HardwareMonitorStatusWindow.Service;
|
||||
|
||||
namespace HardwareMonitorStatusWindow.StatusWindow.SettingsWindow;
|
||||
|
||||
public class HardwareTypeItem(HardwareType hardwareType)
|
||||
{
|
||||
public HardwareType Value { get; set; } = hardwareType;
|
||||
public string Name { get; set; } = hardwareType.ToString();
|
||||
}
|
||||
9
StatusWindow/SettingsWindow/SensorTypeItem.cs
Normal file
9
StatusWindow/SettingsWindow/SensorTypeItem.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using HardwareMonitorStatusWindow.Service;
|
||||
|
||||
namespace HardwareMonitorStatusWindow.StatusWindow.SettingsWindow;
|
||||
|
||||
public class SensorTypeItem(SensorType sensorType)
|
||||
{
|
||||
public SensorType Value { get; set; } = sensorType;
|
||||
public string Name { get; set; } = sensorType.ToString();
|
||||
}
|
||||
106
StatusWindow/SettingsWindow/SensorWindow.xaml
Normal file
106
StatusWindow/SettingsWindow/SensorWindow.xaml
Normal file
@@ -0,0 +1,106 @@
|
||||
<Window x:Class="HardwareMonitorStatusWindow.StatusWindow.SettingsWindow.SensorWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hardwareMonitorStatusWindow="clr-namespace:HardwareMonitorStatusWindow.StatusWindow"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
d:DataContext="{d:DesignInstance Type=hardwareMonitorStatusWindow:SensorEntry}"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
xmlns:windows="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.CategoryWindow"
|
||||
mc:Ignorable="d"
|
||||
Title="SensorWindow"
|
||||
ResizeMode="NoResize"
|
||||
SizeToContent="Height"
|
||||
Width="450"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
FocusManager.FocusedElement="{Binding ElementName=LabelTextBox}">
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
|
||||
<ResourceDictionary
|
||||
Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.FlatButton.xaml" />
|
||||
<ResourceDictionary
|
||||
Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/light.cobalt.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
<Grid Margin="6">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Margin="0,4"
|
||||
windows:Spacing.Vertical="8">
|
||||
<TextBox Name="LabelTextBox"
|
||||
mah:TextBoxHelper.UseFloatingWatermark="True"
|
||||
mah:TextBoxHelper.Watermark="{x:Static hardwareMonitorStatusWindow:Resources.LabelColumnHeader}"
|
||||
mah:TextBoxHelper.SelectAllOnFocus="True"
|
||||
Text="{Binding Path=Label, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=True}" />
|
||||
<ComboBox Name="HardwareTypeComboBox"
|
||||
SelectedValuePath="Value"
|
||||
DisplayMemberPath="Name"
|
||||
VirtualizingPanel.IsVirtualizing="False"
|
||||
mah:TextBoxHelper.UseFloatingWatermark="True"
|
||||
mah:TextBoxHelper.Watermark="{x:Static hardwareMonitorStatusWindow:Resources.HardwareTypeWatermark}"
|
||||
SelectionChanged="HardwareTypeComboBox_SelectionChanged">
|
||||
</ComboBox>
|
||||
<ComboBox Name="HardwareComboBox"
|
||||
DisplayMemberPath="Name"
|
||||
VirtualizingPanel.IsVirtualizing="False"
|
||||
mah:TextBoxHelper.UseFloatingWatermark="True"
|
||||
mah:TextBoxHelper.Watermark="{x:Static hardwareMonitorStatusWindow:Resources.HardwareWatermark}"
|
||||
SelectionChanged="HardwareComboBox_SelectionChanged">
|
||||
</ComboBox>
|
||||
<ComboBox Name="SensorTypeComboBox"
|
||||
SelectedValuePath="Value"
|
||||
DisplayMemberPath="Name"
|
||||
VirtualizingPanel.IsVirtualizing="False"
|
||||
mah:TextBoxHelper.UseFloatingWatermark="True"
|
||||
mah:TextBoxHelper.Watermark="{x:Static hardwareMonitorStatusWindow:Resources.SensorTypeWatermark}"
|
||||
SelectionChanged="SensorTypeComboBox_SelectionChanged">
|
||||
</ComboBox>
|
||||
<ComboBox Name="SensorComboBox"
|
||||
DisplayMemberPath="Name"
|
||||
VirtualizingPanel.IsVirtualizing="False"
|
||||
mah:TextBoxHelper.UseFloatingWatermark="True"
|
||||
mah:TextBoxHelper.Watermark="{x:Static hardwareMonitorStatusWindow:Resources.SensorWatermark}">
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="0"
|
||||
Grid.Row="1"
|
||||
Orientation="Horizontal"
|
||||
Margin="0,5,0,0"
|
||||
HorizontalAlignment="Right">
|
||||
<Button Content="{x:Static hardwareMonitorStatusWindow:Resources.OkayButton}"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Width="75"
|
||||
Margin="0,0,5,0"
|
||||
IsDefault="True"
|
||||
Click="HandleOkayButtonClick">
|
||||
<Button.Style>
|
||||
<Style TargetType="Button"
|
||||
BasedOn="{StaticResource {x:Type Button}}">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Text.Length, ElementName=LabelTextBox}"
|
||||
Value="0">
|
||||
<Setter Property="IsEnabled"
|
||||
Value="False" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
<Button Content="{x:Static hardwareMonitorStatusWindow:Resources.CancelButton}"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Width="75"
|
||||
IsCancel="True" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
98
StatusWindow/SettingsWindow/SensorWindow.xaml.cs
Normal file
98
StatusWindow/SettingsWindow/SensorWindow.xaml.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using ChrisKaczor.Wpf.Validation;
|
||||
using HardwareMonitorStatusWindow.Service;
|
||||
|
||||
namespace HardwareMonitorStatusWindow.StatusWindow.SettingsWindow;
|
||||
|
||||
public partial class SensorWindow
|
||||
{
|
||||
public SensorWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public bool? Display(SensorEntry sensorEntry, Window owner)
|
||||
{
|
||||
DataContext = sensorEntry;
|
||||
|
||||
Data.RefreshComputer();
|
||||
|
||||
HardwareTypeComboBox.ItemsSource = Data.ComputerHardware.Where(h => h.Sensors.Any()).DistinctBy(h => h.Type).Select(s => new HardwareTypeItem(s.Type)).OrderBy(s => s.Name);
|
||||
|
||||
var hardware = Data.ComputerHardware.FirstOrDefault(h => h.Identifier.ToString() == sensorEntry.HardwareId);
|
||||
var sensor = hardware?.Sensors.FirstOrDefault(s => s.Identifier.ToString() == sensorEntry.SensorId);
|
||||
|
||||
HardwareTypeComboBox.SelectedValue = hardware?.Type;
|
||||
HardwareComboBox.SelectedItem = hardware;
|
||||
SensorTypeComboBox.SelectedValue = sensor?.Type;
|
||||
SensorComboBox.SelectedItem = sensor;
|
||||
|
||||
Title = string.IsNullOrWhiteSpace(sensorEntry.Label) ? StatusWindow.Resources.SensorWindowAdd : StatusWindow.Resources.SensorWindowEdit;
|
||||
|
||||
Owner = owner;
|
||||
|
||||
return ShowDialog();
|
||||
}
|
||||
|
||||
private void HandleOkayButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!this.IsValid())
|
||||
return;
|
||||
|
||||
var sensorEntry = (SensorEntry)DataContext;
|
||||
|
||||
var hardware = (Hardware)HardwareComboBox.SelectedItem;
|
||||
sensorEntry.HardwareId = hardware.Identifier;
|
||||
|
||||
var sensor = (Sensor)SensorComboBox.SelectedItem;
|
||||
sensorEntry.SensorId = sensor.Identifier;
|
||||
|
||||
if (!Data.SensorEntries.Contains(sensorEntry))
|
||||
Data.SensorEntries.Add(sensorEntry);
|
||||
|
||||
Data.Save();
|
||||
|
||||
DialogResult = true;
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
private void HardwareTypeComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||
{
|
||||
if (HardwareTypeComboBox.SelectedIndex == -1)
|
||||
return;
|
||||
|
||||
var hardwareType = (HardwareTypeItem)HardwareTypeComboBox.SelectedItem;
|
||||
|
||||
HardwareComboBox.SelectedIndex = -1;
|
||||
SensorTypeComboBox.SelectedIndex = -1;
|
||||
SensorComboBox.SelectedIndex = -1;
|
||||
|
||||
HardwareComboBox.ItemsSource = Data.ComputerHardware.Where(h => h.Type == hardwareType.Value);
|
||||
}
|
||||
|
||||
private void HardwareComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||
{
|
||||
if (HardwareComboBox.SelectedIndex == -1)
|
||||
return;
|
||||
|
||||
var hardware = (Hardware)HardwareComboBox.SelectedItem;
|
||||
|
||||
SensorTypeComboBox.SelectedIndex = -1;
|
||||
SensorComboBox.SelectedIndex = -1;
|
||||
|
||||
SensorTypeComboBox.ItemsSource = hardware.Sensors.DistinctBy(s => s.Type).Select(s => new SensorTypeItem(s.Type)).OrderBy(s => s.Name);
|
||||
}
|
||||
|
||||
private void SensorTypeComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||
{
|
||||
if (SensorTypeComboBox.SelectedIndex == -1)
|
||||
return;
|
||||
|
||||
var hardware = (Hardware)HardwareComboBox.SelectedItem;
|
||||
var sensorType = (SensorTypeItem)SensorTypeComboBox.SelectedItem;
|
||||
|
||||
SensorComboBox.ItemsSource = hardware.Sensors.Where(s => s.Type == sensorType.Value);
|
||||
}
|
||||
}
|
||||
21
StatusWindow/SettingsWindow/UpdateSettingsPanel.xaml
Normal file
21
StatusWindow/SettingsWindow/UpdateSettingsPanel.xaml
Normal file
@@ -0,0 +1,21 @@
|
||||
<windows:CategoryPanelBase x:Class="HardwareMonitorStatusWindow.StatusWindow.SettingsWindow.UpdateSettingsPanel"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:windows="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.CategoryWindow"
|
||||
xmlns:window="clr-namespace:HardwareMonitorStatusWindow.StatusWindow"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="150"
|
||||
d:DesignWidth="250">
|
||||
<StackPanel windows:Spacing.Vertical="10">
|
||||
<CheckBox Content="{x:Static window:Resources.checkVersionOnStartupCheckBox}"
|
||||
Name="CheckVersionOnStartupCheckBox"
|
||||
IsChecked="{Binding Source={x:Static window:Settings.Default}, Path=CheckVersionAtStartup}"
|
||||
Click="OnSaveSettings" />
|
||||
<Button Content="{x:Static window:Resources.checkVersionNowButton}"
|
||||
IsEnabled="{Binding Source={x:Static window:UpdateCheck.IsInstalled}}"
|
||||
HorizontalAlignment="Left"
|
||||
Click="HandleCheckVersionNowButtonClick" />
|
||||
</StackPanel>
|
||||
</windows:CategoryPanelBase>
|
||||
38
StatusWindow/SettingsWindow/UpdateSettingsPanel.xaml.cs
Normal file
38
StatusWindow/SettingsWindow/UpdateSettingsPanel.xaml.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using HardwareMonitorStatusWindow.StatusWindow;
|
||||
|
||||
namespace HardwareMonitorStatusWindow.StatusWindow.SettingsWindow;
|
||||
|
||||
public partial class UpdateSettingsPanel
|
||||
{
|
||||
public UpdateSettingsPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public override string CategoryName => StatusWindow.Resources.optionCategoryUpdate;
|
||||
|
||||
private async void HandleCheckVersionNowButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var cursor = Cursor;
|
||||
|
||||
Cursor = Cursors.Wait;
|
||||
|
||||
await UpdateCheck.DisplayUpdateInformation(true);
|
||||
|
||||
Cursor = cursor;
|
||||
}
|
||||
|
||||
private void OnSaveSettings(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
private void SaveSettings()
|
||||
{
|
||||
if (!HasLoaded) return;
|
||||
|
||||
Settings.Default.Save();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user