@@ -27,10 +27,10 @@ public class BetterComboBox : ComboBox
2727 BetterComboBox ,
2828 string
2929 > ( nameof ( SearchWatermark ) , defaultValue : "Search..." ) ;
30- public static readonly StyledProperty < bool > UseLegacyModelSearchProperty = AvaloniaProperty . Register <
30+ public static readonly StyledProperty < bool > UseLegacySearchProperty = AvaloniaProperty . Register <
3131 BetterComboBox ,
3232 bool
33- > ( nameof ( UseLegacyModelSearch ) ) ;
33+ > ( nameof ( UseLegacySearch ) ) ;
3434 public static readonly DirectProperty < BetterComboBox , string > SearchTextProperty =
3535 AvaloniaProperty . RegisterDirect < BetterComboBox , string > ( nameof ( SearchText ) , o => o . SearchText ) ;
3636
@@ -40,10 +40,10 @@ public string SearchWatermark
4040 set => SetValue ( SearchWatermarkProperty , value ) ;
4141 }
4242
43- public bool UseLegacyModelSearch
43+ public bool UseLegacySearch
4444 {
45- get => GetValue ( UseLegacyModelSearchProperty ) ;
46- set => SetValue ( UseLegacyModelSearchProperty , value ) ;
45+ get => GetValue ( UseLegacySearchProperty ) ;
46+ set => SetValue ( UseLegacySearchProperty , value ) ;
4747 }
4848
4949 public string SearchText
@@ -104,7 +104,7 @@ public BetterComboBox()
104104 settingsManager = App . Services . GetService < ISettingsManager > ( ) ;
105105 if ( settingsManager is not null )
106106 {
107- UseLegacyModelSearch = settingsManager . Settings . UseLegacyModelSearch ;
107+ ApplyGlobalLegacySearchOverride ( settingsManager . Settings . UseLegacySearch ) ;
108108 settingsManager . SettingsPropertyChanged += OnSettingsPropertyChanged ;
109109 }
110110 }
@@ -160,7 +160,7 @@ protected override void OnTextInput(TextInputEventArgs e)
160160 if ( IsDropDownOpen )
161161 {
162162 UpdateSearchTextBoxText ( keyboardSearchText ) ;
163- if ( ! UseLegacyModelSearch )
163+ if ( ! UseLegacySearch )
164164 {
165165 Dispatcher . UIThread . Post ( ( ) => searchTextBox ? . Focus ( ) , DispatcherPriority . Input ) ;
166166 }
@@ -199,7 +199,7 @@ private void OnDropDownOpened(object? sender, EventArgs e)
199199 StopLegacySearchResetTimer ( ) ;
200200 ResetSearchText ( ) ;
201201 ApplyFilter ( string . Empty ) ;
202- if ( ! UseLegacyModelSearch )
202+ if ( ! UseLegacySearch )
203203 {
204204 Dispatcher . UIThread . Post ( ( ) => searchTextBox ? . Focus ( ) , DispatcherPriority . Input ) ;
205205 }
@@ -235,7 +235,7 @@ private void ResetSearchText()
235235
236236 private void RestartLegacySearchResetTimer ( )
237237 {
238- if ( ! UseLegacyModelSearch || string . IsNullOrEmpty ( keyboardSearchText ) )
238+ if ( ! UseLegacySearch || string . IsNullOrEmpty ( keyboardSearchText ) )
239239 return ;
240240
241241 legacySearchResetTimer . Stop ( ) ;
@@ -249,7 +249,7 @@ private void StopLegacySearchResetTimer()
249249
250250 private void UpdateLegacySearchPopupText ( string text )
251251 {
252- if ( ! UseLegacyModelSearch || string . IsNullOrWhiteSpace ( text ) )
252+ if ( ! UseLegacySearch || string . IsNullOrWhiteSpace ( text ) )
253253 {
254254 HideLegacySearchPopup ( ) ;
255255 return ;
@@ -278,7 +278,7 @@ private void OnLegacySearchResetTimerTick(object? sender, EventArgs e)
278278 {
279279 legacySearchResetTimer . Stop ( ) ;
280280
281- if ( ! UseLegacyModelSearch || string . IsNullOrWhiteSpace ( keyboardSearchText ) )
281+ if ( ! UseLegacySearch || string . IsNullOrWhiteSpace ( keyboardSearchText ) )
282282 return ;
283283
284284 ResetSearchText ( ) ;
@@ -288,7 +288,7 @@ private void OnInputReceived(string input)
288288 {
289289 if ( IsDropDownOpen )
290290 {
291- if ( UseLegacyModelSearch )
291+ if ( UseLegacySearch )
292292 {
293293 var query = input . Trim ( ) ;
294294 if ( string . IsNullOrWhiteSpace ( query ) )
@@ -320,7 +320,7 @@ private void OnInputReceived(string input)
320320 return ;
321321 }
322322
323- if ( UseLegacyModelSearch )
323+ if ( UseLegacySearch )
324324 {
325325 var legacyMatch = FindLegacyMatch ( input ) ;
326326 if ( legacyMatch is null )
@@ -393,9 +393,9 @@ private void ApplyFilter(string input)
393393
394394 private bool IsItemMatch ( object item , string query )
395395 {
396- var itemText = GetItemSearchText ( item , UseLegacyModelSearch ) ;
396+ var itemText = GetItemSearchText ( item , UseLegacySearch ) ;
397397
398- if ( UseLegacyModelSearch )
398+ if ( UseLegacySearch )
399399 {
400400 return itemText . Contains ( query , StringComparison . OrdinalIgnoreCase ) ;
401401 }
@@ -475,7 +475,7 @@ Func<TItem, string> getSearchText
475475
476476 private void OnContainerPrepared ( object ? sender , ContainerPreparedEventArgs e )
477477 {
478- if ( ! IsDropDownOpen || UseLegacyModelSearch )
478+ if ( ! IsDropDownOpen || UseLegacySearch )
479479 return ;
480480
481481 var query = keyboardSearchText . Trim ( ) ;
@@ -493,7 +493,7 @@ private void OnContainerPrepared(object? sender, ContainerPreparedEventArgs e)
493493
494494 private void OnContainerIndexChanged ( object ? sender , ContainerIndexChangedEventArgs e )
495495 {
496- if ( ! IsDropDownOpen || UseLegacyModelSearch )
496+ if ( ! IsDropDownOpen || UseLegacySearch )
497497 return ;
498498
499499 var query = keyboardSearchText . Trim ( ) ;
@@ -518,22 +518,34 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
518518 searchCache . Clear ( ) ;
519519 }
520520
521- if ( change . Property == UseLegacyModelSearchProperty && ! UseLegacyModelSearch )
521+ if ( change . Property == UseLegacySearchProperty && ! UseLegacySearch )
522522 {
523523 StopLegacySearchResetTimer ( ) ;
524524 HideLegacySearchPopup ( ) ;
525525 }
526526 }
527527
528+ private void ApplyGlobalLegacySearchOverride ( bool globalOverride )
529+ {
530+ if ( globalOverride )
531+ {
532+ SetValue ( UseLegacySearchProperty , true ) ;
533+ }
534+ else
535+ {
536+ ClearValue ( UseLegacySearchProperty ) ;
537+ }
538+ }
539+
528540 private void OnSettingsPropertyChanged ( object ? sender , RelayPropertyChangedEventArgs e )
529541 {
530- if ( e . PropertyName != nameof ( Settings . UseLegacyModelSearch ) || settingsManager is null )
542+ if ( e . PropertyName != nameof ( Settings . UseLegacySearch ) || settingsManager is null )
531543 return ;
532544
533545 Dispatcher . UIThread . Post ( ( ) =>
534546 {
535- UseLegacyModelSearch = settingsManager . Settings . UseLegacyModelSearch ;
536- if ( ! UseLegacyModelSearch )
547+ ApplyGlobalLegacySearchOverride ( settingsManager . Settings . UseLegacySearch ) ;
548+ if ( ! UseLegacySearch )
537549 {
538550 StopLegacySearchResetTimer ( ) ;
539551 HideLegacySearchPopup ( ) ;
0 commit comments