Example #1
0
        void SetScroll()
        {
            SizeF contentSize    = gridViewCore.GetContentSize();
            float viewportWidth  = gridViewCore.GetViewportWidth();
            float viewportHeight = gridViewCore.GetViewportHeight();

            float spacingW = SideSpacing.left + SideSpacing.right;
            float spacingH = SideSpacing.top + SideSpacing.bottom;
            float packWidth;
            float packHeight;
            float n = IsUseInside ? 1 : 0;

            packWidth  = Width - spacingW - n;
            packHeight = Height - spacingH - n;

            float headerH = gridViewCore.HeaderHeight + gridViewCore.HeaderSpacing;

            if (contentSize.Height > gridViewCore.GetViewportHeight())
            {
                scrollBarVertical.Width  = VerScrollSize;
                scrollBarVertical.Height = Height;

                scrollBarVertical.Visible = true;
                gridViewPack.Width        = packWidth - scrollBarVertical.Width;
                seletorScreen.Width       = packWidth + SelectorMargin.left + SelectorMargin.right - scrollBarVertical.Width;
                gridViewCore.Width        = packWidth - scrollBarVertical.Width;
            }
            else
            {
                scrollBarVertical.Visible = false;
                gridViewPack.Width        = packWidth;
                seletorScreen.Width       = packWidth + SelectorMargin.left + SelectorMargin.right;
                gridViewCore.Width        = packWidth;
            }

            if (contentSize.Width > gridViewCore.GetViewportWidth())
            {
                scrollBarHorizontal.Width  = Width;
                scrollBarHorizontal.Height = HorScrollSize;

                scrollBarHorizontal.Visible = true;
                gridViewPack.Height         = packHeight - scrollBarHorizontal.Height;
                seletorScreen.Height        = Height - spacingH - headerH + SelectorMargin.top + SelectorMargin.bottom - scrollBarHorizontal.Height;
                gridViewCore.Height         = packHeight - scrollBarHorizontal.Height;
            }
            else
            {
                scrollBarHorizontal.Visible = false;
                gridViewPack.Height         = packHeight;
                seletorScreen.Height        = Height - spacingH - headerH + SelectorMargin.top + SelectorMargin.bottom;
                gridViewCore.Height         = packHeight;
            }

            if (scrollBarVertical.Visible && scrollBarHorizontal.Visible)
            {
                scrollBarHorizontal.Width = Width - scrollBarVertical.Width;
                scrollBarVertical.Height  = Height - scrollBarHorizontal.Height;
            }

            if (scrollBarVertical.Visible)
            {
                scrollBarVertical.SetSliderRatio(contentSize.Height, gridViewCore.GetViewportHeight());
                scrollBarVertical.Location = new PointF(Width - scrollBarVertical.Width, scrollBarVertical.Location.Y);
                scrollBarVertical.SetSliderLocationByViewport(gridViewCore.GetContentShowPos());
            }

            if (scrollBarHorizontal.Visible)
            {
                PointF screenLoctain = gridViewCore.GetScreenLoaction();
                scrollBarHorizontal.SetSliderRatio(contentSize.Width, gridViewCore.Width);
                scrollBarHorizontal.Location = new PointF(scrollBarHorizontal.Location.X, Height - scrollBarHorizontal.Height);
                scrollBarHorizontal.SetSliderLocationByViewport(-screenLoctain.X);
            }

            if (ShadowLayer != null)
            {
                ScShadow shadow = (ScShadow)ShadowLayer;

                switch (ShadowStyle)
                {
                case 0:

                    shadow.DirectionRect = new RectangleF(
                        DirectionRect.X - shadow.ShadowRadius,
                        DirectionRect.Y + shadow.ShadowRadius,
                        DirectionRect.Width + shadow.ShadowRadius * 2,
                        DirectionRect.Height);
                    break;

                case 1:

                    shadow.DirectionRect = new RectangleF(
                        DirectionRect.X + gridViewPack.DirectionRect.X - shadow.ShadowRadius,
                        DirectionRect.Y + gridViewPack.DirectionRect.Y + shadow.ShadowRadius,
                        gridViewPack.Width + shadow.ShadowRadius * 2,
                        gridViewPack.Height);
                    break;


                case 2:

                    shadow.DirectionRect = new RectangleF(
                        DirectionRect.X - shadow.ShadowRadius,
                        DirectionRect.Y - shadow.ShadowRadius,
                        DirectionRect.Width + shadow.ShadowRadius * 2,
                        DirectionRect.Height + shadow.ShadowRadius * 2);
                    break;


                case 3:
                    shadow.DirectionRect = new RectangleF(
                        DirectionRect.X + gridViewPack.DirectionRect.X - shadow.ShadowRadius,
                        DirectionRect.Y + gridViewPack.DirectionRect.Y - shadow.ShadowRadius,
                        gridViewPack.Width + shadow.ShadowRadius * 2,
                        gridViewPack.Height + shadow.ShadowRadius * 2);
                    break;
                }
            }
        }