Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit max entries shown in MSFS 2020 preset combo box #1810

Merged
merged 4 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ProjectMessages/ProjectMessages.Designer.cs

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

6 changes: 6 additions & 0 deletions ProjectMessages/ProjectMessages.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -679,4 +679,10 @@ 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: 4 additions & 0 deletions ProjectMessages/ProjectMessages.resx
Original file line number Diff line number Diff line change
Expand Up @@ -644,4 +644,8 @@ 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>
3 changes: 1 addition & 2 deletions UI/Panels/Config/HubHopPresetPanel.Designer.cs

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

21 changes: 15 additions & 6 deletions UI/Panels/Config/HubHopPresetPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private void _loadPresets()
try
{
PresetList.Load(PresetFile);
FilterPresetList();
FilterPresetListDelayedByMs(20);
}
catch (Exception e)
{
Expand Down Expand Up @@ -590,6 +590,7 @@ private void UpdatePresetComboBoxValues()
{
String SelectedValue = null;
Msfs2020HubhopPreset selectedPreset = null;
int maxItemsCombobox = 1500;

PresetComboBox.SelectedIndexChanged -= PresetComboBox_SelectedIndexChanged;
if (PresetComboBox.SelectedIndex > 0)
Expand All @@ -601,20 +602,29 @@ private void UpdatePresetComboBoxValues()
FilteredPresetList.Items.Add(selectedPreset);
}
}

PresetComboBox.DataSource = null;
PresetComboBox.DataSource = FilteredPresetList.Items;
if (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);
}
else
{
PresetComboBox.DataSource = FilteredPresetList.Items;
}

PresetComboBox.ValueMember = "id";
PresetComboBox.DisplayMember = "label";

if (SelectedValue != null)
{
{
PresetComboBox.SelectedValue = SelectedValue;

// we didn't find the preset within the current
// list
if (PresetComboBox.SelectedValue == null)
PresetComboBox.SelectedIndex = 0;
PresetComboBox.SelectedIndex = 0;
}
else
{
Expand All @@ -625,7 +635,6 @@ private void UpdatePresetComboBoxValues()

PresetComboBox.SelectedIndexChanged += PresetComboBox_SelectedIndexChanged;
}

private void UpdateValues(ComboBox cb, String[] valueList)
{
String SelectedValue = null;
Expand Down
Loading