/// <summary>
 /// Disposes of the resources (other than memory) used by the <see cref="T:System.Windows.Forms.Form"/>.
 /// </summary>
 /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         _document.DocumentAboutToBeChanged -= DocumentAboutToBeChanged;
         if (_completionListView != null)
         {
             _completionListView.Dispose();
             _completionListView = null;
         }
         if (_declarationViewWindow != null)
         {
             _declarationViewWindow.Dispose();
             _declarationViewWindow = null;
         }
     }
     base.Dispose(disposing);
 }
예제 #2
0
 void SetToolTip(string text, int lineNumber)
 {
     if (_toolTip == null || _toolTip.IsDisposed)
     _toolTip = new DeclarationViewWindow(FindForm());
       if (_oldToolTip == text)
     return;
       if (text == null)
       {
     _toolTip.Hide();
       }
       else
       {
     Point p = MousePosition;
     Point cp = PointToClient(p);
     if (lineNumber >= 0)
     {
       lineNumber = Document.GetVisibleLine(lineNumber);
       p.Y = (p.Y - cp.Y) + (lineNumber * TextView.LineHeight) - _virtualTop.Y;
     }
     p.Offset(3, 3);
     _toolTip.Location = p;
     _toolTip.Description = text;
     _toolTip.HideOnClick = true;
     _toolTip.Show();
       }
       _oldToolTip = text;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="CompletionWindow"/> class.
        /// </summary>
        /// <param name="completionDataProvider">The completion data provider.</param>
        /// <param name="completionData">The completion data.</param>
        /// <param name="parentForm">The parent form.</param>
        /// <param name="control">The text editor control.</param>
        /// <param name="showDeclarationWindow"><c>true</c> to show declaration window; otherwise <c>false</c>.</param>
        /// <param name="fixedListViewWidth"><c>true</c> to use a fixed width in the list view.</param>
        /// <param name="closeAutomatically"><c>true</c> to close the completion window automatically.</param>
        CompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth, bool closeAutomatically)
            : base(parentForm, control)
        {
            _dataProvider          = completionDataProvider;
            _completionData        = completionData;
            _document              = control.Document;
            _showDeclarationWindow = showDeclarationWindow;
            _fixedListViewWidth    = fixedListViewWidth;
            _closeAutomatically    = closeAutomatically;

            int caretOffset = control.ActiveTextAreaControl.Caret.Offset;

            _startOffset = caretOffset;
            _endOffset   = caretOffset;

            // Move start offset if something is pre-selected.
            if (!String.IsNullOrEmpty(completionDataProvider.PreSelection))
            {
                _startOffset -= completionDataProvider.PreSelection.Length;
            }

            _completionListView                      = new CompletionListView(completionData);
            _completionListView.Dock                 = DockStyle.Fill;
            _completionListView.FilterList           = true;
            _completionListView.ImageList            = completionDataProvider.ImageList;
            _completionListView.Click               += CompletionListViewClick;
            _completionListView.DoubleClick         += CompletionListViewDoubleClick;
            _completionListView.FirstItemChanged    += CompletionListViewFirstItemChanged;
            _completionListView.ItemCountChanged    += CompletionListViewItemCountChanged;
            _completionListView.SelectedItemChanged += CompletionListViewSelectedItemChanged;
            Controls.Add(_completionListView);

            _vScrollBar             = new VScrollBar();
            _vScrollBar.SmallChange = 1;
            _vScrollBar.LargeChange = _maxListLength;
            _vScrollBar.Dock        = DockStyle.Right;
            Controls.Add(_vScrollBar);
            UpdateScrollBar();

            _workingScreen = Screen.GetWorkingArea(Location);
            DrawingSize    = GetListViewSize();
            _textLocation  = TextEditorControl.ActiveTextAreaControl.TextArea.Caret.Position;
            SetLocation(_textLocation);

            if (_declarationViewWindow == null)
            {
                _declarationViewWindow = new DeclarationViewWindow(parentForm);
            }

            SetDeclarationViewLocation();
            _declarationViewWindow.Show();
            _declarationViewWindow.MouseMove += ControlMouseMove;
            control.Focus();
            CompletionListViewSelectedItemChanged(this, EventArgs.Empty);

            if (!String.IsNullOrEmpty(completionDataProvider.PreSelection))
            {
                // Select item based on pre-selection.
                CaretOffsetChanged(this, EventArgs.Empty);
            }
            else if (completionDataProvider.DefaultIndex >= 0)
            {
                // Select default item
                _completionListView.SelectItem(completionDataProvider.DefaultIndex);
            }

            _vScrollBar.ValueChanged           += VScrollBarValueChanged;
            _document.DocumentAboutToBeChanged += DocumentAboutToBeChanged;
        }
    /// <summary>
    /// Initializes a new instance of the <see cref="CompletionWindow"/> class.
    /// </summary>
    /// <param name="completionDataProvider">The completion data provider.</param>
    /// <param name="completionData">The completion data.</param>
    /// <param name="parentForm">The parent form.</param>
    /// <param name="control">The text editor control.</param>
    /// <param name="showDeclarationWindow"><see langword="true"/> to show declaration window; otherwise <see langword="false"/>.</param>
    /// <param name="fixedListViewWidth"><see langword="true"/> to use a fixed width in the list view.</param>
    /// <param name="closeAutomatically"><see langword="true"/> to close the completion window automatically.</param>
    CompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth, bool closeAutomatically)
      : base(parentForm, control)
    {
      _dataProvider = completionDataProvider;
      _completionData = completionData;
      _document = control.Document;
      _showDeclarationWindow = showDeclarationWindow;
      _fixedListViewWidth = fixedListViewWidth;
      _closeAutomatically = closeAutomatically;

      int caretOffset = control.ActiveTextAreaControl.Caret.Offset;
      _startOffset = caretOffset;
      _endOffset = caretOffset;

      // Move start offset if something is pre-selected.
      if (!String.IsNullOrEmpty(completionDataProvider.PreSelection))
        _startOffset -= completionDataProvider.PreSelection.Length;

      _completionListView = new CompletionListView(completionData);
      _completionListView.Dock = DockStyle.Fill;
      _completionListView.FilterList = true;
      _completionListView.ImageList = completionDataProvider.ImageList;
      _completionListView.Click += CompletionListViewClick;
      _completionListView.DoubleClick += CompletionListViewDoubleClick;
      _completionListView.FirstItemChanged += CompletionListViewFirstItemChanged;
      _completionListView.ItemCountChanged += CompletionListViewItemCountChanged;
      _completionListView.SelectedItemChanged += CompletionListViewSelectedItemChanged;
      Controls.Add(_completionListView);

      _vScrollBar = new VScrollBar();
      _vScrollBar.SmallChange = 1;
      _vScrollBar.LargeChange = _maxListLength;
      _vScrollBar.Dock = DockStyle.Right;
      Controls.Add(_vScrollBar);
      UpdateScrollBar();

      _workingScreen = Screen.GetWorkingArea(Location);
      DrawingSize = GetListViewSize();
      _textLocation = TextEditorControl.ActiveTextAreaControl.TextArea.Caret.Position;
      SetLocation(_textLocation);

      if (_declarationViewWindow == null)
        _declarationViewWindow = new DeclarationViewWindow(parentForm);

      SetDeclarationViewLocation();
      _declarationViewWindow.Show();
      _declarationViewWindow.MouseMove += ControlMouseMove;
      control.Focus();
      CompletionListViewSelectedItemChanged(this, EventArgs.Empty);

      if (!String.IsNullOrEmpty(completionDataProvider.PreSelection))
      {
        // Select item based on pre-selection.
        CaretOffsetChanged(this, EventArgs.Empty);
      }
      else if (completionDataProvider.DefaultIndex >= 0)
      {
        // Select default item
        _completionListView.SelectItem(completionDataProvider.DefaultIndex);
      }

      _vScrollBar.ValueChanged += VScrollBarValueChanged;
      _document.DocumentAboutToBeChanged += DocumentAboutToBeChanged;
    }
 /// <summary>
 /// Disposes of the resources (other than memory) used by the <see cref="T:System.Windows.Forms.Form"/>.
 /// </summary>
 /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
 protected override void Dispose(bool disposing)
 {
   if (disposing)
   {
     _document.DocumentAboutToBeChanged -= DocumentAboutToBeChanged;
     if (_completionListView != null)
     {
       _completionListView.Dispose();
       _completionListView = null;
     }
     if (_declarationViewWindow != null)
     {
       _declarationViewWindow.Dispose();
       _declarationViewWindow = null;
     }
   }
   base.Dispose(disposing);
 }