示例#1
0
        protected override void OnLayout(LayoutEventArgs levent)
        {
            base.OnLayout(levent);

            int bordersize = (!BorderColor.IsFullyTransparent()) ? 3 : 0;

            int textboxclienth = ClientRectangle.Height - bordersize * 2;       // border is within Client area
            int linesinbox     = EstimateLinesInBox(textboxclienth);

            int firstVisibleLine = unchecked ((int)(long)TextBox.SendMessage(EM.GETFIRSTVISIBLELINE, IntPtr.Zero, IntPtr.Zero));

            ScrollBar.SetValueMaximumLargeChange(firstVisibleLine, LineCount - 1, linesinbox);

            visibleonlayout = ScrollBar.IsScrollBarOn || DesignMode || !HideScrollBar;  // Hide must be on, or in design mode, or scroll bar is on due to values

            TextBox.Location = new Point(bordersize, bordersize);
            TextBox.Size     = new Size(ClientRectangle.Width - (visibleonlayout ? ScrollBarWidth : 0) - bordersize * 2, textboxclienth);

            //System.Diagnostics.Debug.WriteLine("text box size " + textboxclienth + " Lines " + linesinbox );

            ScrollBar.Location = new Point(ClientRectangle.Width - ScrollBarWidth - bordersize, bordersize);
            ScrollBar.Size     = new Size(ScrollBarWidth, textboxclienth);

            //System.Diagnostics.Debug.WriteLine("layout Scroll State Lines: " + LineCount + " FVL: " + firstVisibleLine + " textlines " + textboxlinesestimate);
        }
        private void UpdateScrollBar()            // from the richtext, vscroll occurred, set the scroll bar
        {
            int firstVisibleLine = unchecked ((int)(long)TextBox.SendMessage(EM.GETFIRSTVISIBLELINE, IntPtr.Zero, IntPtr.Zero));

            ScrollBar.SetValueMaximumLargeChange(firstVisibleLine, LineCount - 1, visiblelines);
            if (ScrollBar.IsScrollBarOn != scrollbarvisibleonlayout)     // need to relayout if scroll bars pop on
            {
                PerformLayout();
            }
        }
示例#3
0
        private void UpdateVscroll()            // from the richtext, set the scroll bar
        {
            int firstVisibleLine = unchecked ((int)(long)TextBox.SendMessage(EM_GETFIRSTVISIBLELINE, (IntPtr)0, (IntPtr)0));
            int linecount        = unchecked ((int)(long)TextBox.SendMessage(EM_GETLINECOUNT, (IntPtr)0, (IntPtr)0));

            //Console.WriteLine("Scroll State Lines: " + linecount + " FVL: " + firstVisibleLine + " textlines " + textboxlinesestimate );
            ScrollBar.SetValueMaximumLargeChange(firstVisibleLine, linecount - 1, textboxlinesestimate);

            if (ScrollBar.IsScrollBarOn != visibleonlayout)     // need to relayout if scroll bars pop on
            {
                PerformLayout();
            }
        }
        private void UpdateScrollBar()            // from the richtext, vscroll occurred, set the scroll bar
        {
            int firstVisibleLine;

            if (Environment.OSVersion.Platform != PlatformID.Win32NT)
            {
                int firstVisibleChar = TextBox.GetCharIndexFromPosition(new Point(0, 0));
                firstVisibleLine = TextBox.GetLineFromCharIndex(firstVisibleChar);
                //System.Diagnostics.Debug.WriteLine("USB first VL:" + firstVisibleLine + " lines " + LineCount + " " + visiblelines );
            }
            else
            {
                firstVisibleLine = unchecked ((int)(long)TextBox.SendMessage(EM.GETFIRSTVISIBLELINE, IntPtr.Zero, IntPtr.Zero));
            }

            ScrollBar.SetValueMaximumLargeChange(firstVisibleLine, LineCount - 1, visiblelines);
            if (ScrollBar.IsScrollBarOn != scrollbarvisibleonlayout)     // need to relayout if scroll bars pop on
            {
                PerformLayout();
            }
        }