Exemplo n.º 1
0
 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.Location    = p;
         toolTip.Description = text;
         toolTip.HideOnClick = true;
         toolTip.Show();
     }
     oldToolTip = text;
 }
Exemplo n.º 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;
 }
 void SetToolTip(string text, int lineNumber)
 {
     try
     {
         if (toolTip == null || toolTip.IsDisposed)
         {
             toolTip = new DeclarationViewWindow(this.FindForm());
         }
         if (toolTip.Owner == null)
         {
             System.Diagnostics.Debug.WriteLine("in TextArea.SetToolTip, toolTip.Owner  was null");
         }
         else if (toolTip.Owner.InvokeRequired)
         {
             System.Diagnostics.Debug.WriteLine("in TextArea.SetToolTip, aborting method due to CrossThread Problem");
         }
         else
         {
             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);
                 var form = this.FindForm(); // DC
                 if (form.InvokeRequired || toolTip.Owner.InvokeRequired)
                 {
                     System.Diagnostics.Debug.WriteLine("in TextArea.SetToolTip, aborting method due to CrossThread Problem");
                 }
                 else
                 {
                     toolTip.Owner       = form; // this.FindForm();
                     toolTip.Location    = p;
                     toolTip.Description = text;
                     toolTip.HideOnClick = true;
                     toolTip.Show();
                 }
             }
             oldToolTip = text;
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception in TextArea.SetToolTip: {0}" + ex.Message);
     }
 }
Exemplo n.º 4
0
 protected override void OnClosed(EventArgs e)
 {
     base.OnClosed(e);
     Dispose();
     codeCompletionListView.Dispose();
     codeCompletionListView = null;
     declarationViewWindow.Dispose();
     declarationViewWindow = null;
 }
Exemplo n.º 5
0
        public static void ToolTipService_TextAreaToolTipRequest(object sender, ToolTipRequestEventArgs e)
        {
            if (!VisualPABCSingleton.MainForm.UserOptions.CodeCompletionHint)
            {
                return;
            }
            if (CodeCompletion.CodeCompletionController.CurrentParser == null)
            {
                return;
            }
            try
            {
                TextArea textArea = sender as TextArea;
                if (dvw != null && dvw.Description != null)
                {
                    hideToolTip();
                    return;
                }
                if (e.ToolTipShown && dvw != null)
                {
                    hideToolTip();
                    return;
                }
                if (e.InDocument)
                {
                    if (dvw == null)
                    {
                        dvw      = new DeclarationWindow(VisualPABCSingleton.MainForm);
                        dvw.Font = new System.Drawing.Font(Constants.CompletionWindowDeclarationViewWindowFontName, dvw.Font.Size);

                        dvw.HideOnClick = true;
                        //dvw.ShowDeclarationViewWindow();
                    }
                    int ypos = (textArea.Document.GetVisibleLine(e.LogicalPosition.Y) + 1) * textArea.TextView.FontHeight - textArea.VirtualTop.Y;
                    System.Drawing.Point p = new System.Drawing.Point(0, ypos);
                    p    = textArea.PointToScreen(p);
                    p.X  = Control.MousePosition.X + 3;
                    p.Y += 5;
                    string txt = GetPopupHintText(textArea, e);
                    dvw.Location    = choose_location(p, txt);
                    dvw.Description = txt;

                    _hint_hide_d   = dvw.Font.Height / 2;
                    _mouse_hint_x  = e.MousePosition.X;
                    _mouse_hint_y  = e.MousePosition.Y;
                    toolTipVisible = true;
                }
            }
            catch (System.Exception ex)
            {
                //VisualPABCSingleton.MainForm.WriteToOutputBox(ex.Message);// ICSharpCode.Core.MessageService.ShowError(ex);
            }
            finally
            {
            }
        }
