void SearchWindow() { ImGui.Text(isSearchInfocards ? "Search Infocards" : "Search Strings"); searchBuffer.InputText("##searchtext", ImGuiInputTextFlags.None, 200); ImGui.Checkbox("Case Sensitive", ref searchCaseSensitive); ImGui.Checkbox("Match Whole World", ref searchWholeWord); if (ImGui.Button("Go")) { var str = searchBuffer.GetText(); if (!string.IsNullOrWhiteSpace(str)) { resultTitle = ImGuiExt.IDSafe($"Results for '{str}'"); dialogState = 1; Regex r; var regOptions = searchCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase; if (searchWholeWord) { r = new Regex($"\\b{Regex.Escape(str)}\\b", regOptions); } else { r = new Regex(Regex.Escape(str), regOptions); } if (isSearchInfocards) { AsyncManager.RunTask(() => { var results = new List <int>(); var resStrings = new List <string>(); foreach (var kv in manager.AllXml) { if (r.IsMatch(kv.Value)) { results.Add(kv.Key); resStrings.Add(kv.Value); } } searchResults = results.ToArray(); searchStrings = resStrings.ToArray(); searchStringPreviews = new string[searchStrings.Length]; dialogState = 2; }); } else { AsyncManager.RunTask(() => { var results = new List <int>(); var resStrings = new List <string>(); foreach (var kv in manager.AllStrings) { if (r.IsMatch(kv.Value)) { results.Add(kv.Key); resStrings.Add(kv.Value); } } searchResults = results.ToArray(); searchStrings = resStrings.ToArray(); dialogState = 2; }); } } } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } }