private static void DrawSearchInput(DictionaryGUIState state, Inspector.Options options) { if (state.searchInput == null) { state.searchInput = new SearchInputState(); } if (state.Size() < options.showSearchAtSize) { ClearSearchInput(state); return; } var now = DateTime.Now; SearchInputState input = state.searchInput; using (GUITools.Indent()) { using (GUITools.HorizontalScope()) { var newInput = GUITools.TextField("Search: ", input.text ?? ""); if (newInput != input.text) { input.text = newInput; input.lastTextChange = now; if (input.inputStart.Ticks == 0) { input.inputStart = now; } } else { if (Math.Abs((now - input.lastTextChange).TotalSeconds) > 0.5) { input.inputStart = new DateTime(); } } if (input.text != input.filter && ( input.inputStart.Ticks == 0 || Math.Abs((now - input.lastFilterChange).TotalSeconds) > 1 && Math.Abs((now - input.inputStart).TotalSeconds) > 1 )) { input.changed = true; input.filter = input.text; input.lastFilterChange = DateTime.Now; } else { input.changed = false; } } } }
private static object[] FilterKeys(object[] keys, SearchInputState search) { if (!string.IsNullOrEmpty(search.filter)) { return(keys .Where(o => o != null && o.ToString().IndexOf(search.filter, StringComparison.Ordinal) != -1) .ToArray()); } return(keys); }