File tree Expand file tree Collapse file tree 2 files changed +16
-13
lines changed Expand file tree Collapse file tree 2 files changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -26,15 +26,16 @@ Class Application
2626 End If
2727
2828 mainWindow = New MainWindow()
29- If e.Args.Length = 1 AndAlso e.Args( 0 ).ToString = "-tray" Then
30- mainWindow.ViewModel.ClosingCommand.Execute( New ComponentModel.CancelEventArgs( True ))
31- ElseIf e.Args.Length = 1 Then
32- Await mainWindow.ViewModel.SelectFolderAsync(e.Args( 0 ))
33- End If
29+ Dim shouldMinimizeToTray As Boolean = (e.Args.Length = 1 AndAlso e.Args( 0 ).ToString = "-tray" ) OrElse
30+ (SettingsHandler.AppSettings.StartInSystemTray AndAlso e.Args.Length = 0 )
3431
35- If SettingsHandler.AppSettings.StartInSystemTray AndAlso e.Args.Length = 0 Then
32+ If shouldMinimizeToTray Then
33+ mainWindow.Show()
3634 mainWindow.ViewModel.ClosingCommand.Execute( New ComponentModel.CancelEventArgs( True ))
3735 Else
36+ If e.Args.Length = 1 Then
37+ Await mainWindow.ViewModel.SelectFolderAsync(e.Args( 0 ))
38+ End If
3839 mainWindow.Show()
3940 End If
4041
Original file line number Diff line number Diff line change @@ -34,16 +34,18 @@ Partial Public Class MainViewModel
3434 Private Sub InitialiseNotificationTray()
3535 ClosingCommand = New RelayCommand( Of CancelEventArgs)( AddressOf Closing)
3636 NotifyCommand = New RelayCommand( Sub () Notify( "Hello" , "World" ))
37- NotifyIconOpenCommand = New RelayCommand( Sub ()
38- Application.Current.MainWindow.Show()
39- WindowState = WindowState.Normal
40- Application.Current.MainWindow.Topmost = True
41- Application.Current.MainWindow.Activate()
42- Application.Current.MainWindow.Topmost = False
43- End Sub )
37+ NotifyIconOpenCommand = New RelayCommand( AddressOf NotifyOpen)
4438 NotifyIconExitCommand = New RelayCommand( AddressOf NotifyExit)
4539 End Sub
4640
41+ Private Sub NotifyOpen()
42+ Application.Current.MainWindow.Show()
43+ WindowState = WindowState.Normal
44+ Application.Current.MainWindow.Topmost = True
45+ Application.Current.MainWindow.Activate()
46+ Application.Current.MainWindow.Topmost = False
47+ End Sub
48+
4749 Private Sub NotifyExit()
4850 If Watcher.WatchedFolders.Count = 0 Then Application.Current.Shutdown()
4951 Dim res = MessageBox.Show(
You can’t perform that action at this time.
0 commit comments