public void Initialize(string text) { if (string.IsNullOrEmpty(text)) { TagsTextBox.Text = ""; } else { TagsTextBox.Text = text.Trim(); } TagsTextBox.SelectAll(); FHoverLine = -1; ScrolledLine = 0; // if (NeedsUpdate) // Redraw(); RedrawSelection(); }
public void DoKeyDown(KeyEventArgs e) { if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) { if (!e.Shift) { CreateNodeFromHoverLine(); } } else if (e.KeyCode == Keys.Escape) { OnCreateNode(null); } else if ((TagsTextBox.Lines.Length < 2) && (e.KeyCode == Keys.Down)) { FHoverLine += 1; //if this is exceeding the FSelectionList.Count -> jump to line 0 if (FHoverLine + ScrolledLine >= FSelectionList.Count) { FHoverLine = 0; ScrolledLine = 0; } //if this is exceeding the currently visible lines -> scroll down a line else if (FHoverLine >= FVisibleLines) { ScrolledLine += 1; FHoverLine = FVisibleLines - 1; } RedrawSelection(); ShowToolTip(0); } else if ((TagsTextBox.Lines.Length < 2) && (e.KeyCode == Keys.Up)) { FHoverLine -= 1; //if this is exceeding the currently visible lines -> scroll up a line if ((FHoverLine == -1) && (ScrolledLine > 0)) { ScrolledLine -= 1; FHoverLine = 0; } //if we are now < 0 -> jump to last entry else if (FHoverLine < 0) { FHoverLine = Math.Min(FSelectionList.Count, FVisibleLines) - 1; ScrolledLine = FSelectionList.Count; } RedrawSelection(); ShowToolTip(0); } else if ((e.KeyCode == Keys.Left) || (e.KeyCode == Keys.Right)) { if (FHoverLine != -1) { FHoverLine = -1; TagsTextBox.SelectionStart = TagsTextBox.Text.Length; RedrawSelection(); } } else if ((e.Control) && (e.KeyCode == Keys.A)) { TagsTextBox.SelectAll(); } }