From ff548105c33b9316c2e38a8c98102fd1758ade52 Mon Sep 17 00:00:00 2001 From: pongo1231 Date: Mon, 13 Nov 2023 01:34:24 +0000 Subject: [PATCH] ConfigApp: Add toggle for sorting workshop items by installed first Allows users to turn that behaviour off --- ConfigApp/Tabs/WorkshopTab.cs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ConfigApp/Tabs/WorkshopTab.cs b/ConfigApp/Tabs/WorkshopTab.cs index 84a370ce3..1c397a0ab 100644 --- a/ConfigApp/Tabs/WorkshopTab.cs +++ b/ConfigApp/Tabs/WorkshopTab.cs @@ -35,7 +35,9 @@ enum SortingMode private ObservableCollection m_WorkshopSubmissionItems = new ObservableCollection(); + private CheckBox m_SortIntalledFirstToggle; private WatermarkTextBox m_SearchBox; + private ItemsControl m_ItemsControl; private void SortSubmissionItems() @@ -57,7 +59,12 @@ private void SortSubmissionItems() throw new NotImplementedException(); } - m_WorkshopSubmissionItems = new ObservableCollection(items.OrderBy(item => item.InstallState)); + if (m_SortIntalledFirstToggle.IsChecked.GetValueOrDefault(true)) + { + items = items.OrderBy(item => item.InstallState); + } + + m_WorkshopSubmissionItems = new ObservableCollection(items); m_ItemsControl.ItemsSource = m_WorkshopSubmissionItems; } @@ -301,6 +308,7 @@ protected override void InitContent() var sortingModeBox = new ComboBox() { HorizontalAlignment = HorizontalAlignment.Left, + Width = 100f, Margin = new Thickness(55f, 0f, 0f, 0f), ItemsSource = m_SortingModeLabels.Values, SelectedIndex = 0 @@ -308,6 +316,17 @@ protected override void InitContent() sortingModeBox.SelectionChanged += OnSortingModeBoxSelectionChanged; headerGrid.Children.Add(sortingModeBox); + m_SortIntalledFirstToggle = new CheckBox() + { + HorizontalAlignment = HorizontalAlignment.Left, + VerticalAlignment = VerticalAlignment.Center, + Margin = new Thickness(165f, 0f, 0f, 0f), + IsChecked = true, + Content = "Show installed first" + }; + m_SortIntalledFirstToggle.Click += (sender, eventArgs) => { SortSubmissionItems(); }; + headerGrid.Children.Add(m_SortIntalledFirstToggle); + m_SearchBox = new WatermarkTextBox() { HorizontalAlignment = HorizontalAlignment.Right,