Skip to content

Commit 4c46e16

Browse files
committed
Fix possible convert issue
1 parent 590b4c8 commit 4c46e16

4 files changed

Lines changed: 19 additions & 4 deletions

File tree

Plugins/Flow.Launcher.Plugin.WebSearch/Flow.Launcher.Plugin.WebSearch.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
</ItemGroup>
5252

5353
<ItemGroup>
54+
<!-- Do not include it in the build files -->
5455
<PackageReference Include="iNKORE.UI.WPF.Modern" Version="0.10.2.1">
5556
<PrivateAssets>all</PrivateAssets>
5657
</PackageReference>

Plugins/Flow.Launcher.Plugin.WebSearch/Settings.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,13 @@ public int MaxSuggestions
211211
get => maxSuggestions;
212212
set
213213
{
214-
if (maxSuggestions != value)
214+
if (value > 0 && value <= 1000)
215215
{
216-
maxSuggestions = value;
217-
OnPropertyChanged();
216+
if (maxSuggestions != value)
217+
{
218+
maxSuggestions = value;
219+
OnPropertyChanged();
220+
}
218221
}
219222
}
220223
}

Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@
167167
SmallChange="10"
168168
SpinButtonPlacementMode="Compact"
169169
ValidationMode="InvalidInputOverwritten"
170-
Value="{Binding Settings.MaxSuggestions, Mode=TwoWay}" />
170+
ValueChanged="NumberBox_ValueChanged"
171+
Value="{Binding Settings.MaxSuggestions, Mode=OneWay}" />
171172
</StackPanel>
172173
<StackPanel Orientation="Horizontal">
173174
<TextBlock

Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,5 +240,15 @@ private static T FindAncestor<T>(DependencyObject current) where T : DependencyO
240240
}
241241
return null;
242242
}
243+
244+
// This is used for NumberBox to force its value to be 1 when the user clears the value
245+
private void NumberBox_ValueChanged(iNKORE.UI.WPF.Modern.Controls.NumberBox sender, iNKORE.UI.WPF.Modern.Controls.NumberBoxValueChangedEventArgs args)
246+
{
247+
if (double.IsNaN(args.NewValue))
248+
{
249+
sender.Value = 1;
250+
_settings.MaxSuggestions = (int)sender.Value;
251+
}
252+
}
243253
}
244254
}

0 commit comments

Comments
 (0)