Skip to content

Commit

Permalink
Fix row count setting
Browse files Browse the repository at this point in the history
  • Loading branch information
dremin committed Nov 9, 2024
1 parent f7786fd commit ad4f7af
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
19 changes: 19 additions & 0 deletions RetroBar/Converters/CountToIndexConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Globalization;
using System.Windows.Data;

namespace RetroBar.Converters
{
public class CountToIndexConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (int)value - 1;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return (int)value + 1;
}
}
}
4 changes: 3 additions & 1 deletion RetroBar/PropertiesWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<converters:BoolToTextRenderingModeConverter x:Key="textRenderingModeConverter" />
<converters:BoolToVisibilityConverter x:Key="boolToVisibilityConverter" />
<converters:BoolToInvertedVisibilityConverter x:Key="boolToInvertedVisibilityConverter" />
<converters:CountToIndexConverter x:Key="countToIndexConverter" />
<converters:DoubleToPercentConverter x:Key="doubleToPercentConverter" />
<converters:EnumConverter x:Key="enumConverter" />
<converters:EdgeIsHorizontalConverter x:Key="isHorizontalConverter" />
Expand Down Expand Up @@ -212,7 +213,8 @@
</Label>
<ComboBox x:Name="cbRowCount"
ItemsSource="{DynamicResource rowcount_options}"
SelectedValue="{Binding Source={x:Static Settings:Settings.Instance}, Path=RowCount, UpdateSourceTrigger=PropertyChanged}" />
SelectedIndex="{Binding Source={x:Static Settings:Settings.Instance}, Path=RowCount, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource countToIndexConverter}}"
SelectionChanged="cbRowCount_SelectionChanged" />
</DockPanel>
<CheckBox IsChecked="{Binding Source={x:Static Settings:Settings.Instance}, Path=AllowFontSmoothing, UpdateSourceTrigger=PropertyChanged}">
<Label Content="{DynamicResource allow_font_smoothing}" />
Expand Down
8 changes: 8 additions & 0 deletions RetroBar/PropertiesWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,14 @@ private void cboMiddleMouseAction_SelectionChanged(object sender, System.Windows
}
}

private void cbRowCount_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
if (cbRowCount.SelectedItem == null)
{
cbRowCount.SelectedValue = cbRowCount.Items[Settings.Instance.RowCount - 1];
}
}

private void CustomizeNotifications_OnClick(object sender, RoutedEventArgs e)
{
OpenCustomizeNotifications();
Expand Down

0 comments on commit ad4f7af

Please sign in to comment.