@@ -166,22 +166,6 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
166166 {
167167 if ( _viewModel . MainWindowVisibilityStatus )
168168 {
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-
185169 // Play sound effect before activing the window
186170 if ( _settings . UseSound )
187171 {
@@ -214,21 +198,6 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
214198 // Update activate times
215199 _settings . ActivateTimes ++ ;
216200 }
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- }
232201 } ) ;
233202 break ;
234203 }
@@ -329,8 +298,8 @@ private async void OnDeactivated(object sender, EventArgs e)
329298 _settings . WindowLeft = Left ;
330299 _settings . WindowTop = Top ;
331300
332- ClockPanel . Opacity = 0.0 ;
333- SearchIcon . Opacity = 0.0 ;
301+ _viewModel . ClockPanelOpacity = 0.0 ;
302+ _viewModel . SearchIconOpacity = 0.0 ;
334303
335304 // This condition stops extra hide call when animator is on,
336305 // which causes the toggling to occasional hide instead of show.
@@ -908,28 +877,28 @@ private void UpdateClockPanelVisibility()
908877 var animationDuration = TimeSpan . FromMilliseconds ( animationLength * 2 / 3 ) ;
909878
910879 // ✅ 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 &&
912881 ContextMenu . Visibility != Visibility . Visible &&
913882 History . Visibility != Visibility . Visible ;
914883
915884 // ✅ 1. When ContextMenu opens, immediately set Visibility.Hidden (force hide without animation)
916885 if ( ContextMenu . Visibility == Visibility . Visible )
917886 {
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
920889 return ;
921890 }
922891
923892 // ✅ 2. When ContextMenu is closed, keep it Hidden if there's text in the query (remember previous state)
924893 if ( ContextMenu . Visibility != Visibility . Visible && QueryTextBox . Text . Length > 0 )
925894 {
926- ClockPanel . Visibility = Visibility . Hidden ;
927- ClockPanel . Opacity = 0.0 ;
895+ _viewModel . ClockPanelVisibility = Visibility . Hidden ;
896+ _viewModel . ClockPanelOpacity = 0.0 ;
928897 return ;
929898 }
930899
931900 // ✅ 3. When hiding ClockPanel (apply fade-out animation)
932- if ( ( ! shouldShowClock ) && ClockPanel . Visibility == Visibility . Visible && ! _isClockPanelAnimating )
901+ if ( ( ! shouldShowClock ) && _viewModel . ClockPanelVisibility == Visibility . Visible && ! _isClockPanelAnimating )
933902 {
934903 _isClockPanelAnimating = true ;
935904
@@ -943,21 +912,21 @@ private void UpdateClockPanelVisibility()
943912
944913 fadeOut . Completed += ( s , e ) =>
945914 {
946- ClockPanel . Visibility = Visibility . Hidden ; // ✅ Completely hide after animation
915+ _viewModel . ClockPanelVisibility = Visibility . Hidden ; // ✅ Completely hide after animation
947916 _isClockPanelAnimating = false ;
948917 } ;
949918
950919 ClockPanel . BeginAnimation ( OpacityProperty , fadeOut ) ;
951920 }
952921
953922 // ✅ 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 )
955924 {
956925 _isClockPanelAnimating = true ;
957926
958927 Application . Current . Dispatcher . Invoke ( ( ) =>
959928 {
960- ClockPanel . Visibility = Visibility . Visible ; // ✅ Set Visibility to Visible first
929+ _viewModel . ClockPanelVisibility = Visibility . Visible ; // ✅ Set Visibility to Visible first
961930
962931 var fadeIn = new DoubleAnimation
963932 {
0 commit comments