Skip to content

Commit

Permalink
ConfigApp: Add toggle for sorting workshop items by installed first
Browse files Browse the repository at this point in the history
Allows users to turn that behaviour off
  • Loading branch information
pongo1231 committed Nov 13, 2023
1 parent f034b32 commit ff54810
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion ConfigApp/Tabs/WorkshopTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ enum SortingMode

private ObservableCollection<WorkshopSubmissionItem> m_WorkshopSubmissionItems = new ObservableCollection<WorkshopSubmissionItem>();

private CheckBox m_SortIntalledFirstToggle;
private WatermarkTextBox m_SearchBox;

private ItemsControl m_ItemsControl;

private void SortSubmissionItems()
Expand All @@ -57,7 +59,12 @@ private void SortSubmissionItems()
throw new NotImplementedException();
}

m_WorkshopSubmissionItems = new ObservableCollection<WorkshopSubmissionItem>(items.OrderBy(item => item.InstallState));
if (m_SortIntalledFirstToggle.IsChecked.GetValueOrDefault(true))
{
items = items.OrderBy(item => item.InstallState);
}

m_WorkshopSubmissionItems = new ObservableCollection<WorkshopSubmissionItem>(items);
m_ItemsControl.ItemsSource = m_WorkshopSubmissionItems;
}

Expand Down Expand Up @@ -301,13 +308,25 @@ 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
};
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,
Expand Down

0 comments on commit ff54810

Please sign in to comment.