@@ -166,22 +166,6 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
166
166
{
167
167
if ( _viewModel . MainWindowVisibilityStatus )
168
168
{
169
- // Set clock and search icon opacity
170
- var opacity = _settings . UseAnimation ? 0.0 : 1.0 ;
171
- ClockPanel . Opacity = opacity ;
172
- SearchIcon . Opacity = opacity ;
173
-
174
- // Set clock and search icon visibility
175
- ClockPanel . Visibility = string . IsNullOrEmpty ( _viewModel . QueryText ) ? Visibility . Visible : Visibility . Collapsed ;
176
- if ( _viewModel . PluginIconSource != null )
177
- {
178
- SearchIcon . Opacity = 0.0 ;
179
- }
180
- else
181
- {
182
- _viewModel . SearchIconVisibility = Visibility . Visible ;
183
- }
184
-
185
169
// Play sound effect before activing the window
186
170
if ( _settings . UseSound )
187
171
{
@@ -214,21 +198,6 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
214
198
// Update activate times
215
199
_settings . ActivateTimes ++ ;
216
200
}
217
- else
218
- {
219
- // Set clock and search icon opacity
220
- var opacity = _settings . UseAnimation ? 0.0 : 1.0 ;
221
- ClockPanel . Opacity = opacity ;
222
- SearchIcon . Opacity = opacity ;
223
-
224
- // Set clock and search icon visibility
225
- ClockPanel . Visibility = Visibility . Hidden ;
226
- _viewModel . SearchIconVisibility = Visibility . Hidden ;
227
-
228
- // Force UI update
229
- ClockPanel . UpdateLayout ( ) ;
230
- SearchIcon . UpdateLayout ( ) ;
231
- }
232
201
} ) ;
233
202
break ;
234
203
}
@@ -329,8 +298,8 @@ private async void OnDeactivated(object sender, EventArgs e)
329
298
_settings . WindowLeft = Left ;
330
299
_settings . WindowTop = Top ;
331
300
332
- ClockPanel . Opacity = 0.0 ;
333
- SearchIcon . Opacity = 0.0 ;
301
+ _viewModel . ClockPanelOpacity = 0.0 ;
302
+ _viewModel . SearchIconOpacity = 0.0 ;
334
303
335
304
// This condition stops extra hide call when animator is on,
336
305
// which causes the toggling to occasional hide instead of show.
@@ -908,28 +877,28 @@ private void UpdateClockPanelVisibility()
908
877
var animationDuration = TimeSpan . FromMilliseconds ( animationLength * 2 / 3 ) ;
909
878
910
879
// ✅ Conditions for showing ClockPanel (No query input & ContextMenu, History are closed)
911
- bool shouldShowClock = QueryTextBox . Text . Length == 0 &&
880
+ var shouldShowClock = QueryTextBox . Text . Length == 0 &&
912
881
ContextMenu . Visibility != Visibility . Visible &&
913
882
History . Visibility != Visibility . Visible ;
914
883
915
884
// ✅ 1. When ContextMenu opens, immediately set Visibility.Hidden (force hide without animation)
916
885
if ( ContextMenu . Visibility == Visibility . Visible )
917
886
{
918
- ClockPanel . Visibility = Visibility . Hidden ;
919
- ClockPanel . Opacity = 0.0 ; // Set to 0 in case Opacity animation affects it
887
+ _viewModel . ClockPanelVisibility = Visibility . Hidden ;
888
+ _viewModel . ClockPanelOpacity = 0.0 ; // Set to 0 in case Opacity animation affects it
920
889
return ;
921
890
}
922
891
923
892
// ✅ 2. When ContextMenu is closed, keep it Hidden if there's text in the query (remember previous state)
924
893
if ( ContextMenu . Visibility != Visibility . Visible && QueryTextBox . Text . Length > 0 )
925
894
{
926
- ClockPanel . Visibility = Visibility . Hidden ;
927
- ClockPanel . Opacity = 0.0 ;
895
+ _viewModel . ClockPanelVisibility = Visibility . Hidden ;
896
+ _viewModel . ClockPanelOpacity = 0.0 ;
928
897
return ;
929
898
}
930
899
931
900
// ✅ 3. When hiding ClockPanel (apply fade-out animation)
932
- if ( ( ! shouldShowClock ) && ClockPanel . Visibility == Visibility . Visible && ! _isClockPanelAnimating )
901
+ if ( ( ! shouldShowClock ) && _viewModel . ClockPanelVisibility == Visibility . Visible && ! _isClockPanelAnimating )
933
902
{
934
903
_isClockPanelAnimating = true ;
935
904
@@ -943,21 +912,21 @@ private void UpdateClockPanelVisibility()
943
912
944
913
fadeOut . Completed += ( s , e ) =>
945
914
{
946
- ClockPanel . Visibility = Visibility . Hidden ; // ✅ Completely hide after animation
915
+ _viewModel . ClockPanelVisibility = Visibility . Hidden ; // ✅ Completely hide after animation
947
916
_isClockPanelAnimating = false ;
948
917
} ;
949
918
950
919
ClockPanel . BeginAnimation ( OpacityProperty , fadeOut ) ;
951
920
}
952
921
953
922
// ✅ 4. When showing ClockPanel (apply fade-in animation)
954
- else if ( shouldShowClock && ClockPanel . Visibility != Visibility . Visible && ! _isClockPanelAnimating )
923
+ else if ( shouldShowClock && _viewModel . ClockPanelVisibility != Visibility . Visible && ! _isClockPanelAnimating )
955
924
{
956
925
_isClockPanelAnimating = true ;
957
926
958
927
Application . Current . Dispatcher . Invoke ( ( ) =>
959
928
{
960
- ClockPanel . Visibility = Visibility . Visible ; // ✅ Set Visibility to Visible first
929
+ _viewModel . ClockPanelVisibility = Visibility . Visible ; // ✅ Set Visibility to Visible first
961
930
962
931
var fadeIn = new DoubleAnimation
963
932
{
0 commit comments