public CornerLauncherMenu(Dictionary <string, MergedCommand> mergedCommands) { //this._mergedCommands = mergedCommands; this._allSyntaxesAndCommands = new Dictionary <string, Command>(); foreach (KeyValuePair <string, MergedCommand> mergedCommand in mergedCommands) { foreach (var command in mergedCommand.Value.sourceCommands) { _allSyntaxesAndCommands.Add(command.Name + " " + command.Postfix, command); } } this._suggestionsProcessor = new SuggestionsProcessor(_allSyntaxesAndCommands.Keys.ToList(), 10, false, false, null, false, false); this._guiElements = new GuiElements(); this._guiElements.lines = new List <CornerLauncherLine>(); this._formCornerLauncher = new FormCornerLauncher(this._guiElements); this._typedText = string.Empty; }
internal FormCornerLauncher(GuiElements guiElements) { this._guiElements = guiElements; InitializeComponent(); this.Visible = false; }
public CornerLauncherLine(GuiElements parentGuiElements, CornerLauncherLineKind kind, int lineIndex, string text, string typedText, bool selected) { this.parentGuiElements = parentGuiElements; this.kind = kind; this.lineIndex = lineIndex; this.typedText = typedText; this.selected = selected; this.font = new Font(FontFamily.GenericSansSerif, 30); List <int> indexesOfSelectedParts = new List <int>(); if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(typedText)) { indexesOfSelectedParts.AddRange(text.IndexesOfOccurrences(typedText, false)); } int index = 0; bool inField = false; bool inTypedPart = false; CornerLauncherCharacterKind ck; this.characters = new List <CornerLauncherCharacter>(); foreach (char c in text) { if (!inField && c == openFieldChar) { inField = true; } inTypedPart = indexesOfSelectedParts.Any(partStart => partStart <= index && index < partStart + typedText.Length); switch (kind) { case CornerLauncherLineKind.Description: if (!inField) { ck = CornerLauncherCharacterKind.DescriptionNormal; } else { ck = CornerLauncherCharacterKind.DescriptionField; } break; case CornerLauncherLineKind.Suggestion: if (!inField) { if (inTypedPart) { if (!this.selected) { ck = CornerLauncherCharacterKind.Typed; } else { ck = CornerLauncherCharacterKind.TypedSelected; } } else { ck = CornerLauncherCharacterKind.SuggestedNormal; } } else { ck = CornerLauncherCharacterKind.SuggestedField; } break; default: throw new NotImplementedException(); } this.characters.Add(new CornerLauncherCharacter(this, ck, c, index)); if (inField && c == closeFieldChar) { inField = false; } index++; } }