mirror of
https://github.com/ckaczor/WorkIndicator.git
synced 2026-01-13 17:23:18 -05:00
Switch to submodules, support multiple patterns, add options dialog, add license and initial readme
This commit is contained in:
24
Options/AboutOptionsPanel.xaml
Normal file
24
Options/AboutOptionsPanel.xaml
Normal file
@@ -0,0 +1,24 @@
|
||||
<windows:CategoryPanel x:Class="WorkIndicator.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>
|
||||
36
Options/AboutOptionsPanel.xaml.cs
Normal file
36
Options/AboutOptionsPanel.xaml.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Common.Update;
|
||||
using System.Reflection;
|
||||
|
||||
namespace WorkIndicator.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;
|
||||
}
|
||||
}
|
||||
22
Options/GeneralOptionsPanel.xaml
Normal file
22
Options/GeneralOptionsPanel.xaml
Normal file
@@ -0,0 +1,22 @@
|
||||
<windows:CategoryPanel x:Class="WorkIndicator.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:WorkIndicator.Properties"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="300">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<CheckBox Content="{x:Static properties:Resources.StartWithWindows}"
|
||||
Name="StartWithWindows"
|
||||
VerticalAlignment="Top"
|
||||
VerticalContentAlignment="Center"
|
||||
Grid.ColumnSpan="2" />
|
||||
</Grid>
|
||||
</windows:CategoryPanel>
|
||||
39
Options/GeneralOptionsPanel.xaml.cs
Normal file
39
Options/GeneralOptionsPanel.xaml.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Common.Wpf.Extensions;
|
||||
using System.Windows;
|
||||
|
||||
namespace WorkIndicator.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.StartWithWindows;
|
||||
}
|
||||
|
||||
public override bool ValidatePanel()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void SavePanel()
|
||||
{
|
||||
var settings = Properties.Settings.Default;
|
||||
|
||||
if (StartWithWindows.IsChecked.HasValue && settings.StartWithWindows != StartWithWindows.IsChecked.Value)
|
||||
settings.StartWithWindows = StartWithWindows.IsChecked.Value;
|
||||
|
||||
Application.Current.SetStartWithWindows(settings.StartWithWindows);
|
||||
}
|
||||
|
||||
public override string CategoryName => Properties.Resources.OptionCategory_General;
|
||||
}
|
||||
}
|
||||
87
Options/WindowPatternWindow.xaml
Normal file
87
Options/WindowPatternWindow.xaml
Normal file
@@ -0,0 +1,87 @@
|
||||
<Window x:Class="WorkIndicator.Options.WindowPatternWindow"
|
||||
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:properties="clr-namespace:WorkIndicator.Properties"
|
||||
mc:Ignorable="d"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Title="WindowPatternWindow"
|
||||
Height="160"
|
||||
Width="350"
|
||||
FocusManager.FocusedElement="{Binding ElementName=NameTextBox}">
|
||||
<Grid>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="{x:Static properties:Resources.WindowPatternNameLabel}"
|
||||
VerticalContentAlignment="Center"
|
||||
Target="{Binding ElementName=NameTextBox}"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Margin="6"
|
||||
Padding="0" />
|
||||
<TextBox Name="NameTextBox"
|
||||
Grid.Column="1"
|
||||
Text="{Binding Path=Name, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=true}"
|
||||
Grid.Row="0"
|
||||
VerticalAlignment="Center"
|
||||
Margin="6,0,6,0" />
|
||||
|
||||
<Label Content="{x:Static properties:Resources.WindowPatternPatternLabel}"
|
||||
VerticalContentAlignment="Center"
|
||||
Target="{Binding ElementName=PatternTextBox}"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Margin="6"
|
||||
Padding="0" />
|
||||
<TextBox Name="PatternTextBox"
|
||||
Grid.Column="1"
|
||||
Text="{Binding Path=Pattern, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=true}"
|
||||
Grid.Row="1"
|
||||
VerticalAlignment="Center"
|
||||
Margin="6,0,6,0" />
|
||||
|
||||
|
||||
<Label Content="{x:Static properties:Resources.WindowPatternEnabledLabel}"
|
||||
VerticalContentAlignment="Center"
|
||||
Target="{Binding ElementName=NameTextBox}"
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Margin="6"
|
||||
Padding="0" />
|
||||
<CheckBox Grid.Column="1"
|
||||
IsChecked="{Binding Path=Enabled, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=true}"
|
||||
Grid.Row="2"
|
||||
Margin="5,0,5,0"
|
||||
VerticalAlignment="Center" />
|
||||
<StackPanel Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Grid.Row="3"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="6">
|
||||
<Button Content="{x:Static properties:Resources.OkayButton}"
|
||||
Height="23"
|
||||
VerticalAlignment="Bottom"
|
||||
Width="75"
|
||||
IsDefault="True"
|
||||
Click="HandleOkayButtonClick"
|
||||
Margin="0,0,8,0" />
|
||||
<Button Content="{x:Static properties:Resources.CancelButton}"
|
||||
Height="23"
|
||||
VerticalAlignment="Bottom"
|
||||
Width="75"
|
||||
IsCancel="True" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
66
Options/WindowPatternWindow.xaml.cs
Normal file
66
Options/WindowPatternWindow.xaml.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using Common.Wpf.Extensions;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace WorkIndicator.Options
|
||||
{
|
||||
public partial class WindowPatternWindow
|
||||
{
|
||||
public WindowPatternWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Icon = ((Icon)Properties.Resources.ResourceManager.GetObject("ApplicationIcon")).ToImageSource();
|
||||
}
|
||||
|
||||
public bool? Display(WindowPattern windowPattern, Window owner)
|
||||
{
|
||||
// Set the data context
|
||||
DataContext = windowPattern;
|
||||
|
||||
// Set the title based on the state of the item
|
||||
Title = string.IsNullOrWhiteSpace(windowPattern.Name) ? Properties.Resources.WindowPatternWindowAdd : Properties.Resources.WindowPatternWindowEdit;
|
||||
|
||||
// Set the window owner
|
||||
Owner = owner;
|
||||
|
||||
// Show the dialog and result the result
|
||||
return ShowDialog();
|
||||
}
|
||||
|
||||
private void HandleOkayButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Get a list of all framework elements and explicit binding expressions
|
||||
var bindingExpressions = this.GetBindingExpressions(new[] { UpdateSourceTrigger.Explicit });
|
||||
|
||||
// Loop over each binding expression and clear any existing error
|
||||
this.ClearAllValidationErrors(bindingExpressions);
|
||||
|
||||
// Force all explicit bindings to update the source
|
||||
this.UpdateAllSources(bindingExpressions);
|
||||
|
||||
// See if there are any errors
|
||||
var hasError = bindingExpressions.Any(b => b.BindingExpression.HasError);
|
||||
|
||||
// If there was an error then set focus to the bad controls
|
||||
if (hasError)
|
||||
{
|
||||
// Get the first framework element with an error
|
||||
var firstErrorElement = bindingExpressions.First(b => b.BindingExpression.HasError).FrameworkElement;
|
||||
|
||||
// Set focus
|
||||
firstErrorElement.Focus();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Dialog is good
|
||||
DialogResult = true;
|
||||
|
||||
// Close the dialog
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
79
Options/WindowPatternsOptionsPanel.xaml
Normal file
79
Options/WindowPatternsOptionsPanel.xaml
Normal file
@@ -0,0 +1,79 @@
|
||||
<windows:CategoryPanel x:Class="WorkIndicator.Options.WindowPatternsOptionsPanel"
|
||||
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:linkControl="clr-namespace:Common.Wpf.LinkControl;assembly=Common.Wpf"
|
||||
xmlns:properties="clr-namespace:WorkIndicator.Properties"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="300">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<DataGrid x:Name="WindowPatternsGrid"
|
||||
SelectionMode="Extended"
|
||||
Grid.Column="0"
|
||||
Grid.Row="0"
|
||||
AutoGenerateColumns="False"
|
||||
GridLinesVisibility="None"
|
||||
CanUserResizeRows="False"
|
||||
IsReadOnly="True"
|
||||
HeadersVisibility="Column"
|
||||
SelectionUnit="FullRow"
|
||||
SelectionChanged="HandleWindowPatternsSelectionChanged"
|
||||
Background="{x:Null}"
|
||||
MouseDoubleClick="HandleWindowPatternsDoubleClick">
|
||||
<DataGrid.Columns>
|
||||
<DataGridCheckBoxColumn Binding="{Binding Enabled}"
|
||||
Header="{x:Static properties:Resources.ColumnHeader_Enabled}" />
|
||||
<DataGridTextColumn Binding="{Binding Name}"
|
||||
Header="{x:Static properties:Resources.ColumnHeader_Name}"
|
||||
SortDirection="Ascending"
|
||||
Width="*" />
|
||||
<DataGridTextColumn Binding="{Binding Pattern}"
|
||||
Header="{x:Static properties:Resources.ColumnHeader_Pattern}"
|
||||
Width="2*" />
|
||||
</DataGrid.Columns>
|
||||
<DataGrid.CellStyle>
|
||||
<Style TargetType="DataGridCell">
|
||||
<Setter Property="BorderThickness"
|
||||
Value="0"></Setter>
|
||||
<Setter Property="FocusVisualStyle"
|
||||
Value="{x:Null}" />
|
||||
</Style>
|
||||
</DataGrid.CellStyle>
|
||||
</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}}">
|
||||
<linkControl:LinkControl Margin="2"
|
||||
Click="HandleAddWindowPatternButtonClick"
|
||||
Text="{x:Static properties:Resources.AddWindowPattern}"
|
||||
ToolTip="{x:Static properties:Resources.AddWindowPattern_ToolTip}">
|
||||
</linkControl:LinkControl>
|
||||
<linkControl:LinkControl Name="EditWindowPatternButton"
|
||||
Margin="2"
|
||||
Click="HandleEditWindowPatternButtonClick"
|
||||
Text="{x:Static properties:Resources.EditWindowPattern}"
|
||||
ToolTip="{x:Static properties:Resources.EditWindowPattern_ToolTip}">
|
||||
</linkControl:LinkControl>
|
||||
<linkControl:LinkControl Name="DeleteWindowPatternButton"
|
||||
Margin="2"
|
||||
Click="HandleDeleteWindowPatternButtonClick"
|
||||
Text="{x:Static properties:Resources.DeleteWindowPattern}"
|
||||
ToolTip="{x:Static properties:Resources.DeleteWindowPattern_ToolTip}">
|
||||
</linkControl:LinkControl>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</windows:CategoryPanel>
|
||||
114
Options/WindowPatternsOptionsPanel.xaml.cs
Normal file
114
Options/WindowPatternsOptionsPanel.xaml.cs
Normal file
@@ -0,0 +1,114 @@
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace WorkIndicator.Options
|
||||
{
|
||||
public partial class WindowPatternsOptionsPanel
|
||||
{
|
||||
public WindowPatternsOptionsPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private WindowPatterns WindowPatterns => Data as WindowPatterns;
|
||||
|
||||
public override void LoadPanel(object data)
|
||||
{
|
||||
base.LoadPanel(data);
|
||||
|
||||
WindowPatternsGrid.ItemsSource = WindowPatterns;
|
||||
|
||||
WindowPatternsGrid.SelectedItem = WindowPatterns.FirstOrDefault();
|
||||
SetButtonStates();
|
||||
}
|
||||
|
||||
public override bool ValidatePanel()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void SavePanel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override string CategoryName => Properties.Resources.OptionCategory_WindowPatterns;
|
||||
|
||||
private void SetButtonStates()
|
||||
{
|
||||
EditWindowPatternButton.IsEnabled = (WindowPatternsGrid.SelectedItems.Count == 1);
|
||||
DeleteWindowPatternButton.IsEnabled = (WindowPatternsGrid.SelectedItems.Count > 0);
|
||||
}
|
||||
|
||||
private void AddWindowPattern()
|
||||
{
|
||||
var windowPattern = new WindowPattern();
|
||||
|
||||
var windowPatternWindow = new WindowPatternWindow();
|
||||
|
||||
var result = windowPatternWindow.Display(windowPattern, Window.GetWindow(this));
|
||||
|
||||
if (result.HasValue && result.Value)
|
||||
{
|
||||
WindowPatterns.Add(windowPattern);
|
||||
|
||||
WindowPatternsGrid.SelectedItem = windowPattern;
|
||||
|
||||
SetButtonStates();
|
||||
}
|
||||
}
|
||||
|
||||
private void EditSelectedWindowPattern()
|
||||
{
|
||||
if (WindowPatternsGrid.SelectedItem == null)
|
||||
return;
|
||||
|
||||
var windowPattern = WindowPatternsGrid.SelectedItem as WindowPattern;
|
||||
|
||||
var windowPatternWindow = new WindowPatternWindow();
|
||||
|
||||
windowPatternWindow.Display(windowPattern, Window.GetWindow(this));
|
||||
}
|
||||
|
||||
private void DeleteSelectedWindowPattern()
|
||||
{
|
||||
var windowPattern = WindowPatternsGrid.SelectedItem as WindowPattern;
|
||||
var index = WindowPatternsGrid.SelectedIndex;
|
||||
|
||||
WindowPatterns.Remove(windowPattern);
|
||||
|
||||
if (WindowPatternsGrid.Items.Count == index)
|
||||
WindowPatternsGrid.SelectedIndex = WindowPatternsGrid.Items.Count - 1;
|
||||
else if (WindowPatternsGrid.Items.Count >= index)
|
||||
WindowPatternsGrid.SelectedIndex = index;
|
||||
|
||||
SetButtonStates();
|
||||
}
|
||||
|
||||
private void HandleAddWindowPatternButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AddWindowPattern();
|
||||
}
|
||||
|
||||
private void HandleEditWindowPatternButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
EditSelectedWindowPattern();
|
||||
}
|
||||
|
||||
private void HandleDeleteWindowPatternButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DeleteSelectedWindowPattern();
|
||||
}
|
||||
|
||||
private void HandleWindowPatternsSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
SetButtonStates();
|
||||
}
|
||||
|
||||
private void HandleWindowPatternsDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
EditSelectedWindowPattern();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user