Exemplo n.º 6
0
        AutoCompleteWindow(ICompletionDataProvider completionDataProvider, Form parentForm, TextEditorControl control, string fileName, bool showDeclarationWindow)
            : base(parentForm, control)
        {
            this.showDeclarationWindow = showDeclarationWindow;

            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 > 10)
            {
                vScrollBar.Dock        = DockStyle.Right;
                vScrollBar.Minimum     = 0;
                vScrollBar.Maximum     = completionData.Length - 8;
                vScrollBar.SmallChange = 1;
                vScrollBar.LargeChange = 3;
                codeCompletionListView.FirstItemChanged += new EventHandler(CodeCompletionListViewFirstItemChanged);
                Controls.Add(vScrollBar);
            }

            this.drawingSize = GetListViewSize();
            SetLocation();

            declarationViewWindow = new DeclarationViewWindow(parentForm);
            SetDeclarationViewLocation();
            declarationViewWindow.ShowDeclarationViewWindow();
            control.Focus();
            CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty);

            if (completionDataProvider.DefaultIndex >= 0)
            {
                codeCompletionListView.SelectIndex(completionDataProvider.DefaultIndex);
            }

            if (completionDataProvider.PreSelection != null)
            {
                CaretOffsetChanged(this, EventArgs.Empty);
            }

            vScrollBar.Scroll += new ScrollEventHandler(DoScroll);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Default AltoListControl constructor.
        /// </summary>
        public AutoListForm(Control Owner)
        {
            this.ParentControl = Owner;
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();
            //SetStyle(ControlStyles.ContainerControl  ,false);
            SetStyle(ControlStyles.Selectable, true);
            declaration             = new DeclarationViewWindow(this);
            declaration.HideOnClick = true;
            //TooltipMaxWidth(300);

            // TODO: Add any initialization after the InitForm call
        }
Exemplo n.º 8
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         control.Document.DocumentAboutToBeChanged -= DocumentAboutToBeChanged;
         if (ListView != null)
         {
             ListView.Dispose();
             ListView = null;
         }
         if (DeclarationViewWindow != null)
         {
             DeclarationViewWindow.Dispose();
             DeclarationViewWindow = null;
         }
     }
     base.Dispose(disposing);
 }
Exemplo n.º 9
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         document.DocumentAboutToBeChanged -= DocumentAboutToBeChanged;
         document.DocumentChanged          -= DocumentDocumentChanged;
         if (codeCompletionListView != null)
         {
             codeCompletionListView.Dispose();
             codeCompletionListView = null;
         }
         if (declarationViewWindow != null)
         {
             declarationViewWindow.Dispose();
             declarationViewWindow = null;
         }
     }
     base.Dispose(disposing);
 }
Exemplo n.º 10
0
        //protected virtual string Filename { get; set; }
        protected CompletionWindow(Form parentForm, TextEditorControl control) : base(parentForm, control)
        {
            DoubleBuffered = true;
            _scrollBar     = new VScrollBar
            {
                Minimum     = 0,
                Dock        = DockStyle.Right,
                SmallChange = 1,
                LargeChange = MaxListLength,
                //Width = 8, // TODO: Create custom scroll bar with overriding OnPaint method
            };
            _scrollBar.ValueChanged += VScrollBarValueChanged;
            Controls.Add(_scrollBar);
            MouseWheel           += (s, e) => HandleMouseWheel(e);
            DeclarationViewWindow = new DeclarationViewWindow(parentForm);
            SetDeclarationViewLocation();
            DeclarationViewWindow.ShowDeclarationViewWindow();
            DeclarationViewWindow.MouseMove += ControlMouseMove;

            control.Document.DocumentAboutToBeChanged += DocumentAboutToBeChanged;
        }
Exemplo n.º 11
0
        CodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth, int startOffset, int endOffset)
            : base(parentForm, control)
        {
            dataProvider               = completionDataProvider;
            this.completionData        = completionData;
            document                   = control.Document;
            this.showDeclarationWindow = showDeclarationWindow;
            this.fixedListViewWidth    = fixedListViewWidth;

            workingScreen    = Screen.GetWorkingArea(Location);
            this.startOffset = startOffset;
            if (startOffset == -1)
            {
                this.startOffset = control.ActiveTextAreaControl.Caret.Offset + 1;
            }
            this.endOffset = endOffset;
            if (this.endOffset == -1)
            {
                this.endOffset = startOffset;
            }
            if (completionDataProvider.PreSelection != null)
            {
                this.startOffset -= completionDataProvider.PreSelection.Length + 1;
                this.endOffset--;
            }

            codeCompletionListView                      = new CodeCompletionListView(completionData);
            codeCompletionListView.ImageList            = completionDataProvider.ImageList;
            codeCompletionListView.Dock                 = DockStyle.Fill;
            codeCompletionListView.SelectedItemChanged += CodeCompletionListViewSelectedItemChanged;
            codeCompletionListView.DoubleClick         += CodeCompletionListViewDoubleClick;
            codeCompletionListView.Click               += 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 += CodeCompletionListViewFirstItemChanged;
                Controls.Add(vScrollBar);
            }

            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;
            document.DocumentChanged          += DocumentDocumentChanged;
        }