Add settings window

This commit is contained in:
2018-02-22 17:21:03 -05:00
parent 33e56dc548
commit 15a1ae0e36
11 changed files with 318 additions and 67 deletions

View File

@@ -0,0 +1,24 @@
<windows:CategoryPanel x:Class="ProcessCpuUsageStatusWindow.Options.AboutOptionsPanel"
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:windows="clr-namespace:Common.Wpf.Windows;assembly=Common.Wpf"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="300">
<Grid>
<TextBlock Text="[Application Name]"
Name="ApplicationNameLabel"
VerticalAlignment="Top"
FontWeight="Bold" />
<TextBlock Text="[Application Version]"
Margin="0,22,0,0"
Name="VersionLabel"
VerticalAlignment="Top" />
<TextBlock Text="[Company]"
Margin="0,44,0,0"
Name="CompanyLabel"
VerticalAlignment="Top" />
</Grid>
</windows:CategoryPanel>

View File

@@ -0,0 +1,36 @@
using Common.Update;
using System.Reflection;
namespace ProcessCpuUsageStatusWindow.Options
{
public partial class AboutOptionsPanel
{
public AboutOptionsPanel()
{
InitializeComponent();
}
public override void LoadPanel(object data)
{
base.LoadPanel(data);
ApplicationNameLabel.Text = Properties.Resources.ApplicationName;
var version = UpdateCheck.LocalVersion.ToString();
VersionLabel.Text = string.Format(Properties.Resources.About_Version, version);
CompanyLabel.Text = ((AssemblyCompanyAttribute)Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0]).Company;
}
public override bool ValidatePanel()
{
return true;
}
public override void SavePanel()
{
}
public override string CategoryName => Properties.Resources.OptionCategory_About;
}
}

View File

@@ -0,0 +1,40 @@
<windows:CategoryPanel x:Class="ProcessCpuUsageStatusWindow.Options.GeneralOptionsPanel"
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:windows="clr-namespace:Common.Wpf.Windows;assembly=Common.Wpf"
xmlns:properties="clr-namespace:ProcessCpuUsageStatusWindow.Properties"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<CheckBox Content="{x:Static properties:Resources.StartWithWindows}"
Name="StartWithWindows"
VerticalAlignment="Top"
VerticalContentAlignment="Center"
Grid.ColumnSpan="2" />
<Label Grid.Column="0"
Grid.Row="1"
Content="{x:Static properties:Resources.NumberOfProcesses}"
Margin="0,6,6,6"
Padding="0"
VerticalContentAlignment="Center" VerticalAlignment="Center" />
<xctk:IntegerUpDown Grid.Column="1"
Grid.Row="1" x:Name="NumberOfProcesses"
Minimum="1" Maximum="20"
TextAlignment="Left" Margin="6"
Width="50"
HorizontalAlignment="Left" />
</Grid>
</windows:CategoryPanel>

View File

@@ -0,0 +1,42 @@
using Common.Wpf.Extensions;
using System.Windows;
namespace ProcessCpuUsageStatusWindow.Options
{
public partial class GeneralOptionsPanel
{
public GeneralOptionsPanel()
{
InitializeComponent();
}
public override void LoadPanel(object data)
{
base.LoadPanel(data);
var settings = Properties.Settings.Default;
StartWithWindows.IsChecked = settings.AutoStart;
NumberOfProcesses.Text = settings.ProcessCount.ToString();
}
public override bool ValidatePanel()
{
return true;
}
public override void SavePanel()
{
var settings = Properties.Settings.Default;
if (StartWithWindows.IsChecked.HasValue && settings.AutoStart != StartWithWindows.IsChecked.Value)
settings.AutoStart = StartWithWindows.IsChecked.Value;
settings.ProcessCount = int.Parse(NumberOfProcesses.Text);
Application.Current.SetStartWithWindows(settings.AutoStart);
}
public override string CategoryName => Properties.Resources.OptionCategory_General;
}
}