@@ -36,9 +36,10 @@ public class AppControllerCore
3636 public NotifyIconContainer NotifyIconContainer { get ; }
3737 public WindowPainter WindowPainter { get ; }
3838
39- private readonly DisplayWatcher _displayWatcher ;
4039 private readonly SessionWatcher _sessionWatcher ;
4140 private readonly PowerWatcher _powerWatcher ;
41+ private readonly DisplaySettingsWatcher _displaySettingsWatcher ;
42+ private readonly DisplayInformationWatcher _displayInformationWatcher ;
4243 private readonly BrightnessWatcher _brightnessWatcher ;
4344 private readonly BrightnessConnector _brightnessConnector ;
4445
@@ -57,9 +58,10 @@ public AppControllerCore(AppKeeper keeper, SettingsCore settings)
5758 NotifyIconContainer = new NotifyIconContainer ( ) ;
5859 WindowPainter = new WindowPainter ( ) ;
5960
60- _displayWatcher = new DisplayWatcher ( ) ;
6161 _sessionWatcher = new SessionWatcher ( ) ;
6262 _powerWatcher = new PowerWatcher ( ) ;
63+ _displaySettingsWatcher = new DisplaySettingsWatcher ( ) ;
64+ _displayInformationWatcher = new DisplayInformationWatcher ( ) ;
6365 _brightnessWatcher = new BrightnessWatcher ( ) ;
6466 _brightnessConnector = new BrightnessConnector ( ) ;
6567 }
@@ -90,9 +92,18 @@ public virtual async Task InitiateAsync()
9092 NotifyIconContainer . MouseLeftButtonClick += OnMainWindowShowRequestedBySelf ;
9193 NotifyIconContainer . MouseRightButtonClick += OnMenuWindowShowRequested ;
9294
93- _displayWatcher . Subscribe ( ( e ) => OnMonitorsChangeInferred ( nameof ( DisplayWatcher ) , e ) ) ;
9495 _sessionWatcher . Subscribe ( ( e ) => OnMonitorsChangeInferred ( nameof ( SessionWatcher ) , e ) ) ;
9596 _powerWatcher . Subscribe ( ( e ) => OnMonitorsChangeInferred ( nameof ( PowerWatcher ) , e ) ) ;
97+ _displaySettingsWatcher . Subscribe ( ( e ) => OnMonitorsChangeInferred ( nameof ( DisplaySettingsWatcher ) , e ) ) ;
98+
99+ _displayInformationWatcher . Subscribe ( async ( deviceInstanceId , message ) =>
100+ {
101+ if ( ! _sessionWatcher . IsLocked )
102+ {
103+ await UpdateMessageAsync ( deviceInstanceId , message ) ;
104+ await Recorder . RecordAsync ( message ) ;
105+ }
106+ } ) ;
96107
97108 if ( Monitors . Any ( x => x . IsInternal ) )
98109 {
@@ -102,17 +113,17 @@ public virtual async Task InitiateAsync()
102113 Update ( instanceName , brightness ) ;
103114 } ,
104115 async ( message ) => await Recorder . RecordAsync ( message ) ) ;
105- }
106116
107- if ( _brightnessConnector . CanConnect )
108- {
109- await _brightnessConnector . InitiateAsync ( ( brightness ) =>
117+ if ( _brightnessConnector . IsEnabled )
110118 {
111- if ( ! _sessionWatcher . IsLocked )
112- Update ( null , brightness ) ;
113- } ,
114- async ( message ) => await Recorder . RecordAsync ( message ) ,
115- ( ) => _current . Dispatcher . Invoke ( ( ) => _current . MainWindow . Visibility is Visibility . Visible ) ) ;
119+ await _brightnessConnector . InitiateAsync ( ( brightness ) =>
120+ {
121+ if ( ! _sessionWatcher . IsLocked )
122+ Update ( null , brightness ) ;
123+ } ,
124+ async ( message ) => await Recorder . RecordAsync ( message ) ,
125+ ( ) => _current . Dispatcher . Invoke ( ( ) => _current . MainWindow . Visibility is Visibility . Visible ) ) ;
126+ }
116127 }
117128
118129 await CleanAsync ( ) ;
@@ -125,9 +136,10 @@ public virtual void End()
125136 NotifyIconContainer . Dispose ( ) ;
126137 WindowPainter . Dispose ( ) ;
127138
128- _displayWatcher . Dispose ( ) ;
129139 _sessionWatcher . Dispose ( ) ;
130140 _powerWatcher . Dispose ( ) ;
141+ _displaySettingsWatcher . Dispose ( ) ;
142+ _displayInformationWatcher . Dispose ( ) ;
131143 _brightnessWatcher . Dispose ( ) ;
132144 _brightnessConnector . Dispose ( ) ;
133145 }
@@ -143,7 +155,7 @@ protected async void OnMainWindowShowRequestedBySelf(object sender, EventArgs e)
143155 ShowMainWindow ( ) ;
144156 await CheckUpdateAsync ( ) ;
145157
146- if ( _brightnessConnector . CanConnect )
158+ if ( _brightnessConnector . IsEnabled )
147159 await _brightnessConnector . ConnectAsync ( true ) ;
148160 }
149161
@@ -152,7 +164,7 @@ protected async void OnMainWindowShowRequestedByOther(object sender, EventArgs e
152164 _current . Dispatcher . Invoke ( ( ) => ShowMainWindow ( ) ) ;
153165 await CheckUpdateAsync ( ) ;
154166
155- if ( _brightnessConnector . CanConnect )
167+ if ( _brightnessConnector . IsEnabled )
156168 await _brightnessConnector . ConnectAsync ( true ) ;
157169 }
158170
@@ -263,7 +275,7 @@ protected internal virtual async void OnMonitorsChangeFound()
263275 {
264276 await Recorder . RecordAsync ( $ "{ nameof ( OnMonitorsChangeFound ) } ") ;
265277
266- _displayWatcher . RaiseDisplaySettingsChanged ( ) ;
278+ _displaySettingsWatcher . RaiseDisplaySettingsChanged ( ) ;
267279 }
268280 }
269281
@@ -436,6 +448,16 @@ protected virtual void Update(string instanceName, int brightness)
436448 monitor ? . UpdateBrightness ( brightness ) ;
437449 }
438450
451+ protected virtual async Task UpdateMessageAsync ( string deviceInstanceId , string message )
452+ {
453+ var monitor = Monitors . FirstOrDefault ( x => string . Equals ( x . DeviceInstanceId , deviceInstanceId , StringComparison . OrdinalIgnoreCase ) ) ;
454+ System . Diagnostics . Debug . WriteLine ( message ) ;
455+ if ( monitor is not null )
456+ {
457+ await monitor . ShowNormalMessageAsync ( message , TimeSpan . FromSeconds ( 30 ) ) ;
458+ }
459+ }
460+
439461 private void MonitorsDispose ( )
440462 {
441463 foreach ( var m in Monitors )
0 commit comments