示例#1
0
        /// <summary>
        /// The actual scroll magic is here
        /// </summary>
        private void SetDisplayRectLocation(YamuiScrollHandler scroll, int deltaValue)
        {
            if (deltaValue == 0 || !scroll.HasScroll)
            {
                return;
            }

            // (found in ScrollablePanel.SetDisplayRectLocation(0, deltaVerticalValue);)
            Rectangle cr = ClientRectangle;

            WinApi.RECT rcClip   = WinApi.RECT.FromXYWH(cr.X, cr.Y, cr.Width - scroll.BarThickness, cr.Height);
            WinApi.RECT rcUpdate = WinApi.RECT.FromXYWH(cr.X, cr.Y, cr.Width - scroll.BarThickness, cr.Height);
            WinApi.ScrollWindowEx(
                new HandleRef(this, Handle),
                scroll.IsVertical ? 0 : deltaValue,
                scroll.IsVertical ? deltaValue : 0,
                null,
                ref rcClip,
                WinApi.NullHandleRef,
                ref rcUpdate,
                WinApi.ScrollWindowExFlags.SW_ERASE |
                WinApi.ScrollWindowExFlags.SW_INVALIDATE |
                WinApi.ScrollWindowExFlags.SW_SCROLLCHILDREN |
                WinApi.ScrollWindowExFlags.SW_SMOOTHSCROLL);

            UpdateChildrenBound();

            Refresh(); // not critical but help reduce flickering
        }
        /// <summary>
        /// Creates a new HtmlPanel and sets a basic css for it's styling.
        /// </summary>
        public YamuiScrollControl()
        {
            VerticalScroll = new YamuiScrollHandler(true, this)
            {
                SmallChange  = 70,
                LargeChange  = 400,
                BarThickness = ScrollBarWidth
            };
            HorizontalScroll = new YamuiScrollHandler(false, this)
            {
                SmallChange  = 70,
                LargeChange  = 400,
                BarThickness = ScrollBarWidth
            };

            VerticalScroll.OnValueChanged             += OnScrollValueChanged;
            VerticalScroll.OnScrollbarsRedrawNeeded   += OnScrollbarsRedrawNeeded;
            HorizontalScroll.OnValueChanged           += OnScrollValueChanged;
            HorizontalScroll.OnScrollbarsRedrawNeeded += OnScrollbarsRedrawNeeded;
        }
示例#3
0
        public YamuiScrollPanel()
        {
            TabStop = false;
            SetStyle(ControlStyles.Selectable, false);
            SetStyle(ControlStyles.UserMouse, true);

            VerticalScroll = new YamuiScrollHandler(true, this)
            {
                SmallChange  = 70,
                LargeChange  = 400,
                BarThickness = ScrollBarWidth
            };
            HorizontalScroll = new YamuiScrollHandler(false, this)
            {
                SmallChange  = 70,
                LargeChange  = 400,
                BarThickness = ScrollBarWidth
            };
            VerticalScroll.OnValueChanged             += ScrollOnOnValueChanged;
            VerticalScroll.OnScrollbarsRedrawNeeded   += OnScrollbarsRedrawNeeded;
            HorizontalScroll.OnValueChanged           += ScrollOnOnValueChanged;
            HorizontalScroll.OnScrollbarsRedrawNeeded += OnScrollbarsRedrawNeeded;
        }
示例#4
0
        protected void PaintScrollBars(YamuiScrollHandler yamuiScrollHandler)
        {
            if (!IsHandleCreated)
            {
                return;
            }

            // get non client area device
            var hdc = WinApi.GetWindowDC(new HandleRef(this, Handle));

            if (hdc == IntPtr.Zero)
            {
                return;
            }

            try {
                // paint the left over between the 2 scrolls (the small square)
                if (_needBothScroll)
                {
                    PaintOnRectangle(hdc, ref _leftoverBar, PaintLeftOver);
                }

                if (VerticalScroll.HasScroll)
                {
                    var verticalBar = VerticalScroll.BarRect;
                    PaintOnRectangle(hdc, ref verticalBar, PaintVerticalScroll);
                }

                if (HorizontalScroll.HasScroll)
                {
                    var horizontalBar = HorizontalScroll.BarRect;
                    PaintOnRectangle(hdc, ref horizontalBar, PaintHorizontalScroll);
                }
            } finally {
                WinApi.ReleaseDC(new HandleRef(this, Handle), new HandleRef(null, hdc));
            }
        }