Skip to content

Commit

Permalink
Merge pull request #367 from hellium/feature-324-minimise-on-close cl…
Browse files Browse the repository at this point in the history
…oses #324

Issue #324
  • Loading branch information
benrhughes committed Sep 6, 2018
2 parents 11d22e3 + 7a5eed2 commit 8a47fbe
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions Client/Controls/MainWindow.xaml
Expand Up @@ -5,6 +5,7 @@
xmlns:local="clr-namespace:Client"
xmlns:convertors="clr-namespace:Client.Converters"
Loaded="Window_Loaded"
Closing="Window_Closing"
Title="todotxt.net"
mc:Ignorable="d"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Expand Down
15 changes: 15 additions & 0 deletions Client/Controls/MainWindow.xaml.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Reflection;
using System.Windows;
Expand Down Expand Up @@ -136,6 +137,20 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
DataContext = ViewModel;
}

private void Window_Closing(object sender, CancelEventArgs e)
{
if (Application.Current.ShutdownMode == ShutdownMode.OnExplicitShutdown)
{
return;
}

if (User.Default.MinimiseToSystemTray && User.Default.MinimiseOnClose)
{
e.Cancel = true;
WindowState = WindowState.Minimized;
}
}

#region window location handlers
private void Window_LocationChanged(object sender, EventArgs e)
{
Expand Down
1 change: 1 addition & 0 deletions Client/Controls/Options.xaml
Expand Up @@ -46,6 +46,7 @@
<CheckBox Content="Filter text is case-sensitive" x:Name="cbCaseSensitiveFilter" />
<CheckBox Content="Intellisense project and context suggestions are case-sensitive" x:Name="cbIntellisenseCaseSensitive" />
<CheckBox Content="Minimise to system tray (requires restart)" x:Name="cbMinToSysTray" />
<CheckBox Content="Minimise to system tray on close" x:Name="cbMinOnClose" IsEnabled="{Binding ElementName=cbMinToSysTray, Path=IsChecked}" />
<CheckBox Content="Enable debug logging" x:Name="cbDebugOn" />
<CheckBox Content="Use Ctrl-Enter to create new task" x:Name="cbRequireCtrlEnter" />
<CheckBox Content="Allow grouping of tasks" x:Name="cbAllowGrouping" />
Expand Down
1 change: 1 addition & 0 deletions Client/Controls/Options.xaml.cs
Expand Up @@ -33,6 +33,7 @@ public Options(FontInfo taskFont)
cbAddCreationDate.IsChecked = User.Default.AddCreationDate;
cbDebugOn.IsChecked = User.Default.DebugLoggingOn;
cbMinToSysTray.IsChecked = User.Default.MinimiseToSystemTray;
cbMinOnClose.IsChecked = User.Default.MinimiseOnClose;
cbRequireCtrlEnter.IsChecked = User.Default.RequireCtrlEnter;
cbAllowGrouping.IsChecked = User.Default.AllowGrouping;
cbMoveFocusToTaskListAfterAddingNewTask.IsChecked = User.Default.MoveFocusToTaskListAfterAddingNewTask;
Expand Down
1 change: 1 addition & 0 deletions Client/MainWindowViewModel.cs
Expand Up @@ -1493,6 +1493,7 @@ public void ShowOptionsDialog()
User.Default.AddCreationDate = o.cbAddCreationDate.IsChecked.Value;
User.Default.DebugLoggingOn = o.cbDebugOn.IsChecked.Value;
User.Default.MinimiseToSystemTray = o.cbMinToSysTray.IsChecked.Value;
User.Default.MinimiseOnClose = o.cbMinOnClose.IsChecked.Value;
User.Default.RequireCtrlEnter = o.cbRequireCtrlEnter.IsChecked.Value;
User.Default.AllowGrouping = o.cbAllowGrouping.IsChecked.Value;
User.Default.PreserveWhiteSpace = o.cbPreserveWhiteSpace.IsChecked.Value;
Expand Down
13 changes: 13 additions & 0 deletions Client/User.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Client/User.settings
Expand Up @@ -47,6 +47,9 @@
<Setting Name="MinimiseToSystemTray" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="MinimiseOnClose" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="RequireCtrlEnter" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
Expand Down
3 changes: 3 additions & 0 deletions Client/app.config
Expand Up @@ -52,6 +52,9 @@
<setting name="MinimiseToSystemTray" serializeAs="String">
<value>False</value>
</setting>
<setting name="MinimiseOnClose" serializeAs="String">
<value>False</value>
</setting>
<setting name="RequireCtrlEnter" serializeAs="String">
<value>False</value>
</setting>
Expand Down

0 comments on commit 8a47fbe

Please sign in to comment.