예제 #1
0
        private void ApplyPreferedSize(Size preferedSize, Size panelSize)
        {
            _needBothScroll = false;
            var needHorizontalScroll = HorizontalScroll.HasScroll;
            var needVerticalScroll   = VerticalScroll.UpdateLength(preferedSize.Height, null, panelSize.Height - (needHorizontalScroll ? HorizontalScroll.BarThickness : 0), panelSize.Width);

            HorizontalScroll.UpdateLength(preferedSize.Width, null, panelSize.Width - (needVerticalScroll ? VerticalScroll.BarThickness : 0), panelSize.Height);

            if (needHorizontalScroll != HorizontalScroll.HasScroll)
            {
                needHorizontalScroll = HorizontalScroll.HasScroll;
                needVerticalScroll   = VerticalScroll.UpdateLength(preferedSize.Height, null, panelSize.Height - (needHorizontalScroll ? HorizontalScroll.BarThickness : 0), panelSize.Width);
            }

            _needBothScroll = needVerticalScroll && needHorizontalScroll;
            if (_needBothScroll)
            {
                _leftoverBar = new Rectangle(panelSize.Width - VerticalScroll.BarThickness, panelSize.Height - HorizontalScroll.BarThickness, VerticalScroll.BarThickness, HorizontalScroll.BarThickness);
            }
        }
        protected void ComputeScrollbars(Size naturalSize, Size availableSize)
        {
            _needBothScroll = false;
            var needHorizontalScroll = HorizontalScroll.HasScroll;
            var needVerticalScroll   = VerticalScroll.UpdateLength(naturalSize.Height, null, availableSize.Height - (needHorizontalScroll ? HorizontalScroll.BarThickness : 0), availableSize.Width);

            HorizontalScroll.UpdateLength(naturalSize.Width, null, availableSize.Width - (needVerticalScroll ? VerticalScroll.BarThickness : 0), availableSize.Height);

            if (needHorizontalScroll != HorizontalScroll.HasScroll)
            {
                needHorizontalScroll = HorizontalScroll.HasScroll;
                needVerticalScroll   = VerticalScroll.UpdateLength(naturalSize.Height, null, availableSize.Height - (needHorizontalScroll ? HorizontalScroll.BarThickness : 0), availableSize.Width);
            }

            // compute the "left over" rectangle on the bottom right between the 2 scrolls
            _needBothScroll = needVerticalScroll && needHorizontalScroll;
            if (_needBothScroll)
            {
                _leftoverBar = new Rectangle(ContentSurfaceWithScrolls.X + ContentSurfaceWithScrolls.Width - VerticalScroll.BarThickness, ContentSurfaceWithScrolls.Y + ContentSurfaceWithScrolls.Height - HorizontalScroll.BarThickness, VerticalScroll.BarThickness, HorizontalScroll.BarThickness);
            }

            ContentSurface = new Rectangle(ContentSurfaceWithScrolls.X, ContentSurfaceWithScrolls.Y, ContentSurfaceWithScrolls.Width - (needVerticalScroll ? VerticalScroll.BarThickness : 0), ContentSurfaceWithScrolls.Height - (needHorizontalScroll ? HorizontalScroll.BarThickness : 0));
        }