Skip to content

Commit 5c88e0a

Browse files
committed
Add option to start CompactGUI in tray. Closes #371
1 parent 43fe54b commit 5c88e0a

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

CompactGUI/Application.xaml.vb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ Class Application
6363

6464
mainWindow.ViewModel.SelectFolder(e.Args(0))
6565
End If
66+
67+
If SettingsHandler.AppSettings.StartInSystemTray Then
68+
mainWindow.Show()
69+
mainWindow.ViewModel.ClosingCommand.Execute(New ComponentModel.CancelEventArgs(True))
70+
Return
71+
End If
72+
6673
mainWindow.Show()
6774

6875
End Sub

CompactGUI/Components/Settings/SettingsControl.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local="clr-namespace:CompactGUI" xmlns:ui="http://schemas.modernwpf.com/2019"
7-
mc:Ignorable="d" Width="400" Background="White" Height="600" Padding="0,0,0,0"
7+
mc:Ignorable="d" Width="400" Background="White" Padding="0,0,0,0"
88
d:DesignHeight="600" d:DesignWidth="400">
99
<Grid Margin="0">
1010
<TextBlock Text="options" FontSize="26" FontWeight="SemiBold"/>
@@ -17,10 +17,10 @@
1717
<ui:NavigationViewItem Tag="help" Content="help"/>
1818
</ui:NavigationView.MenuItems>
1919
<ui:ScrollViewerEx VerticalScrollBarVisibility="Hidden">
20-
<Frame x:Name="ContentFrame" Padding="0, 20, 0, 0" NavigationUIVisibility="Hidden"/>
20+
<Frame x:Name="ContentFrame" Padding="0, 20, 0, 20" NavigationUIVisibility="Hidden"/>
2121
</ui:ScrollViewerEx>
2222

2323
</ui:NavigationView>
24-
<Border BorderThickness="2" VerticalAlignment="Bottom" Width="400" BorderBrush="Gray" CornerRadius="1"/>
24+
<Border BorderThickness="1" VerticalAlignment="Bottom" Width="400" BorderBrush="Gray" CornerRadius="1"/>
2525
</Grid>
2626
</UserControl>

CompactGUI/Components/Settings/Settings_main.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@
4949
<CheckBox x:Name="uiIsContextEnabled" >add to right-click context menu</CheckBox>
5050
<CheckBox x:Name="uiIsStartMenuEnabled" IsEnabled="False" Visibility="Collapsed">add to start menu</CheckBox>
5151
<CheckBox x:Name="uiShowNotifications" IsEnabled="True" Checked="uiShowNotifications_Checked" Unchecked="uiShowNotifications_Unchecked">show notification on completion</CheckBox>
52+
<CheckBox x:Name="uiAlwaysStartInTray" Checked="uiAlwaysStartInTray_Checked" Unchecked="uiAlwaysStartInTray_Unchecked">start CompactGUI in system tray</CheckBox>
5253

53-
</StackPanel>
54+
</StackPanel>
5455
<Separator Margin="0,10,0,10"/>
5556

5657
<Label Content="Background Watcher Settings" FontWeight="SemiBold"/>

CompactGUI/Components/Settings/Settings_main.xaml.vb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Class Settings_main
1515
uiShowNotifications.IsChecked = SettingsHandler.AppSettings.ShowNotifications
1616
uiEnableBackgroundWatcher.IsChecked = SettingsHandler.AppSettings.EnableBackgroundWatcher
1717
uiEnableBackgroundAutoCompression.IsChecked = SettingsHandler.AppSettings.EnableBackgroundAutoCompression
18+
uiAlwaysStartInTray.IsChecked = SettingsHandler.AppSettings.StartInSystemTray
1819
comboBoxSkipUserResultsAggression.SelectedIndex = SettingsHandler.AppSettings.SkipUserFileTypesLevel
1920
uiScalingFactor.Value = SettingsHandler.AppSettings.WindowScalingFactor
2021
SetEnv()
@@ -116,4 +117,14 @@ Class Settings_main
116117
SettingsHandler.AppSettings.EnableBackgroundAutoCompression = False
117118
SettingsHandler.AppSettings.Save()
118119
End Sub
120+
121+
Private Sub uiAlwaysStartInTray_Checked(sender As Object, e As RoutedEventArgs)
122+
SettingsHandler.AppSettings.StartInSystemTray = True
123+
SettingsHandler.AppSettings.Save()
124+
End Sub
125+
126+
Private Sub uiAlwaysStartInTray_Unchecked(sender As Object, e As RoutedEventArgs)
127+
SettingsHandler.AppSettings.StartInSystemTray = False
128+
SettingsHandler.AppSettings.Save()
129+
End Sub
119130
End Class

CompactGUI/Models/SetttingsHandler.vb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ Public Class Settings : Inherits ObservableObject
9696
Public Property IsStartMenuEnabled As Boolean = False
9797
Public Property SkipUserFileTypesLevel As Integer = 0
9898
Public Property ShowNotifications As Boolean = False
99+
Public Property StartInSystemTray As Boolean = False
99100

100101
Private _EnableBackgroundWatcher As Boolean = True
101102
Public Property EnableBackgroundWatcher As Boolean

0 commit comments

Comments
 (0)