Skip to content

Commit

Permalink
Fix SelectedIndex Issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Sep 17, 2024
1 parent bfb3a1b commit 4f31973
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion src/PicView.Avalonia/Views/GeneralSettingsView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,37 @@ public GeneralSettingsView()
SettingsHelper.Settings.StartUp.OpenLastFile = ApplicationStartupBox.SelectedIndex == 1;
await SettingsHelper.SaveSettingsAsync();
};
ApplicationStartupBox.DropDownOpened += delegate
{
if (ApplicationStartupBox.SelectedIndex == -1)
{
ApplicationStartupBox.SelectedIndex = SettingsHelper.Settings.StartUp.OpenLastFile ? 0 : 1;
}
};
MouseWheelBox.SelectionChanged += async delegate
{
SettingsHelper.Settings.Zoom.CtrlZoom = MouseWheelBox.SelectedIndex == 0;
await SettingsHelper.SaveSettingsAsync();
};
MouseWheelBox.DropDownOpened += delegate
{
if (MouseWheelBox.SelectedIndex == -1)
{
MouseWheelBox.SelectedIndex = SettingsHelper.Settings.Zoom.CtrlZoom ? 0 : 1;
}
};
ScrollDirectionBox.SelectionChanged += async delegate
{
SettingsHelper.Settings.Zoom.HorizontalReverseScroll = ScrollDirectionBox.SelectedIndex == 0;
await SettingsHelper.SaveSettingsAsync();
};
ScrollDirectionBox.DropDownOpened += delegate
{
if (ScrollDirectionBox.SelectedIndex == -1)
{
ScrollDirectionBox.SelectedIndex = SettingsHelper.Settings.Zoom.HorizontalReverseScroll ? 0 : 1;
}
};
MouseWheelBox.SelectedIndex = SettingsHelper.Settings.Zoom.CtrlZoom ? 0 : 1;
ScrollDirectionBox.SelectedIndex = SettingsHelper.Settings.Zoom.HorizontalReverseScroll ? 0 : 1;
ApplicationStartupBox.SelectedIndex = SettingsHelper.Settings.StartUp.OpenLastFile ? 1 : 0;
Expand Down Expand Up @@ -69,6 +90,11 @@ public GeneralSettingsView()
{
return;
}

if (language == SettingsHelper.Settings.UIProperties.UserLanguage)
{
return;
}
SettingsHelper.Settings.UIProperties.UserLanguage = language;

await TranslationHelper.LoadLanguage(language).ConfigureAwait(false);
Expand All @@ -85,12 +111,30 @@ await Dispatcher.UIThread.InvokeAsync(() =>
{
return;
}
window.Close();
window.Close();
});

await FunctionsHelper.SettingsWindow();
await SettingsHelper.SaveSettingsAsync();
};
LanguageBox.DropDownOpened += delegate
{
if (LanguageBox.SelectedIndex != -1)
{
return;
}

// Find the ComboBoxItem whose Tag matches UserLanguage
for (var i = 0; i < LanguageBox.Items.Count; i++)
{
if (LanguageBox.Items[i] is ComboBoxItem { Tag: string tag } &&
tag == SettingsHelper.Settings.UIProperties.UserLanguage)
{
LanguageBox.SelectedIndex = i;
break;
}
}
};
};
}
}

0 comments on commit 4f31973

Please sign in to comment.