Пример #1
0
        private void ScrollVisible(int index, int deltaY)
        {
            int visibleY = Math.Max(0, index - _location.Y);

            if (visibleY <= _visibleCount)
            {
                Rectangle visible = DisplayRectangle;
                RECT      scroll  = UnsafeUtilities.RECTFromLTRB(visible.X, visibleY * _rowHeight, visible.Right, Math.Max(visible.Bottom, visible.Bottom + _rowHeight));
                RECT      clip    = UnsafeUtilities.RECTFromRectangle(visible);
                UnsafeNativeMethods.ScrollWindowEx(this.Handle, 0, deltaY * _rowHeight, ref scroll, ref clip, IntPtr.Zero, IntPtr.Zero, 2 /* SW_INVALIDATE */ | 4 /* SW_ERASE */);
            }
        }
Пример #2
0
        private void NavigateTo(Point location)
        {
            location.X = Constrain(location.X, _hScrollBar.Minimum, _hScrollBar.Maximum);
            location.Y = Math.Max(0, Math.Min(_exposed.Count, location.Y + (_visibleCount - 1)) - (_visibleCount - 1));
            if (location != _location)
            {
                Point delta = new Point((_location.X - location.X) * _indent, (_location.Y - location.Y) * _rowHeight);

                _location = location;

                _hScrollBar.Value = _location.X;
                _vScrollBar.Value = _location.Y;

                UpdateDesigners(true);                  // even if layout weren't supressed, there is no guarantee that a layout will be performed

                RECT rect = UnsafeUtilities.RECTFromRectangle(DisplayRectangle);
                UnsafeNativeMethods.ScrollWindowEx(this.Handle, delta.X, delta.Y, ref rect, ref rect, IntPtr.Zero, IntPtr.Zero, 2 /* SW_INVALIDATE */);

                PerformLayout();
            }
        }
Пример #3
0
        private void NavigateTo(Point location)
        {
            location.X = Constrain(location.X, _hScrollBar.Minimum, _hScrollBar.Maximum);
            location.Y = Constrain(location.Y, _vScrollBar.Minimum, _vScrollBar.Maximum);
            if (location != _location)
            {
                Point delta = new Point(SumWidths(_location.X, location.X), (_location.Y - location.Y) * _rowHeight);

                _location = location;

                _hScrollBar.Value = _location.X;
                _vScrollBar.Value = _location.Y;

                // Scroll vertically (seperate from horizontal because it does not affect header
                RECT rect = UnsafeUtilities.RECTFromRectangle(DataRectangle);
                UnsafeNativeMethods.ScrollWindowEx(this.Handle, 0, delta.Y, ref rect, ref rect, IntPtr.Zero, IntPtr.Zero, 2 /* SW_INVALIDATE */);

                // Scroll horizontally
                rect = UnsafeUtilities.RECTFromRectangle(DisplayRectangle);
                UnsafeNativeMethods.ScrollWindowEx(this.Handle, delta.X, 0, ref rect, ref rect, IntPtr.Zero, IntPtr.Zero, 2 /* SW_INVALIDATE */);

                PerformLayout();
            }
        }