/// <summary> /// Show a listbox with possible completions for the uncompleted string. /// When the user chooses one and presses enter (or clicks it with the mouse), /// return the chosen completion. Or, when the user presses escape, then /// close the window and return null. /// </summary> public string ShowTooltip(string uncompleted, IEnumerable <string> completions, IEnumerable <string> documentations, Point location) { _lstCompletions = new ListBox(); _lstCompletions.ScrollAlwaysVisible = true; _lstCompletions.Items.AddRange(completions.ToArray()); _lstCompletions.SelectionMode = SelectionMode.One; _lstCompletions.AutoSize = false; _lstCompletions.SelectedIndexChanged += new EventHandler(selectedIndexChanged); _lstCompletions.Click += new EventHandler(lstCompletionsClicked); int maxWidth = 0; for (int i = 0; i < _lstCompletions.Items.Count; i++) { if (_lstCompletions.GetItemRectangle(i).Width > maxWidth) { maxWidth = _lstCompletions.GetItemRectangle(i).Width; } } _lstCompletions.Width = maxWidth; if (_lstCompletions.Items.Count > 0) { _lstCompletions.Height = _lstCompletions.GetItemHeight(0) * 10; } _documentations = documentations; _lblDocumentation = new TextBox(); _lblDocumentation.WordWrap = true; _lblDocumentation.Width = _lstCompletions.Width; _lblDocumentation.BackColor = SystemColors.ControlLight; if (_documentations != null && _documentations.Count() > 0) { _lblDocumentation.Text = _documentations.ElementAt(0); } _lblDocumentation.ScrollBars = ScrollBars.Vertical; _lblDocumentation.Multiline = true; _lblDocumentation.AutoSize = true; _lblDocumentation.Height = 100; _lblDocumentation.ReadOnly = true; _dialog = new CompletionToolTipWindow(_lstCompletions, _lblDocumentation); _dialog.KeyDown += new KeyEventHandler(dialog_KeyDown); _dialog.Location = location; _dialog.KeyPreview = true; _dialog.ShowDialog(); if (_cancel || _lstCompletions.SelectedIndex < 0) { return(null); } return((string)_lstCompletions.SelectedItem); }
/// <summary> /// Show a listbox with possible completions for the uncompleted string. /// When the user chooses one and presses enter (or clicks it with the mouse), /// return the chosen completion. Or, when the user presses escape, then /// close the window and return null. /// </summary> public string ShowTooltip(string uncompleted, IEnumerable<string> completions, IEnumerable<string> documentations,Point location) { _lstCompletions = new ListBox(); _lstCompletions.ScrollAlwaysVisible = true; _lstCompletions.Items.AddRange(completions.ToArray()); _lstCompletions.SelectionMode = SelectionMode.One; _lstCompletions.AutoSize = false; _lstCompletions.SelectedIndexChanged += new EventHandler(selectedIndexChanged); _lstCompletions.Click += new EventHandler(lstCompletionsClicked); int maxWidth = 0; for (int i = 0; i < _lstCompletions.Items.Count; i++) { if (_lstCompletions.GetItemRectangle(i).Width > maxWidth) maxWidth = _lstCompletions.GetItemRectangle(i).Width; } _lstCompletions.Width = maxWidth; if (_lstCompletions.Items.Count > 0) _lstCompletions.Height = _lstCompletions.GetItemHeight(0) * 10; _documentations = documentations; _lblDocumentation = new TextBox(); _lblDocumentation.WordWrap = true; _lblDocumentation.Width = _lstCompletions.Width; _lblDocumentation.BackColor = SystemColors.ControlLight; if (_documentations!=null && _documentations.Count() > 0) _lblDocumentation.Text = _documentations.ElementAt(0); _lblDocumentation.ScrollBars = ScrollBars.Vertical; _lblDocumentation.Multiline = true; _lblDocumentation.AutoSize = true; _lblDocumentation.Height = 100; _lblDocumentation.ReadOnly = true; _dialog = new CompletionToolTipWindow(_lstCompletions,_lblDocumentation); _dialog.KeyDown += new KeyEventHandler(dialog_KeyDown); _dialog.Location = location; _dialog.KeyPreview = true; _dialog.ShowDialog(); if (_cancel || _lstCompletions.SelectedIndex < 0) return null; return (string)_lstCompletions.SelectedItem; }
/// <summary> /// Show a listbox with possible completions for the uncompleted string. /// When the user chooses one and presses enter (or clicks it with the mouse), /// return the chosen completion. Or, when the user presses escape, then /// close the window and return null. /// </summary> public string ShowTooltip(string uncompleted, IEnumerable<string> completions, Point location) { _lstCompletions = new ListBox(); _lstCompletions.ScrollAlwaysVisible = true; _lstCompletions.Items.AddRange(completions.ToArray()); _lstCompletions.SelectionMode = SelectionMode.One; _dialog = new CompletionToolTipWindow(_lstCompletions); _dialog.KeyDown += new KeyEventHandler(dialog_KeyDown); _dialog.Location = location; _dialog.KeyPreview = true; _dialog.ShowDialog(); if (_cancel || _lstCompletions.SelectedIndex < 0) { return null; } return (string)_lstCompletions.SelectedItem; }