From 7161d3b86fee7f487034c61f892d947dd0475a78 Mon Sep 17 00:00:00 2001 From: Koseng <26673978+Koseng@users.noreply.github.com> Date: Thu, 8 Aug 2024 20:49:24 +0200 Subject: [PATCH] Load all items end of ComboBox --- ProjectMessages/ProjectMessages.Designer.cs | 10 ------ ProjectMessages/ProjectMessages.de.resx | 6 ---- ProjectMessages/ProjectMessages.resx | 4 --- UI/Panels/Config/HubHopPresetPanel.cs | 35 ++++++++++++--------- 4 files changed, 21 insertions(+), 34 deletions(-) diff --git a/ProjectMessages/ProjectMessages.Designer.cs b/ProjectMessages/ProjectMessages.Designer.cs index 0e1cef8e..b8143752 100644 --- a/ProjectMessages/ProjectMessages.Designer.cs +++ b/ProjectMessages/ProjectMessages.Designer.cs @@ -826,16 +826,6 @@ internal static string uiMessageHubHopAutoUpdate { } } - /// - /// Looks up a localized string similar to Max {0} of {1} shown. - ///Please extend filter.. - /// - internal static string uiMessageHubHopPanelMaxItems { - get { - return ResourceManager.GetString("uiMessageHubHopPanelMaxItems", resourceCulture); - } - } - /// /// Looks up a localized string similar to Error on downloading HubHop presets. Please check the Log for more information.. /// diff --git a/ProjectMessages/ProjectMessages.de.resx b/ProjectMessages/ProjectMessages.de.resx index b0fa607a..6d1ccced 100644 --- a/ProjectMessages/ProjectMessages.de.resx +++ b/ProjectMessages/ProjectMessages.de.resx @@ -679,10 +679,4 @@ Tip: Save the file after opening to update the associated board for future use.< Es sind nicht genug Pins frei, um die Auto-Zero Funktion zu nutzen. There are not enough pins available to use the auto-zero option. - - Max {0} von {1} angezeigt. -Bitte Filter erweitern. - Max {0} of {1} shown. -Please extend filter. - \ No newline at end of file diff --git a/ProjectMessages/ProjectMessages.resx b/ProjectMessages/ProjectMessages.resx index 52908e06..0dbd66b9 100644 --- a/ProjectMessages/ProjectMessages.resx +++ b/ProjectMessages/ProjectMessages.resx @@ -644,8 +644,4 @@ Tip: Save the file after opening to update the associated board for future use.< There are not enough pins available to use the auto-zero option. - - Max {0} of {1} shown. -Please extend filter. - \ No newline at end of file diff --git a/UI/Panels/Config/HubHopPresetPanel.cs b/UI/Panels/Config/HubHopPresetPanel.cs index cfbcc667..3a09f125 100644 --- a/UI/Panels/Config/HubHopPresetPanel.cs +++ b/UI/Panels/Config/HubHopPresetPanel.cs @@ -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 @@ -207,7 +200,7 @@ private void _loadPresets() try { PresetList.Load(PresetFile); - FilterPresetListDelayedByMs(20); + FilterPresetList(); } catch (Exception e) { @@ -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(); @@ -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; @@ -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 {