File tree Expand file tree Collapse file tree 4 files changed +32
-2
lines changed Expand file tree Collapse file tree 4 files changed +32
-2
lines changed Original file line number Diff line number Diff line change 1
- using System . Windows ;
1
+ using System ;
2
+ using System . Windows ;
2
3
using System . Windows . Input ;
3
4
4
5
namespace Flow . Launcher . Plugin
@@ -32,6 +33,24 @@ namespace Flow.Launcher.Plugin
32
33
/// <returns>return true to continue handling, return false to intercept system handling</returns>
33
34
public delegate bool FlowLauncherGlobalKeyboardEventHandler ( int keyevent , int vkcode , SpecialKeyState state ) ;
34
35
36
+ /// <summary>
37
+ /// A delegate for when the visibility is changed
38
+ /// </summary>
39
+ /// <param name="sender"></param>
40
+ /// <param name="args"></param>
41
+ public delegate void VisibilityChangedEventHandler ( object sender , VisibilityChangedEventArgs args ) ;
42
+
43
+ /// <summary>
44
+ /// The event args for <see cref="VisibilityChangedEventHandler"/>
45
+ /// </summary>
46
+ public class VisibilityChangedEventArgs : EventArgs
47
+ {
48
+ /// <summary>
49
+ /// <see langword="true"/> if the main window has become visible
50
+ /// </summary>
51
+ public bool IsVisible { get ; init ; }
52
+ }
53
+
35
54
/// <summary>
36
55
/// Arguments container for the Key Down event
37
56
/// </summary>
Original file line number Diff line number Diff line change @@ -96,7 +96,12 @@ public interface IPublicAPI
96
96
/// </summary>
97
97
/// <returns></returns>
98
98
bool IsMainWindowVisible ( ) ;
99
-
99
+
100
+ /// <summary>
101
+ /// Invoked when the visibility of the main window has changed. Currently, the plugin will continue to be subscribed even if it is turned off.
102
+ /// </summary>
103
+ event VisibilityChangedEventHandler VisibilityChanged ;
104
+
100
105
/// <summary>
101
106
/// Show message box
102
107
/// </summary>
Original file line number Diff line number Diff line change @@ -75,6 +75,8 @@ public void RestartApp()
75
75
76
76
public bool IsMainWindowVisible ( ) => _mainVM . MainWindowVisibilityStatus ;
77
77
78
+ public event VisibilityChangedEventHandler VisibilityChanged { add => _mainVM . VisibilityChanged += value ; remove => _mainVM . VisibilityChanged -= value ; }
79
+
78
80
public void CheckForNewUpdate ( ) => _settingsVM . UpdateApp ( ) ;
79
81
80
82
public void SaveAppAllSettings ( )
Original file line number Diff line number Diff line change @@ -578,6 +578,8 @@ private ResultsViewModel SelectedResults
578
578
// because it is more accurate and reliable representation than using Visibility as a condition check
579
579
public bool MainWindowVisibilityStatus { get ; set ; } = true ;
580
580
581
+ public event VisibilityChangedEventHandler VisibilityChanged ;
582
+
581
583
public Visibility SearchIconVisibility { get ; set ; }
582
584
583
585
public double MainWindowWidth
@@ -1014,6 +1016,7 @@ public void Show()
1014
1016
MainWindowOpacity = 1 ;
1015
1017
1016
1018
MainWindowVisibilityStatus = true ;
1019
+ VisibilityChanged ? . Invoke ( this , new VisibilityChangedEventArgs { IsVisible = true } ) ;
1017
1020
} ) ;
1018
1021
}
1019
1022
@@ -1048,6 +1051,7 @@ public async void Hide()
1048
1051
1049
1052
MainWindowVisibilityStatus = false ;
1050
1053
MainWindowVisibility = Visibility . Collapsed ;
1054
+ VisibilityChanged ? . Invoke ( this , new VisibilityChangedEventArgs { IsVisible = false } ) ;
1051
1055
}
1052
1056
1053
1057
/// <summary>
You can’t perform that action at this time.
0 commit comments