Fix possible convert issue

This commit is contained in:
Jack251970 2026-01-04 23:19:12 +08:00
parent 590b4c82d2
commit 4c46e16160
4 changed files with 19 additions and 4 deletions

View file

@ -51,6 +51,7 @@
</ItemGroup>
<ItemGroup>
<!-- Do not include it in the build files -->
<PackageReference Include="iNKORE.UI.WPF.Modern" Version="0.10.2.1">
<PrivateAssets>all</PrivateAssets>
</PackageReference>

View file

@ -211,10 +211,13 @@ namespace Flow.Launcher.Plugin.WebSearch
get => maxSuggestions;
set
{
if (maxSuggestions != value)
if (value > 0 && value <= 1000)
{
maxSuggestions = value;
OnPropertyChanged();
if (maxSuggestions != value)
{
maxSuggestions = value;
OnPropertyChanged();
}
}
}
}

View file

@ -167,7 +167,8 @@
SmallChange="10"
SpinButtonPlacementMode="Compact"
ValidationMode="InvalidInputOverwritten"
Value="{Binding Settings.MaxSuggestions, Mode=TwoWay}" />
ValueChanged="NumberBox_ValueChanged"
Value="{Binding Settings.MaxSuggestions, Mode=OneWay}" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock

View file

@ -240,5 +240,15 @@ namespace Flow.Launcher.Plugin.WebSearch
}
return null;
}
// This is used for NumberBox to force its value to be 1 when the user clears the value
private void NumberBox_ValueChanged(iNKORE.UI.WPF.Modern.Controls.NumberBox sender, iNKORE.UI.WPF.Modern.Controls.NumberBoxValueChangedEventArgs args)
{
if (double.IsNaN(args.NewValue))
{
sender.Value = 1;
_settings.MaxSuggestions = (int)sender.Value;
}
}
}
}