@@ -111,8 +111,8 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
111111                App . API . SaveAppAllSettings ( ) ; 
112112
113113                // Show Welcome Window 
114-                 var  WelcomeWindow  =  new  WelcomeWindow ( ) ; 
115-                 WelcomeWindow . Show ( ) ; 
114+                 var  welcomeWindow  =  new  WelcomeWindow ( ) ; 
115+                 welcomeWindow . Show ( ) ; 
116116            } 
117117
118118            // Hide window if need 
@@ -241,7 +241,7 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
241241            } ; 
242242
243243            // QueryTextBox.Text change detection (modified to only work when character count is 1 or higher) 
244-             QueryTextBox . TextChanged  +=  ( sender ,  e )  =>  UpdateClockPanelVisibility ( ) ; 
244+             QueryTextBox . TextChanged  +=  ( s ,  e )  =>  UpdateClockPanelVisibility ( ) ; 
245245
246246            // Detecting ContextMenu.Visibility changes 
247247            DependencyPropertyDescriptor 
@@ -351,15 +351,13 @@ private void OnKeyDown(object sender, KeyEventArgs e)
351351                        _viewModel . LoadContextMenuCommand . Execute ( null ) ; 
352352                        e . Handled  =  true ; 
353353                    } 
354- 
355354                    break ; 
356355                case  Key . Left : 
357356                    if  ( ! _viewModel . QueryResultsSelected ( )  &&  QueryTextBox . CaretIndex  ==  0 ) 
358357                    { 
359358                        _viewModel . EscCommand . Execute ( null ) ; 
360359                        e . Handled  =  true ; 
361360                    } 
362- 
363361                    break ; 
364362                case  Key . Back : 
365363                    if  ( specialKeyState . CtrlPressed ) 
@@ -378,7 +376,6 @@ private void OnKeyDown(object sender, KeyEventArgs e)
378376                            } 
379377                        } 
380378                    } 
381- 
382379                    break ; 
383380                default : 
384381                    break ; 
@@ -864,16 +861,18 @@ private void WindowAnimation()
864861        private  void  UpdateClockPanelVisibility ( ) 
865862        { 
866863            if  ( QueryTextBox  ==  null  ||  ContextMenu  ==  null  ||  History  ==  null  ||  ClockPanel  ==  null ) 
864+             { 
867865                return ; 
866+             } 
868867
868+             // ✅ Initialize animation length & duration 
869869            var  animationLength  =  _settings . AnimationSpeed  switch 
870870            { 
871871                AnimationSpeeds . Slow  =>  560 , 
872872                AnimationSpeeds . Medium  =>  360 , 
873873                AnimationSpeeds . Fast  =>  160 , 
874874                _ =>  _settings . CustomAnimationLength 
875875            } ; 
876- 
877876            var  animationDuration  =  TimeSpan . FromMilliseconds ( animationLength  *  2  /  3 ) ; 
878877
879878            // ✅ Conditions for showing ClockPanel (No query input & ContextMenu, History are closed) 
@@ -890,15 +889,21 @@ private void UpdateClockPanelVisibility()
890889            } 
891890
892891            // ✅ 2. When ContextMenu is closed, keep it Hidden if there's text in the query (remember previous state) 
893-             if  ( ContextMenu . Visibility   !=   Visibility . Visible   &&   QueryTextBox . Text . Length  >  0 ) 
892+             else   if  ( QueryTextBox . Text . Length  >  0 ) 
894893            { 
895894                _viewModel . ClockPanelVisibility  =  Visibility . Hidden ; 
896895                _viewModel . ClockPanelOpacity  =  0.0 ; 
897896                return ; 
898897            } 
899898
899+             // ✅ Prevent multiple animations 
900+             if  ( _isClockPanelAnimating ) 
901+             { 
902+                 return ; 
903+             } 
904+ 
900905            // ✅ 3. When hiding ClockPanel (apply fade-out animation) 
901-             if  ( ( ! shouldShowClock )  &&  _viewModel . ClockPanelVisibility  ==  Visibility . Visible   &&   ! _isClockPanelAnimating ) 
906+             if  ( ( ! shouldShowClock )  &&  _viewModel . ClockPanelVisibility  ==  Visibility . Visible ) 
902907            { 
903908                _isClockPanelAnimating  =  true ; 
904909
@@ -920,32 +925,32 @@ private void UpdateClockPanelVisibility()
920925            } 
921926
922927            // ✅ 4. When showing ClockPanel (apply fade-in animation) 
923-             else  if  ( shouldShowClock  &&  _viewModel . ClockPanelVisibility  !=  Visibility . Visible   &&   ! _isClockPanelAnimating ) 
928+             else  if  ( shouldShowClock  &&  _viewModel . ClockPanelVisibility  !=  Visibility . Visible ) 
924929            { 
925930                _isClockPanelAnimating  =  true ; 
926931
927-                 Application . Current . Dispatcher . Invoke ( ( )  => 
932+                 _viewModel . ClockPanelVisibility  =  Visibility . Visible ;   // ✅ Set Visibility to Visible first 
933+ 
934+                 var  fadeIn  =  new  DoubleAnimation 
928935                { 
929-                     _viewModel . ClockPanelVisibility  =  Visibility . Visible ;   // ✅ Set Visibility to Visible first 
936+                     From  =  0.0 , 
937+                     To  =  1.0 , 
938+                     Duration  =  animationDuration , 
939+                     FillBehavior  =  FillBehavior . HoldEnd 
940+                 } ; 
930941
931-                     var  fadeIn  =  new  DoubleAnimation 
932-                     { 
933-                         From  =  0.0 , 
934-                         To  =  1.0 , 
935-                         Duration  =  animationDuration , 
936-                         FillBehavior  =  FillBehavior . HoldEnd 
937-                     } ; 
938- 
939-                     fadeIn . Completed  +=  ( s ,  e )  =>  _isClockPanelAnimating  =  false ; 
940-                     ClockPanel . BeginAnimation ( OpacityProperty ,  fadeIn ) ; 
941-                 } ,  DispatcherPriority . Render ) ; 
942+                 fadeIn . Completed  +=  ( s ,  e )  =>  _isClockPanelAnimating  =  false ; 
943+ 
944+                 ClockPanel . BeginAnimation ( OpacityProperty ,  fadeIn ) ; 
942945            } 
943946        } 
944947
945948        private  static   double  GetOpacityFromStyle ( Style  style ,  double  defaultOpacity  =  1.0 ) 
946949        { 
947950            if  ( style  ==  null ) 
951+             { 
948952                return  defaultOpacity ; 
953+             } 
949954
950955            foreach  ( Setter  setter  in  style . Setters . Cast < Setter > ( ) ) 
951956            { 
@@ -961,7 +966,9 @@ private static double GetOpacityFromStyle(Style style, double defaultOpacity = 1
961966        private  static   Thickness  GetThicknessFromStyle ( Style  style ,  Thickness  defaultThickness ) 
962967        { 
963968            if  ( style  ==  null ) 
969+             { 
964970                return  defaultThickness ; 
971+             } 
965972
966973            foreach  ( Setter  setter  in  style . Setters . Cast < Setter > ( ) ) 
967974            { 
0 commit comments