22using  System . ComponentModel ; 
33using  System . Linq ; 
44using  System . Media ; 
5- using  System . Reactive . Linq ; 
65using  System . Threading . Tasks ; 
76using  System . Windows ; 
87using  System . Windows . Controls ; 
@@ -64,9 +63,6 @@ public partial class MainWindow : IDisposable
6463        private  const  double  DefaultRightMargin  =  66 ;  //* this value from base.xaml 
6564        private  bool  _isClockPanelAnimating  =  false ; 
6665
67-         // Search Delay 
68-         private  IDisposable  _reactiveSubscription ; 
69- 
7066        // IDisposable 
7167        private  bool  _disposed  =  false ; 
7268
@@ -122,9 +118,6 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
122118                welcomeWindow . Show ( ) ; 
123119            } 
124120
125-             // Initialize search delay 
126-             SetupSearchTextBoxReactiveness ( _settings . SearchQueryResultsWithDelay ,  _settings . SearchDelay ) ; 
127- 
128121            // Initialize place holder 
129122            SetupPlaceholderText ( ) ; 
130123            _viewModel . PlaceholderText  =  _settings . PlaceholderText ; 
@@ -267,15 +260,6 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
267260                    case  nameof ( Settings . KeepMaxResults ) : 
268261                        SetupResizeMode ( ) ; 
269262                        break ; 
270-                     case  nameof ( Settings . SearchQueryResultsWithDelay ) : 
271-                         SetupSearchTextBoxReactiveness ( _settings . SearchQueryResultsWithDelay ,  _settings . SearchDelay ) ; 
272-                         break ; 
273-                     case  nameof ( Settings . SearchDelaySpeed ) : 
274-                         if  ( _settings . SearchQueryResultsWithDelay ) 
275-                         { 
276-                             SetupSearchTextBoxReactiveness ( _settings . SearchQueryResultsWithDelay ,  _settings . SearchDelay ) ; 
277-                         } 
278-                         break ; 
279263                } 
280264            } ; 
281265
@@ -1126,46 +1110,11 @@ private void SetupResizeMode()
11261110
11271111        #region Search Delay
11281112
1129-         // Edited from: https://github.com/microsoft/PowerToys 
1130- 
1131-         private  void  SetupSearchTextBoxReactiveness ( bool  showResultsWithDelay ,  int  searchDelay ) 
1132-         { 
1133-             if  ( _reactiveSubscription  !=  null ) 
1134-             { 
1135-                 _reactiveSubscription . Dispose ( ) ; 
1136-                 _reactiveSubscription  =  null ; 
1137-             } 
1138- 
1139-             QueryTextBox . TextChanged  -=  QueryTextBox_TextChanged1 ; 
1140- 
1141-             if  ( showResultsWithDelay ) 
1142-             { 
1143-                 _reactiveSubscription  =  Observable . FromEventPattern < TextChangedEventHandler ,  TextChangedEventArgs > ( 
1144-                     conversion =>  ( sender ,  eventArg )  =>  conversion ( sender ,  eventArg ) , 
1145-                     add =>  QueryTextBox . TextChanged  +=  add , 
1146-                     remove =>  QueryTextBox . TextChanged  -=  remove ) 
1147-                     // TODO: Remove debug codes. 
1148-                     . Throttle ( TimeSpan . FromMilliseconds ( _settings . SearchDelay  *  10 ) ) 
1149-                     . Do ( @event =>  Dispatcher . Invoke ( ( )  =>  PerformSearchQuery ( true ,  ( TextBox ) @event . Sender ) ) ) 
1150-                     . Subscribe ( ) ; 
1151-             } 
1152-             else 
1153-             { 
1154-                 QueryTextBox . TextChanged  +=  QueryTextBox_TextChanged1 ; 
1155-             } 
1156-         } 
1157- 
11581113        private  void  QueryTextBox_TextChanged1 ( object  sender ,  TextChangedEventArgs  e ) 
11591114        { 
11601115            var  textBox  =  ( TextBox ) sender ; 
1161-             PerformSearchQuery ( false ,  textBox ) ; 
1162-         } 
1163- 
1164-         private  void  PerformSearchQuery ( bool  searchDelay ,  TextBox  textBox ) 
1165-         { 
1166-             var  text  =  textBox . Text ; 
1167-             _viewModel . QueryText  =  text ; 
1168-             _viewModel . Query ( searchDelay ) ; 
1116+             _viewModel . QueryText  =  textBox . Text ; 
1117+             _viewModel . Query ( _settings . SearchQueryResultsWithDelay ) ; 
11691118        } 
11701119
11711120        #endregion
@@ -1180,7 +1129,6 @@ protected virtual void Dispose(bool disposing)
11801129                { 
11811130                    _hwndSource ? . Dispose ( ) ; 
11821131                    _notifyIcon ? . Dispose ( ) ; 
1183-                     _reactiveSubscription ? . Dispose ( ) ; 
11841132                } 
11851133
11861134                _disposed  =  true ; 
0 commit comments