Пример #1
0
        public frmIntellisense()
        {
            this.DoubleBuffered = true;

            values = new List <string>();

            InitializeComponent();

            vsb       = new QVScrollBar(SCROLL_BAR_WIDTH);
            vsb.Value = 0;

            this.Controls.Add(vsb);

            vsb.GotFocus   += new EventHandler(vsb_GotFocus);
            vsb.Scroll     += new ScrollEventHandler(vsb_Scroll);
            vsb.LargeChange = numVisibleItems;

            this.ClientSize = new Size(220, FontInfo.Height * 6 + 2);

            this.Font = new Font(FontInfo.FontName, 9f, FontStyle.Regular);
        }
Пример #2
0
        public QTextBox(Font Font, StringComparer Comparer)
        {
            InitializeComponent(); // NOP

            this.SuspendLayout();

            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
            this.Name = "QTextBox";

            this.DoubleBuffered = true;
            this.BackColor      = Color.White;

            FontInfo.SetFont(Font);

            ki = new KeywordInfo(comparer = Comparer);
            SubLine.SetKeywordInfo(ki);
            Line.SetKeywordInfo(ki);

            currentView = new View(new Document(4), this);
            curDoc      = currentView.Document;

            EventManager.ViewChanged += () =>
            {
                vsb.SetValue(currentView.FirstVisibleLine);
                this.Invalidate();
            };

            EventManager.DocumentChanged += () => { if (DocumentChanged != null)
                                                    {
                                                        DocumentChanged.Invoke(this, EventArgs.Empty);
                                                    }
            };
            EventManager.CaretLocationChanged += () => { if (CaretLocationChanged != null)
                                                         {
                                                             CaretLocationChanged.Invoke(currentView.CaretDocLoc);
                                                         }
            };
            EventManager.SelectionChanged += () => { if (SelectionChanged != null)
                                                     {
                                                         SelectionChanged.Invoke(this, EventArgs.Empty);
                                                     }
            };
            EventManager.NumLinesChanged    += updateMaxLinesChanged;
            EventManager.LongestLineChanged += updateForLongestLine;

            vsb = new QVScrollBar(SCROLL_BAR_WIDTH);
            this.Controls.Add(vsb);

            vsb.ValChanged += (e) =>
            {
                switch (e.Delta)
                {
                case -1:
                    if (!currentView.ScrollView(-1))
                    {
                        e.Accept = false;
                    }
                    break;

                case 1:
                    if (!currentView.ScrollView(1))
                    {
                        e.Accept = false;
                    }
                    break;

                default:
                    currentView.FirstVisibleLine = vsb.Value;
                    break;
                }
            };

            hsb = new QHScrollBar(SCROLL_BAR_WIDTH);
            this.Controls.Add(hsb);

            hsb.ValueChanged += (s, e) =>
            {
                currentView.FirstVisibleColumn = hsb.Value;
                this.Invalidate();
            };

            hsb.Visible = false;

            this.ResumeLayout(false);

            ViewEnvironment.NumColumnsPerLineChanged += setMetrics;
            FontInfo.FontMetricsChanged         += setMetrics;
            EventManager.DocumentChangedChanged += () => { if (this.DocumentChangedChanged != null)
                                                           {
                                                               DocumentChangedChanged.Invoke(this, EventArgs.Empty);
                                                           }
            };

            this.Size = new System.Drawing.Size(492, 313);
        }