CodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth) : base(parentForm, control) { this.dataProvider = completionDataProvider; this.completionData = completionData; this.document = control.Document; this.showDeclarationWindow = showDeclarationWindow; this.fixedListViewWidth = fixedListViewWidth; workingScreen = Screen.GetWorkingArea(Location); startOffset = control.ActiveTextAreaControl.Caret.Offset + 1; endOffset = startOffset; if (completionDataProvider.PreSelection != null) { startOffset -= completionDataProvider.PreSelection.Length + 1; endOffset--; } codeCompletionListView = new CodeCompletionListView(completionData); codeCompletionListView.ImageList = completionDataProvider.ImageList; codeCompletionListView.Dock = DockStyle.Fill; codeCompletionListView.SelectedItemChanged += new EventHandler(CodeCompletionListViewSelectedItemChanged); codeCompletionListView.DoubleClick += new EventHandler(CodeCompletionListViewDoubleClick); codeCompletionListView.Click += new EventHandler(CodeCompletionListViewClick); Controls.Add(codeCompletionListView); if (completionData.Length > MaxListLength) { vScrollBar.Dock = DockStyle.Right; vScrollBar.Minimum = 0; vScrollBar.Maximum = completionData.Length - 1; vScrollBar.SmallChange = 1; vScrollBar.LargeChange = MaxListLength; codeCompletionListView.FirstItemChanged += new EventHandler(CodeCompletionListViewFirstItemChanged); Controls.Add(vScrollBar); } this.drawingSize = GetListViewSize(); SetLocation(); if (declarationViewWindow == null) { declarationViewWindow = new DeclarationViewWindow(parentForm); } SetDeclarationViewLocation(); declarationViewWindow.ShowDeclarationViewWindow(); declarationViewWindow.MouseMove += ControlMouseMove; control.Focus(); CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty); if (completionDataProvider.DefaultIndex >= 0) { codeCompletionListView.SelectIndex(completionDataProvider.DefaultIndex); } if (completionDataProvider.PreSelection != null) { CaretOffsetChanged(this, EventArgs.Empty); } vScrollBar.ValueChanged += VScrollBarValueChanged; document.DocumentAboutToBeChanged += DocumentAboutToBeChanged; }
void SetToolTip(string text, int lineNumber) { if (toolTip == null || toolTip.IsDisposed) toolTip = new DeclarationViewWindow(this.FindForm()); if (oldToolTip == text) return; if (text == null) { toolTip.Hide(); } else { Point p = Control.MousePosition; Point cp = PointToClient(p); if (lineNumber >= 0) { lineNumber = this.Document.GetVisibleLine(lineNumber); p.Y = (p.Y - cp.Y) + (lineNumber * this.TextView.FontHeight) - this.virtualTop.Y; } p.Offset(3, 3); toolTip.Owner = this.FindForm(); toolTip.Location = p; toolTip.Description = text; toolTip.HideOnClick = true; toolTip.Show(); } oldToolTip = text; }
protected override void Dispose(bool disposing) { if (disposing) { document.DocumentAboutToBeChanged -= DocumentAboutToBeChanged; if (codeCompletionListView != null) { codeCompletionListView.Dispose(); codeCompletionListView = null; } if (declarationViewWindow != null) { declarationViewWindow.Dispose(); declarationViewWindow = null; } } base.Dispose(disposing); }