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:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -153,3 +153,5 @@ $RECYCLE.BIN/
|
|||||||
|
|
||||||
# Mac desktop service store files
|
# Mac desktop service store files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
.vs/
|
||||||
6
.gitmodules
vendored
Normal file
6
.gitmodules
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[submodule "Common"]
|
||||||
|
path = Common
|
||||||
|
url = https://github.com/ckaczor/Common.git
|
||||||
|
[submodule "Common.Wpf"]
|
||||||
|
path = Common.Wpf
|
||||||
|
url = https://github.com/ckaczor/Common.Wpf.git
|
||||||
3
App.xaml
3
App.xaml
@@ -1,6 +1,7 @@
|
|||||||
<Application x:Class="WorkIndicator.App"
|
<Application x:Class="WorkIndicator.App"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
ShutdownMode="OnExplicitShutdown">
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
|
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
|
|||||||
1
Common
Submodule
1
Common
Submodule
Submodule Common added at 81ef8f451c
1
Common.Wpf
Submodule
1
Common.Wpf
Submodule
Submodule Common.Wpf added at 8a82786166
21
LICENSE.md
Normal file
21
LICENSE.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2018 Chris Kaczor
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
using System;
|
using Common.Native;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Common.Native;
|
|
||||||
using WorkIndicator.Delcom;
|
using WorkIndicator.Delcom;
|
||||||
|
|
||||||
namespace WorkIndicator
|
namespace WorkIndicator
|
||||||
@@ -17,27 +18,47 @@ namespace WorkIndicator
|
|||||||
|
|
||||||
public static class LightController
|
public static class LightController
|
||||||
{
|
{
|
||||||
|
private static WindowPatterns _windowPatterns;
|
||||||
private static StoplightIndicator _stoplightIndicator;
|
private static StoplightIndicator _stoplightIndicator;
|
||||||
private static bool _initialized;
|
private static bool _initialized;
|
||||||
private static Status _status = Status.Auto;
|
private static Status _status = Status.Auto;
|
||||||
|
|
||||||
public static void Initialize()
|
public static void Initialize()
|
||||||
{
|
{
|
||||||
|
WindowPatterns.Changed += HandleWindowPatternsChanged;
|
||||||
|
|
||||||
_stoplightIndicator = new StoplightIndicator();
|
_stoplightIndicator = new StoplightIndicator();
|
||||||
_stoplightIndicator.SetLight(StoplightIndicator.Light.Green, StoplightIndicator.LightState.On);
|
_stoplightIndicator.SetLight(StoplightIndicator.Light.Green, StoplightIndicator.LightState.On);
|
||||||
|
|
||||||
InitializeWindowDetection();
|
LoadPatterns();
|
||||||
|
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void LoadPatterns()
|
||||||
|
{
|
||||||
|
_windowPatterns = WindowPatterns.Load();
|
||||||
|
|
||||||
|
if (_initialized)
|
||||||
|
TerminateWindowDetection();
|
||||||
|
|
||||||
|
InitializeWindowDetection();
|
||||||
|
|
||||||
|
UpdateLights();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void HandleWindowPatternsChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadPatterns();
|
||||||
|
}
|
||||||
|
|
||||||
public static void Dispose()
|
public static void Dispose()
|
||||||
{
|
{
|
||||||
if (!_initialized)
|
if (!_initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TerminateWindowDetection();
|
TerminateWindowDetection();
|
||||||
|
|
||||||
_stoplightIndicator.SetLights(StoplightIndicator.LightState.Off, StoplightIndicator.LightState.Off, StoplightIndicator.LightState.Off);
|
_stoplightIndicator.SetLights(StoplightIndicator.LightState.Off, StoplightIndicator.LightState.Off, StoplightIndicator.LightState.Off);
|
||||||
_stoplightIndicator.Dispose();
|
_stoplightIndicator.Dispose();
|
||||||
|
|
||||||
@@ -46,7 +67,7 @@ namespace WorkIndicator
|
|||||||
|
|
||||||
public static Status Status
|
public static Status Status
|
||||||
{
|
{
|
||||||
get { return _status; }
|
get => _status;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_status = value;
|
_status = value;
|
||||||
@@ -102,10 +123,18 @@ namespace WorkIndicator
|
|||||||
private static readonly List<IntPtr> WindowEventHooks = new List<IntPtr>();
|
private static readonly List<IntPtr> WindowEventHooks = new List<IntPtr>();
|
||||||
private static readonly List<IntPtr> WindowHandles = new List<IntPtr>();
|
private static readonly List<IntPtr> WindowHandles = new List<IntPtr>();
|
||||||
|
|
||||||
private static readonly Regex WindowMatchRegex = new Regex(Properties.Settings.Default.WindowPattern);
|
private static readonly List<Regex> WindowMatchRegexList = new List<Regex>();
|
||||||
|
|
||||||
|
private static string WildcardToRegexPattern(string value)
|
||||||
|
{
|
||||||
|
return "^" + Regex.Escape(value).Replace("\\?", ".").Replace("\\*", ".*") + "$";
|
||||||
|
}
|
||||||
|
|
||||||
private static void InitializeWindowDetection()
|
private static void InitializeWindowDetection()
|
||||||
{
|
{
|
||||||
|
foreach (var windowPattern in _windowPatterns.Where(w => w.Enabled))
|
||||||
|
WindowMatchRegexList.Add(new Regex(WildcardToRegexPattern(windowPattern.Pattern)));
|
||||||
|
|
||||||
Functions.User32.EnumWindows(EnumWindowProc, IntPtr.Zero);
|
Functions.User32.EnumWindows(EnumWindowProc, IntPtr.Zero);
|
||||||
|
|
||||||
IntPtr hook = WinEvent.SetWinEventHook(WinEvent.Event.ObjectCreate, WinEvent.Event.ObjectDestroy, IntPtr.Zero, ProcDelegate, 0, 0, WinEvent.SetWinEventHookFlags.OutOfContext | WinEvent.SetWinEventHookFlags.SkipOwnProcess);
|
IntPtr hook = WinEvent.SetWinEventHook(WinEvent.Event.ObjectCreate, WinEvent.Event.ObjectDestroy, IntPtr.Zero, ProcDelegate, 0, 0, WinEvent.SetWinEventHookFlags.OutOfContext | WinEvent.SetWinEventHookFlags.SkipOwnProcess);
|
||||||
@@ -120,6 +149,10 @@ namespace WorkIndicator
|
|||||||
private static void TerminateWindowDetection()
|
private static void TerminateWindowDetection()
|
||||||
{
|
{
|
||||||
WindowEventHooks.ForEach(h => WinEvent.UnhookWinEvent(h));
|
WindowEventHooks.ForEach(h => WinEvent.UnhookWinEvent(h));
|
||||||
|
|
||||||
|
WindowMatchRegexList.Clear();
|
||||||
|
|
||||||
|
WindowHandles.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool EnumWindowProc(IntPtr hWnd, IntPtr lParam)
|
private static bool EnumWindowProc(IntPtr hWnd, IntPtr lParam)
|
||||||
@@ -140,10 +173,13 @@ namespace WorkIndicator
|
|||||||
if (WindowHandles.Contains(hwnd))
|
if (WindowHandles.Contains(hwnd))
|
||||||
WindowHandles.Remove(hwnd);
|
WindowHandles.Remove(hwnd);
|
||||||
|
|
||||||
if (WindowMatchRegex.IsMatch(Functions.Window.GetText(hwnd)))
|
foreach (var regex in WindowMatchRegexList)
|
||||||
{
|
{
|
||||||
WindowHandles.Add(hwnd);
|
if (regex.IsMatch(Functions.Window.GetText(hwnd)))
|
||||||
UpdateLights();
|
{
|
||||||
|
WindowHandles.Add(hwnd);
|
||||||
|
UpdateLights();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
267
Properties/Resources.Designer.cs
generated
267
Properties/Resources.Designer.cs
generated
@@ -1,7 +1,7 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// This code was generated by a tool.
|
||||||
// Runtime Version:4.0.30319.34209
|
// Runtime Version:4.0.30319.42000
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
// the code is regenerated.
|
// the code is regenerated.
|
||||||
@@ -19,10 +19,10 @@ namespace WorkIndicator.Properties {
|
|||||||
// class via a tool like ResGen or Visual Studio.
|
// class via a tool like ResGen or Visual Studio.
|
||||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
// with the /str option, or rebuild your VS project.
|
// with the /str option, or rebuild your VS project.
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
internal class Resources {
|
public class Resources {
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ namespace WorkIndicator.Properties {
|
|||||||
/// Returns the cached ResourceManager instance used by this class.
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
public static global::System.Resources.ResourceManager ResourceManager {
|
||||||
get {
|
get {
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WorkIndicator.Properties.Resources", typeof(Resources).Assembly);
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WorkIndicator.Properties.Resources", typeof(Resources).Assembly);
|
||||||
@@ -51,7 +51,7 @@ namespace WorkIndicator.Properties {
|
|||||||
/// resource lookups using this strongly typed resource class.
|
/// resource lookups using this strongly typed resource class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
public static global::System.Globalization.CultureInfo Culture {
|
||||||
get {
|
get {
|
||||||
return resourceCulture;
|
return resourceCulture;
|
||||||
}
|
}
|
||||||
@@ -60,10 +60,47 @@ namespace WorkIndicator.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Version: {0}.
|
||||||
|
/// </summary>
|
||||||
|
public static string About_Version {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("About_Version", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Add.
|
||||||
|
/// </summary>
|
||||||
|
public static string AddWindowPattern {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("AddWindowPattern", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Add Window Pattern.
|
||||||
|
/// </summary>
|
||||||
|
public static string AddWindowPattern_ToolTip {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("AddWindowPattern_ToolTip", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||||
|
/// </summary>
|
||||||
|
public static System.Drawing.Icon ApplicationIcon {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("ApplicationIcon", resourceCulture);
|
||||||
|
return ((System.Drawing.Icon)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Work Indicator.
|
/// Looks up a localized string similar to Work Indicator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ApplicationName {
|
public static string ApplicationName {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("ApplicationName", resourceCulture);
|
return ResourceManager.GetString("ApplicationName", resourceCulture);
|
||||||
}
|
}
|
||||||
@@ -72,44 +109,188 @@ namespace WorkIndicator.Properties {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Auto.
|
/// Looks up a localized string similar to Auto.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string Auto {
|
public static string Auto {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("Auto", resourceCulture);
|
return ResourceManager.GetString("Auto", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Cancel.
|
||||||
|
/// </summary>
|
||||||
|
public static string CancelButton {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("CancelButton", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Enabled.
|
||||||
|
/// </summary>
|
||||||
|
public static string ColumnHeader_Enabled {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ColumnHeader_Enabled", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Name.
|
||||||
|
/// </summary>
|
||||||
|
public static string ColumnHeader_Name {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ColumnHeader_Name", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Pattern.
|
||||||
|
/// </summary>
|
||||||
|
public static string ColumnHeader_Pattern {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ColumnHeader_Pattern", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Delete.
|
||||||
|
/// </summary>
|
||||||
|
public static string DeleteWindowPattern {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("DeleteWindowPattern", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Delete Window Pattern.
|
||||||
|
/// </summary>
|
||||||
|
public static string DeleteWindowPattern_ToolTip {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("DeleteWindowPattern_ToolTip", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Edit.
|
||||||
|
/// </summary>
|
||||||
|
public static string EditWindowPattern {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("EditWindowPattern", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Edit Window Pattern.
|
||||||
|
/// </summary>
|
||||||
|
public static string EditWindowPattern_ToolTip {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("EditWindowPattern_ToolTip", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Free.
|
/// Looks up a localized string similar to Free.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string Free {
|
public static string Free {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("Free", resourceCulture);
|
return ResourceManager.GetString("Free", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
/// Looks up a localized string similar to OK.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static System.Drawing.Icon MainIcon {
|
public static string OkayButton {
|
||||||
get {
|
get {
|
||||||
object obj = ResourceManager.GetObject("MainIcon", resourceCulture);
|
return ResourceManager.GetString("OkayButton", resourceCulture);
|
||||||
return ((System.Drawing.Icon)(obj));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to On Phone.
|
/// Looks up a localized string similar to On Phone.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string OnPhone {
|
public static string OnPhone {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("OnPhone", resourceCulture);
|
return ResourceManager.GetString("OnPhone", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to About.
|
||||||
|
/// </summary>
|
||||||
|
public static string OptionCategory_About {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("OptionCategory_About", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to General.
|
||||||
|
/// </summary>
|
||||||
|
public static string OptionCategory_General {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("OptionCategory_General", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Window Patterns.
|
||||||
|
/// </summary>
|
||||||
|
public static string OptionCategory_WindowPatterns {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("OptionCategory_WindowPatterns", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Cancel.
|
||||||
|
/// </summary>
|
||||||
|
public static string OptionsWindow_CancelButton {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("OptionsWindow_CancelButton", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||||
|
/// </summary>
|
||||||
|
public static System.Drawing.Icon OptionsWindow_Icon {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("OptionsWindow_Icon", resourceCulture);
|
||||||
|
return ((System.Drawing.Icon)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to OK.
|
||||||
|
/// </summary>
|
||||||
|
public static string OptionsWindow_OkayButton {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("OptionsWindow_OkayButton", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Options.
|
||||||
|
/// </summary>
|
||||||
|
public static string OptionsWindow_Title {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("OptionsWindow_Title", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to _Start when Windows starts.
|
||||||
|
/// </summary>
|
||||||
|
public static string StartWithWindows {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("StartWithWindows", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Talking.
|
/// Looks up a localized string similar to Talking.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string Talking {
|
public static string Talking {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("Talking", resourceCulture);
|
return ResourceManager.GetString("Talking", resourceCulture);
|
||||||
}
|
}
|
||||||
@@ -118,16 +299,70 @@ namespace WorkIndicator.Properties {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Exit.
|
/// Looks up a localized string similar to Exit.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string TrayIconContextMenuExit {
|
public static string TrayIconContextMenuExit {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("TrayIconContextMenuExit", resourceCulture);
|
return ResourceManager.GetString("TrayIconContextMenuExit", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Options....
|
||||||
|
/// </summary>
|
||||||
|
public static string TrayIconContextMenuSettings {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("TrayIconContextMenuSettings", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to _Enabled:.
|
||||||
|
/// </summary>
|
||||||
|
public static string WindowPatternEnabledLabel {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("WindowPatternEnabledLabel", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to _Name:.
|
||||||
|
/// </summary>
|
||||||
|
public static string WindowPatternNameLabel {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("WindowPatternNameLabel", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to _Pattern:.
|
||||||
|
/// </summary>
|
||||||
|
public static string WindowPatternPatternLabel {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("WindowPatternPatternLabel", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Add Window Pattern.
|
||||||
|
/// </summary>
|
||||||
|
public static string WindowPatternWindowAdd {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("WindowPatternWindowAdd", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Edit Window Pattern.
|
||||||
|
/// </summary>
|
||||||
|
public static string WindowPatternWindowEdit {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("WindowPatternWindowEdit", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Working.
|
/// Looks up a localized string similar to Working.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string Working {
|
public static string Working {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("Working", resourceCulture);
|
return ResourceManager.GetString("Working", resourceCulture);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,28 +117,106 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<data name="About_Version" xml:space="preserve">
|
||||||
|
<value>Version: {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="AddWindowPattern" xml:space="preserve">
|
||||||
|
<value>Add</value>
|
||||||
|
</data>
|
||||||
|
<data name="AddWindowPattern_ToolTip" xml:space="preserve">
|
||||||
|
<value>Add Window Pattern</value>
|
||||||
|
</data>
|
||||||
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
|
<data name="ApplicationIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\ApplicationIcon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
<data name="ApplicationName" xml:space="preserve">
|
<data name="ApplicationName" xml:space="preserve">
|
||||||
<value>Work Indicator</value>
|
<value>Work Indicator</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Auto" xml:space="preserve">
|
<data name="Auto" xml:space="preserve">
|
||||||
<value>Auto</value>
|
<value>Auto</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="CancelButton" xml:space="preserve">
|
||||||
|
<value>Cancel</value>
|
||||||
|
</data>
|
||||||
|
<data name="ColumnHeader_Enabled" xml:space="preserve">
|
||||||
|
<value>Enabled</value>
|
||||||
|
</data>
|
||||||
|
<data name="ColumnHeader_Name" xml:space="preserve">
|
||||||
|
<value>Name</value>
|
||||||
|
</data>
|
||||||
|
<data name="ColumnHeader_Pattern" xml:space="preserve">
|
||||||
|
<value>Pattern</value>
|
||||||
|
</data>
|
||||||
|
<data name="DeleteWindowPattern" xml:space="preserve">
|
||||||
|
<value>Delete</value>
|
||||||
|
</data>
|
||||||
|
<data name="DeleteWindowPattern_ToolTip" xml:space="preserve">
|
||||||
|
<value>Delete Window Pattern</value>
|
||||||
|
</data>
|
||||||
|
<data name="EditWindowPattern" xml:space="preserve">
|
||||||
|
<value>Edit</value>
|
||||||
|
</data>
|
||||||
|
<data name="EditWindowPattern_ToolTip" xml:space="preserve">
|
||||||
|
<value>Edit Window Pattern</value>
|
||||||
|
</data>
|
||||||
<data name="Free" xml:space="preserve">
|
<data name="Free" xml:space="preserve">
|
||||||
<value>Free</value>
|
<value>Free</value>
|
||||||
</data>
|
</data>
|
||||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
<data name="OkayButton" xml:space="preserve">
|
||||||
<data name="MainIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<value>OK</value>
|
||||||
<value>..\Resources\MainIcon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
</data>
|
||||||
<data name="OnPhone" xml:space="preserve">
|
<data name="OnPhone" xml:space="preserve">
|
||||||
<value>On Phone</value>
|
<value>On Phone</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="OptionCategory_About" xml:space="preserve">
|
||||||
|
<value>About</value>
|
||||||
|
</data>
|
||||||
|
<data name="OptionCategory_General" xml:space="preserve">
|
||||||
|
<value>General</value>
|
||||||
|
</data>
|
||||||
|
<data name="OptionCategory_WindowPatterns" xml:space="preserve">
|
||||||
|
<value>Window Patterns</value>
|
||||||
|
</data>
|
||||||
|
<data name="OptionsWindow_CancelButton" xml:space="preserve">
|
||||||
|
<value>Cancel</value>
|
||||||
|
</data>
|
||||||
|
<data name="OptionsWindow_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\ApplicationIcon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="OptionsWindow_OkayButton" xml:space="preserve">
|
||||||
|
<value>OK</value>
|
||||||
|
</data>
|
||||||
|
<data name="OptionsWindow_Title" xml:space="preserve">
|
||||||
|
<value>Options</value>
|
||||||
|
</data>
|
||||||
|
<data name="StartWithWindows" xml:space="preserve">
|
||||||
|
<value>_Start when Windows starts</value>
|
||||||
|
</data>
|
||||||
<data name="Talking" xml:space="preserve">
|
<data name="Talking" xml:space="preserve">
|
||||||
<value>Talking</value>
|
<value>Talking</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TrayIconContextMenuExit" xml:space="preserve">
|
<data name="TrayIconContextMenuExit" xml:space="preserve">
|
||||||
<value>Exit</value>
|
<value>Exit</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="TrayIconContextMenuSettings" xml:space="preserve">
|
||||||
|
<value>Options...</value>
|
||||||
|
</data>
|
||||||
|
<data name="WindowPatternEnabledLabel" xml:space="preserve">
|
||||||
|
<value>_Enabled:</value>
|
||||||
|
</data>
|
||||||
|
<data name="WindowPatternNameLabel" xml:space="preserve">
|
||||||
|
<value>_Name:</value>
|
||||||
|
</data>
|
||||||
|
<data name="WindowPatternPatternLabel" xml:space="preserve">
|
||||||
|
<value>_Pattern:</value>
|
||||||
|
</data>
|
||||||
|
<data name="WindowPatternWindowAdd" xml:space="preserve">
|
||||||
|
<value>Add Window Pattern</value>
|
||||||
|
</data>
|
||||||
|
<data name="WindowPatternWindowEdit" xml:space="preserve">
|
||||||
|
<value>Edit Window Pattern</value>
|
||||||
|
</data>
|
||||||
<data name="Working" xml:space="preserve">
|
<data name="Working" xml:space="preserve">
|
||||||
<value>Working</value>
|
<value>Working</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
28
Properties/Settings.Designer.cs
generated
28
Properties/Settings.Designer.cs
generated
@@ -1,7 +1,7 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// This code was generated by a tool.
|
||||||
// Runtime Version:4.0.30319.0
|
// Runtime Version:4.0.30319.42000
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
// the code is regenerated.
|
// the code is regenerated.
|
||||||
@@ -12,7 +12,7 @@ namespace WorkIndicator.Properties {
|
|||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.5.0.0")]
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
@@ -35,18 +35,6 @@ namespace WorkIndicator.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute(".* - CKACZOR - Remote Desktop Connection")]
|
|
||||||
public string WindowPattern {
|
|
||||||
get {
|
|
||||||
return ((string)(this["WindowPattern"]));
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
this["WindowPattern"] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("00:00:10")]
|
[global::System.Configuration.DefaultSettingValueAttribute("00:00:10")]
|
||||||
@@ -64,5 +52,17 @@ namespace WorkIndicator.Properties {
|
|||||||
return ((global::System.TimeSpan)(this["UpdateInterval"]));
|
return ((global::System.TimeSpan)(this["UpdateInterval"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||||
|
public string WindowPatterns {
|
||||||
|
get {
|
||||||
|
return ((string)(this["WindowPatterns"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["WindowPatterns"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,14 +5,14 @@
|
|||||||
<Setting Name="StartWithWindows" Type="System.Boolean" Scope="User">
|
<Setting Name="StartWithWindows" Type="System.Boolean" Scope="User">
|
||||||
<Value Profile="(Default)">True</Value>
|
<Value Profile="(Default)">True</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="WindowPattern" Type="System.String" Scope="User">
|
|
||||||
<Value Profile="(Default)">.* - CKACZOR - Remote Desktop Connection</Value>
|
|
||||||
</Setting>
|
|
||||||
<Setting Name="RetryInterval" Type="System.TimeSpan" Scope="Application">
|
<Setting Name="RetryInterval" Type="System.TimeSpan" Scope="Application">
|
||||||
<Value Profile="(Default)">00:00:10</Value>
|
<Value Profile="(Default)">00:00:10</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="UpdateInterval" Type="System.TimeSpan" Scope="Application">
|
<Setting Name="UpdateInterval" Type="System.TimeSpan" Scope="Application">
|
||||||
<Value Profile="(Default)">00:00:00.5000000</Value>
|
<Value Profile="(Default)">00:00:00.5000000</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<Setting Name="WindowPatterns" Type="System.String" Scope="User">
|
||||||
|
<Value Profile="(Default)" />
|
||||||
|
</Setting>
|
||||||
</Settings>
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
||||||
11
README.md
Normal file
11
README.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# WorkIndicator
|
||||||
|
|
||||||
|
Controls a [Delcom Green/Yellow/Red Indicator](https://www.delcomproducts.com/productdetails.asp?PartNumber=907241) to show work status (free, working, on phone, talking) either manually or by automatically detecting a window title.
|
||||||
|
|
||||||
|
## Authors
|
||||||
|
|
||||||
|
* **Chris Kaczor** - *Initial work* - https://github.com/ckaczor - https://chriskaczor.com
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.
|
||||||
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
52
TrayIcon.cs
52
TrayIcon.cs
@@ -1,4 +1,7 @@
|
|||||||
using System.Windows.Forms;
|
using Common.Wpf.Windows;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using WorkIndicator.Options;
|
||||||
using WorkIndicator.Properties;
|
using WorkIndicator.Properties;
|
||||||
|
|
||||||
using Application = System.Windows.Application;
|
using Application = System.Windows.Application;
|
||||||
@@ -11,10 +14,12 @@ namespace WorkIndicator
|
|||||||
|
|
||||||
private static bool _initialized;
|
private static bool _initialized;
|
||||||
|
|
||||||
|
private static CategoryWindow _optionsWindow;
|
||||||
|
|
||||||
public static void Initialize()
|
public static void Initialize()
|
||||||
{
|
{
|
||||||
// Create the tray icon
|
// Create the tray icon
|
||||||
_trayIcon = new NotifyIcon { Icon = Resources.MainIcon, Text = Resources.ApplicationName };
|
_trayIcon = new NotifyIcon { Icon = Resources.ApplicationIcon, Text = Resources.ApplicationName };
|
||||||
|
|
||||||
// Setup the menu
|
// Setup the menu
|
||||||
var contextMenuStrip = new ContextMenuStrip();
|
var contextMenuStrip = new ContextMenuStrip();
|
||||||
@@ -46,6 +51,11 @@ namespace WorkIndicator
|
|||||||
|
|
||||||
// --
|
// --
|
||||||
|
|
||||||
|
contextMenuStrip.Items.Add("-");
|
||||||
|
contextMenuStrip.Items.Add(Resources.TrayIconContextMenuSettings, null, HandleContextMenuSettingsClick);
|
||||||
|
|
||||||
|
// --
|
||||||
|
|
||||||
contextMenuStrip.Items.Add("-");
|
contextMenuStrip.Items.Add("-");
|
||||||
contextMenuStrip.Items.Add(Resources.TrayIconContextMenuExit, null, HandleContextMenuExitClick);
|
contextMenuStrip.Items.Add(Resources.TrayIconContextMenuExit, null, HandleContextMenuExitClick);
|
||||||
|
|
||||||
@@ -65,21 +75,26 @@ namespace WorkIndicator
|
|||||||
if (menuItem.Tag == null)
|
if (menuItem.Tag == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var status = (Status) menuItem.Tag;
|
var status = (Status)menuItem.Tag;
|
||||||
|
|
||||||
((ToolStripMenuItem) menuItem).Checked = (LightController.Status == status);
|
((ToolStripMenuItem)menuItem).Checked = (LightController.Status == status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void HandleStatusMenuClick(object sender, System.EventArgs e)
|
private static void HandleStatusMenuClick(object sender, System.EventArgs e)
|
||||||
{
|
{
|
||||||
var menuItem = (ToolStripMenuItem) sender;
|
var menuItem = (ToolStripMenuItem)sender;
|
||||||
|
|
||||||
var status = (Status) menuItem.Tag;
|
var status = (Status)menuItem.Tag;
|
||||||
|
|
||||||
LightController.Status = status;
|
LightController.Status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void HandleContextMenuSettingsClick(object sender, System.EventArgs e)
|
||||||
|
{
|
||||||
|
ShowSettings();
|
||||||
|
}
|
||||||
|
|
||||||
private static void HandleContextMenuExitClick(object sender, System.EventArgs e)
|
private static void HandleContextMenuExitClick(object sender, System.EventArgs e)
|
||||||
{
|
{
|
||||||
// Shutdown the application
|
// Shutdown the application
|
||||||
@@ -97,5 +112,30 @@ namespace WorkIndicator
|
|||||||
|
|
||||||
_initialized = false;
|
_initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ShowSettings()
|
||||||
|
{
|
||||||
|
var panels = new List<CategoryPanel>
|
||||||
|
{
|
||||||
|
new GeneralOptionsPanel(),
|
||||||
|
new WindowPatternsOptionsPanel(),
|
||||||
|
new AboutOptionsPanel()
|
||||||
|
};
|
||||||
|
|
||||||
|
var windowPatterns = WindowPatterns.Load();
|
||||||
|
|
||||||
|
if (_optionsWindow == null)
|
||||||
|
{
|
||||||
|
_optionsWindow = new CategoryWindow(windowPatterns, panels, Resources.ResourceManager, "OptionsWindow");
|
||||||
|
_optionsWindow.Closed += (o, args) => { _optionsWindow = null; };
|
||||||
|
}
|
||||||
|
|
||||||
|
var dialogResult = _optionsWindow.ShowDialog();
|
||||||
|
|
||||||
|
if (dialogResult.HasValue && dialogResult.Value)
|
||||||
|
{
|
||||||
|
windowPatterns.Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
9
WindowPattern.cs
Normal file
9
WindowPattern.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace WorkIndicator
|
||||||
|
{
|
||||||
|
public class WindowPattern
|
||||||
|
{
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public string Pattern { get; set; } = string.Empty;
|
||||||
|
public bool Enabled { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
47
WindowPatterns.cs
Normal file
47
WindowPatterns.cs
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using WorkIndicator.Properties;
|
||||||
|
|
||||||
|
namespace WorkIndicator
|
||||||
|
{
|
||||||
|
public class WindowPatterns : ObservableCollection<WindowPattern>
|
||||||
|
{
|
||||||
|
public static event EventHandler Changed;
|
||||||
|
|
||||||
|
public static WindowPatterns Load()
|
||||||
|
{
|
||||||
|
var windowPatterns = Load(Settings.Default.WindowPatterns);
|
||||||
|
|
||||||
|
return windowPatterns;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static WindowPatterns Load(string serializedData)
|
||||||
|
{
|
||||||
|
var windowPatterns = JsonConvert.DeserializeObject<WindowPatterns>(serializedData) ?? new WindowPatterns();
|
||||||
|
|
||||||
|
return windowPatterns;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Save()
|
||||||
|
{
|
||||||
|
Settings.Default.WindowPatterns = Serialize();
|
||||||
|
|
||||||
|
Settings.Default.Save();
|
||||||
|
|
||||||
|
Changed?.Invoke(this, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string Serialize()
|
||||||
|
{
|
||||||
|
return JsonConvert.SerializeObject(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WindowPatterns Clone()
|
||||||
|
{
|
||||||
|
var data = Serialize();
|
||||||
|
|
||||||
|
return Load(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,21 @@
|
|||||||
<SccLocalPath>SAK</SccLocalPath>
|
<SccLocalPath>SAK</SccLocalPath>
|
||||||
<SccAuxPath>SAK</SccAuxPath>
|
<SccAuxPath>SAK</SccAuxPath>
|
||||||
<SccProvider>SAK</SccProvider>
|
<SccProvider>SAK</SccProvider>
|
||||||
|
<PublishUrl>publish\</PublishUrl>
|
||||||
|
<Install>true</Install>
|
||||||
|
<InstallFrom>Disk</InstallFrom>
|
||||||
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
|
<UpdateInterval>7</UpdateInterval>
|
||||||
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
|
<UpdateRequired>false</UpdateRequired>
|
||||||
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
@@ -108,7 +123,7 @@
|
|||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ApplicationIcon>Resources\MainIcon.ico</ApplicationIcon>
|
<ApplicationIcon>Resources\ApplicationIcon.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
@@ -144,7 +159,21 @@
|
|||||||
<Compile Include="Delcom\FileIODeclarations.cs" />
|
<Compile Include="Delcom\FileIODeclarations.cs" />
|
||||||
<Compile Include="Delcom\HID.cs" />
|
<Compile Include="Delcom\HID.cs" />
|
||||||
<Compile Include="Delcom\HIDDeclarations.cs" />
|
<Compile Include="Delcom\HIDDeclarations.cs" />
|
||||||
|
<Compile Include="Options\AboutOptionsPanel.xaml.cs">
|
||||||
|
<DependentUpon>AboutOptionsPanel.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Options\GeneralOptionsPanel.xaml.cs">
|
||||||
|
<DependentUpon>GeneralOptionsPanel.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Options\WindowPatternsOptionsPanel.xaml.cs">
|
||||||
|
<DependentUpon>WindowPatternsOptionsPanel.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Options\WindowPatternWindow.xaml.cs">
|
||||||
|
<DependentUpon>WindowPatternWindow.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="TrayIcon.cs" />
|
<Compile Include="TrayIcon.cs" />
|
||||||
|
<Compile Include="WindowPattern.cs" />
|
||||||
|
<Compile Include="WindowPatterns.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Properties\AssemblyInfo.cs">
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
@@ -161,32 +190,68 @@
|
|||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
</Compile>
|
</Compile>
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<None Include="app.config" />
|
<None Include="app.config" />
|
||||||
|
<None Include="LICENSE.md" />
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
</None>
|
</None>
|
||||||
<AppDesigner Include="Properties\" />
|
<AppDesigner Include="Properties\" />
|
||||||
|
<None Include="README.md" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Common.Native\Common.Native.csproj">
|
<Resource Include="Resources\ApplicationIcon.ico" />
|
||||||
<Project>{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}</Project>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include=".gitignore" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="Common.Wpf\Common.Native\Common.Native.csproj">
|
||||||
|
<Project>{ed1c07a1-54f5-4796-8b06-2a0bb1960d84}</Project>
|
||||||
<Name>Common.Native</Name>
|
<Name>Common.Native</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\Common.Wpf\Common.Wpf.csproj">
|
<ProjectReference Include="Common.Wpf\Common.Wpf.csproj">
|
||||||
<Project>{0074C983-550E-4094-9E8C-F566FB669297}</Project>
|
<Project>{0074c983-550e-4094-9e8c-f566fb669297}</Project>
|
||||||
<Name>Common.Wpf</Name>
|
<Name>Common.Wpf</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\Common\Common.csproj">
|
<ProjectReference Include="Common\Common.csproj">
|
||||||
<Project>{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}</Project>
|
<Project>{17864d82-457d-4a0a-bc10-1d07f2b3a5d6}</Project>
|
||||||
<Name>Common</Name>
|
<Name>Common</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Resource Include="Resources\MainIcon.ico" />
|
<Page Include="Options\AboutOptionsPanel.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
|
<Page Include="Options\GeneralOptionsPanel.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
|
<Page Include="Options\WindowPatternsOptionsPanel.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
|
<Page Include="Options\WindowPatternWindow.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json">
|
||||||
|
<Version>10.0.3</Version>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||||
|
<Install>false</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 2013
|
# Visual Studio 15
|
||||||
VisualStudioVersion = 12.0.30110.0
|
VisualStudioVersion = 15.0.27130.2027
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkIndicator", "WorkIndicator.csproj", "{A888FD0E-4A0E-4CAA-BC4D-C17D4AFA5715}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkIndicator", "WorkIndicator.csproj", "{A888FD0E-4A0E-4CAA-BC4D-C17D4AFA5715}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "..\Common\Common.csproj", "{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Native", "..\Common.Native\Common.Native.csproj", "{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Wpf", "Common.Wpf\Common.Wpf.csproj", "{0074C983-550E-4094-9E8C-F566FB669297}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Wpf", "..\Common.Wpf\Common.Wpf.csproj", "{0074C983-550E-4094-9E8C-F566FB669297}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Native", "Common.Wpf\Common.Native\Common.Native.csproj", "{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -45,18 +45,6 @@ Global
|
|||||||
{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|x64.Build.0 = Release|x64
|
{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|x64.Build.0 = Release|x64
|
||||||
{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|x86.ActiveCfg = Release|x86
|
{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|x86.ActiveCfg = Release|x86
|
||||||
{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|x86.Build.0 = Release|x86
|
{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|x86.Build.0 = Release|x86
|
||||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|x86.ActiveCfg = Debug|x86
|
|
||||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|x86.Build.0 = Debug|x86
|
|
||||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|x64.Build.0 = Release|x64
|
|
||||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|x86.ActiveCfg = Release|x86
|
|
||||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|x86.Build.0 = Release|x86
|
|
||||||
{0074C983-550E-4094-9E8C-F566FB669297}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{0074C983-550E-4094-9E8C-F566FB669297}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{0074C983-550E-4094-9E8C-F566FB669297}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{0074C983-550E-4094-9E8C-F566FB669297}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{0074C983-550E-4094-9E8C-F566FB669297}.Debug|x64.ActiveCfg = Debug|x64
|
{0074C983-550E-4094-9E8C-F566FB669297}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
@@ -69,8 +57,23 @@ Global
|
|||||||
{0074C983-550E-4094-9E8C-F566FB669297}.Release|x64.Build.0 = Release|x64
|
{0074C983-550E-4094-9E8C-F566FB669297}.Release|x64.Build.0 = Release|x64
|
||||||
{0074C983-550E-4094-9E8C-F566FB669297}.Release|x86.ActiveCfg = Release|x86
|
{0074C983-550E-4094-9E8C-F566FB669297}.Release|x86.ActiveCfg = Release|x86
|
||||||
{0074C983-550E-4094-9E8C-F566FB669297}.Release|x86.Build.0 = Release|x86
|
{0074C983-550E-4094-9E8C-F566FB669297}.Release|x86.Build.0 = Release|x86
|
||||||
|
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|x64.Build.0 = Release|x64
|
||||||
|
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|x86.Build.0 = Release|x86
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {43D76B6A-4DD4-40CF-BE03-763A12DCFA72}
|
||||||
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
<setting name="StartWithWindows" serializeAs="String">
|
<setting name="StartWithWindows" serializeAs="String">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="WindowPattern" serializeAs="String">
|
<setting name="WindowPatterns" serializeAs="String">
|
||||||
<value>.* - CKACZOR - Remote Desktop Connection</value>
|
<value />
|
||||||
</setting>
|
</setting>
|
||||||
</WorkIndicator.Properties.Settings>
|
</WorkIndicator.Properties.Settings>
|
||||||
</userSettings>
|
</userSettings>
|
||||||
|
|||||||
Reference in New Issue
Block a user