diff --git a/HaCreator/CustomControls/MapBrowser.cs b/HaCreator/CustomControls/MapBrowser.cs
index 55bb34a7..921ad7d2 100644
--- a/HaCreator/CustomControls/MapBrowser.cs
+++ b/HaCreator/CustomControls/MapBrowser.cs
@@ -18,6 +18,7 @@
using HaSharedLibrary.Wz;
using MapleLib.WzLib.WzStructure;
using System.Data.SQLite;
+using HaCreator.GUI.InstanceEditor;
namespace HaCreator.CustomControls
{
@@ -32,6 +33,13 @@ public partial class MapBrowser : UserControl
private bool _bTownOnlyFilter = false;
private bool _bIsHistoryMapBrowser = false;
+ private LoadSearchHelper _search;
+ public LoadSearchHelper Search
+ {
+ get { return _search; }
+ private set { }
+ }
+
///
/// Constructor
///
@@ -39,6 +47,8 @@ public MapBrowser()
{
InitializeComponent();
+ this._search = new LoadSearchHelper(mapNamesBox, maps);
+
this.minimapBox.SizeMode = PictureBoxSizeMode.Zoom;
}
@@ -232,114 +242,6 @@ public void ClearLoadedMapHistory() {
#endregion
#region UI
- private string _previousSeachText = string.Empty;
- private CancellationTokenSource _existingSearchTaskToken = null;
- ///
- /// On search box text changed
- ///
- ///
- /// May be null
- public void searchBox_TextChanged(object sender, EventArgs e)
- {
- TextBox searchBox = (TextBox)sender;
- string searchText = searchBox.Text.ToLower();
-
- if (_previousSeachText == searchText)
- return;
- _previousSeachText = searchText; // set
-
- // start searching
- searchMapsInternal(searchText);
- }
-
- ///
- /// Search and filters map according to the user's query
- ///
- ///
- public void searchMapsInternal(string searchText) {
- if (!_bMapsLoaded)
- return;
-
- // Cancel existing task if any
- if (_existingSearchTaskToken != null && !_existingSearchTaskToken.IsCancellationRequested) {
- _existingSearchTaskToken.Cancel();
- }
-
- // Clear
- mapNamesBox.Items.Clear();
- if (searchText == string.Empty) {
- var filteredItems = maps.Where(kvp => {
- MapInfo mapInfo = null;
- if (mapsMapInfo.ContainsKey(kvp)) {
- mapInfo = mapsMapInfo[kvp].Item2;
-
- if (this._bTownOnlyFilter) {
- if (!mapInfo.town)
- return false;
- }
- }
- return true;
- }).Select(kvp => kvp) // or kvp.Value or any transformation you need
- .Cast