Skip to content

Commit

Permalink
Load all items end of ComboBox
Browse files Browse the repository at this point in the history
  • Loading branch information
Koseng committed Aug 8, 2024
1 parent 3d9bfbf commit 7161d3b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 34 deletions.
10 changes: 0 additions & 10 deletions ProjectMessages/ProjectMessages.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions ProjectMessages/ProjectMessages.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,4 @@ Tip: Save the file after opening to update the associated board for future use.<
<value>Es sind nicht genug Pins frei, um die Auto-Zero Funktion zu nutzen.</value>
<comment>There are not enough pins available to use the auto-zero option.</comment>
</data>
<data name="uiMessageHubHopPanelMaxItems" xml:space="preserve">
<value>Max {0} von {1} angezeigt.
Bitte Filter erweitern.</value>
<comment>Max {0} of {1} shown.
Please extend filter.</comment>
</data>
</root>
4 changes: 0 additions & 4 deletions ProjectMessages/ProjectMessages.resx
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,4 @@ Tip: Save the file after opening to update the associated board for future use.<
<data name="uiMessagePanelsStepperNoFreePins" xml:space="preserve">
<value>There are not enough pins available to use the auto-zero option. </value>
</data>
<data name="uiMessageHubHopPanelMaxItems" xml:space="preserve">
<value>Max {0} of {1} shown.
Please extend filter.</value>
</data>
</root>
35 changes: 21 additions & 14 deletions UI/Panels/Config/HubHopPresetPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,10 @@
using MobiFlight.InputConfig;
using MobiFlight.OutputConfig;
using MobiFlight.UI.Forms;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MobiFlight.UI.Panels.Config
Expand Down Expand Up @@ -207,7 +200,7 @@ private void _loadPresets()
try
{
PresetList.Load(PresetFile);
FilterPresetListDelayedByMs(20);
FilterPresetList();
}
catch (Exception e)
{
Expand Down Expand Up @@ -432,6 +425,12 @@ private void PresetComboBox_SelectedIndexChanged(object sender, EventArgs e)
if ((sender as ComboBox).SelectedItem == null) return;
Msfs2020HubhopPreset selectedItem = (sender as ComboBox).SelectedItem as Msfs2020HubhopPreset;

if (selectedItem.id == "Load all")
{
UpdatePresetComboBoxValues(loadAllItems: true);
return;
}

Msfs2020HubhopPreset selectedPreset = FilteredPresetList.Items.Find(x => x.id == selectedItem.id);
if (selectedPreset == null) return;
DescriptionTextBox.Text = selectedPreset?.description?.ToCRLF();
Expand Down Expand Up @@ -583,10 +582,10 @@ private void FilteredPresetListChanged()
UpdateValues(SystemComboBox, FilteredPresetList.AllSystems(hubhopType).ToArray());
}

UpdatePresetComboBoxValues();
UpdatePresetComboBoxValues(loadAllItems: false);
}

private void UpdatePresetComboBoxValues()
private void UpdatePresetComboBoxValues(bool loadAllItems)
{
String SelectedValue = null;
Msfs2020HubhopPreset selectedPreset = null;
Expand All @@ -603,11 +602,19 @@ private void UpdatePresetComboBoxValues()
}
}
PresetComboBox.DataSource = null;
if (FilteredPresetList.Items.Count > maxItemsCombobox)
if (!loadAllItems && FilteredPresetList.Items.Count > maxItemsCombobox)
{
int MatchesFound = FilteredPresetList.Items.Count - 1;
PresetComboBox.DataSource = FilteredPresetList.Items.GetRange(0, maxItemsCombobox);
MatchLabel.Text = String.Format(i18n._tr("uiMessageHubHopPanelMaxItems"), maxItemsCombobox, MatchesFound);
var MatchesFound = FilteredPresetList.Items.Count - 1;
var presetItems = FilteredPresetList.Items.GetRange(0, maxItemsCombobox);
presetItems.Add(new Msfs2020HubhopPreset()
{
label = "====== Load all items ======",
id = "Load all",
code = "",
description = "Load all items."
});

PresetComboBox.DataSource = presetItems;
}
else
{
Expand Down

0 comments on commit 7161d3b

Please sign in to comment.