bool Filter(CommandItem item) { if (item.Command == "") { return(false); } string searchText = SearchControl.SearchTextBox.Text.ToLower(); if (searchText == "" || searchText == "?") { return(true); } if (searchText.Length == 1) { return(item.Input.ToLower().Replace("ctrl+", "").Replace("shift+", "").Replace("alt+", "") == searchText.ToLower()); } else if (searchText.StartsWith("i ") || searchText.StartsWith("i:") || searchText.Length == 1) { if (searchText.Length > 1) { searchText = searchText.Substring(2).Trim(); } if (searchText.Length < 3) { return(item.Input.ToLower().Replace("ctrl+", "").Replace("shift+", "").Replace("alt+", "").Contains(searchText)); } else { return(item.Input.ToLower().Contains(searchText)); } } else if (searchText.StartsWith("m ") || searchText.StartsWith("m:")) { return(item.Path.ToLower().Contains(searchText.Substring(2).Trim())); } else if (searchText.StartsWith("c ") || searchText.StartsWith("c:")) { return(item.Command.ToLower().Contains(searchText.Substring(2).Trim())); } else if (item.Command.ToLower().Contains(searchText) || item.Path.ToLower().Contains(searchText) || item.Input.ToLower().Contains(searchText)) { return(true); } return(false); }
public void BuildMenu() { string content = File.ReadAllText(core.InputConfPath); var items = CommandItem.GetItems(content); if (!content.Contains("#menu:")) { var defaultItems = CommandItem.GetItems(Properties.Resources.input_conf); foreach (CommandItem item in items) { foreach (CommandItem defaultItem in defaultItems) { if (item.Command == defaultItem.Command) { defaultItem.Input = item.Input; } } } items = defaultItems; } foreach (CommandItem item in items) { if (string.IsNullOrEmpty(item.Path)) { continue; } string path = item.Path.Replace("&", "&&"); MenuItem menuItem = ContextMenu.Add(path, () => { try { core.command(item.Command); } catch (Exception ex) { Msg.ShowException(ex); } }); if (menuItem != null) { menuItem.ShortcutKeyDisplayString = item.Input + " "; } } }
bool Filter(CommandItem item) { if (item.Command == "" || item.Path == "") { return(false); } string filter = FilterTextBox.Text.ToLower(); if (filter == "") { return(true); } if (item.Command.ToLower().Contains(filter) || item.Input.ToLower().Contains(filter) || item.Path.ToLower().Contains(filter)) { return(true); } return(false); }
void ButtonClick(object sender, RoutedEventArgs e) { CommandItem item = ((Button)e.Source).DataContext as CommandItem; if (item is null) { return; } LearnWindow w = new LearnWindow(); w.Owner = this; w.InputItem = item; w.ShowDialog(); var items = new Dictionary <string, CommandItem>(); foreach (CommandItem i in CommandItem.Items) { items[i.Input] = i; } }