public AutoCompleteForm(TextView view, TextControl owner, TextBufferLocation location, ITextAutoCompletionList list) { this.InitializeComponent(); this._pickedItem = string.Empty; this._list = list; foreach (TextAutoCompletionItem item in list.Items) { this._itemList.Items.Add(item); } this._view = view; this._nextHandler = this._view.AddCommandHandler(this); this._owner = owner; if (location.ColumnIndex == location.Line.Length) { this._startLocation = location.Clone(); } else { using (TextBufferSpan span = this._view.GetWordSpan(location)) { this._startLocation = span.Start.Clone(); } } this._timer = new Timer(); this._timer.Interval = 500; this._timer.Tick += new EventHandler(this.OnTimerTick); }
public void ShowAutoComplete(ITextAutoCompletionList list) { if (this._autoCompleteForm == null) { this._autoCompleteForm = new AutoCompleteForm(this, this._owner, this._location, list); int x = (((this._fontWidth * (this.GetViewIndex(this._location) - this.ViewLeftIndex)) + this.MarginPadding) + this.MarginWidth) + this._lineNumbersWidth; int y = ((this._location.LineIndex + 1) - this.ViewTopLineNumber) * this._fontHeight; this._autoCompleteForm.TopLevel = false; this._autoCompleteForm.Parent = this; if ((this._autoCompleteForm.Height + y) > base.Height) { y = (y - this._autoCompleteForm.Height) - this._fontHeight; if (y < 0) { this._autoCompleteForm = null; return; } } if ((this._autoCompleteForm.Width + x) > base.Width) { x -= this._autoCompleteForm.Width; if (x < 0) { this._autoCompleteForm = null; return; } } this._autoCompleteForm.Location = new Point(x, y); this._autoCompleteForm.Closed += new EventHandler(this.OnAutoCompleteFormClosed); this._autoCompleteForm.Show(); this._owner.Focus(); } this.AddCommandHandler(this._autoCompleteForm); }