@@ -111,8 +111,8 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
111
111
App . API . SaveAppAllSettings ( ) ;
112
112
113
113
// Show Welcome Window
114
- var WelcomeWindow = new WelcomeWindow ( ) ;
115
- WelcomeWindow . Show ( ) ;
114
+ var welcomeWindow = new WelcomeWindow ( ) ;
115
+ welcomeWindow . Show ( ) ;
116
116
}
117
117
118
118
// Hide window if need
@@ -241,7 +241,7 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
241
241
} ;
242
242
243
243
// 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 ( ) ;
245
245
246
246
// Detecting ContextMenu.Visibility changes
247
247
DependencyPropertyDescriptor
@@ -351,15 +351,13 @@ private void OnKeyDown(object sender, KeyEventArgs e)
351
351
_viewModel . LoadContextMenuCommand . Execute ( null ) ;
352
352
e . Handled = true ;
353
353
}
354
-
355
354
break ;
356
355
case Key . Left :
357
356
if ( ! _viewModel . QueryResultsSelected ( ) && QueryTextBox . CaretIndex == 0 )
358
357
{
359
358
_viewModel . EscCommand . Execute ( null ) ;
360
359
e . Handled = true ;
361
360
}
362
-
363
361
break ;
364
362
case Key . Back :
365
363
if ( specialKeyState . CtrlPressed )
@@ -378,7 +376,6 @@ private void OnKeyDown(object sender, KeyEventArgs e)
378
376
}
379
377
}
380
378
}
381
-
382
379
break ;
383
380
default :
384
381
break ;
@@ -864,16 +861,18 @@ private void WindowAnimation()
864
861
private void UpdateClockPanelVisibility ( )
865
862
{
866
863
if ( QueryTextBox == null || ContextMenu == null || History == null || ClockPanel == null )
864
+ {
867
865
return ;
866
+ }
868
867
868
+ // ✅ Initialize animation length & duration
869
869
var animationLength = _settings . AnimationSpeed switch
870
870
{
871
871
AnimationSpeeds . Slow => 560 ,
872
872
AnimationSpeeds . Medium => 360 ,
873
873
AnimationSpeeds . Fast => 160 ,
874
874
_ => _settings . CustomAnimationLength
875
875
} ;
876
-
877
876
var animationDuration = TimeSpan . FromMilliseconds ( animationLength * 2 / 3 ) ;
878
877
879
878
// ✅ Conditions for showing ClockPanel (No query input & ContextMenu, History are closed)
@@ -890,15 +889,21 @@ private void UpdateClockPanelVisibility()
890
889
}
891
890
892
891
// ✅ 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 )
894
893
{
895
894
_viewModel . ClockPanelVisibility = Visibility . Hidden ;
896
895
_viewModel . ClockPanelOpacity = 0.0 ;
897
896
return ;
898
897
}
899
898
899
+ // ✅ Prevent multiple animations
900
+ if ( _isClockPanelAnimating )
901
+ {
902
+ return ;
903
+ }
904
+
900
905
// ✅ 3. When hiding ClockPanel (apply fade-out animation)
901
- if ( ( ! shouldShowClock ) && _viewModel . ClockPanelVisibility == Visibility . Visible && ! _isClockPanelAnimating )
906
+ if ( ( ! shouldShowClock ) && _viewModel . ClockPanelVisibility == Visibility . Visible )
902
907
{
903
908
_isClockPanelAnimating = true ;
904
909
@@ -920,32 +925,32 @@ private void UpdateClockPanelVisibility()
920
925
}
921
926
922
927
// ✅ 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 )
924
929
{
925
930
_isClockPanelAnimating = true ;
926
931
927
- Application . Current . Dispatcher . Invoke ( ( ) =>
932
+ _viewModel . ClockPanelVisibility = Visibility . Visible ; // ✅ Set Visibility to Visible first
933
+
934
+ var fadeIn = new DoubleAnimation
928
935
{
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
+ } ;
930
941
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 ) ;
942
945
}
943
946
}
944
947
945
948
private static double GetOpacityFromStyle ( Style style , double defaultOpacity = 1.0 )
946
949
{
947
950
if ( style == null )
951
+ {
948
952
return defaultOpacity ;
953
+ }
949
954
950
955
foreach ( Setter setter in style . Setters . Cast < Setter > ( ) )
951
956
{
@@ -961,7 +966,9 @@ private static double GetOpacityFromStyle(Style style, double defaultOpacity = 1
961
966
private static Thickness GetThicknessFromStyle ( Style style , Thickness defaultThickness )
962
967
{
963
968
if ( style == null )
969
+ {
964
970
return defaultThickness ;
971
+ }
965
972
966
973
foreach ( Setter setter in style . Setters . Cast < Setter > ( ) )
967
974
{
0 commit comments