コード例 #1
0
        public void SetInnerBox(CssBox innerBox)
        {
            if (this.innerBox != null)
            {
                return;
            }

            this.innerBox   = innerBox;
            this.scrollView = new CssScrollWrapper(innerBox);
            //scroll barwidth = 10;
            bool      needHScrollBar = false;
            bool      needVScrollBar = false;
            int       originalBoxW   = (int)innerBox.VisualWidth;
            int       originalBoxH   = (int)innerBox.VisualHeight;
            int       newW           = originalBoxW;
            int       newH           = originalBoxH;
            const int scBarWidth     = 10;

            if (innerBox.InnerContentHeight > innerBox.ExpectedHeight)
            {
                needVScrollBar = true;
                newW          -= scBarWidth;
            }
            if (innerBox.InnerContentWidth > innerBox.ExpectedWidth)
            {
                needHScrollBar = true;
                newH          -= scBarWidth;
            }
            innerBox.SetVisualSize(newW, newH);
            innerBox.SetExpectedSize(newW, newH);
            this.AppendToAbsoluteLayer(innerBox);
            //check if need vertical scroll and/or horizontal scroll

            //vertical scrollbar
            if (needVScrollBar)
            {
                this.vscbar          = new ScrollBar(scBarWidth, needHScrollBar ? newH : originalBoxH);
                vscbar.ScrollBarType = ScrollBarType.Vertical;
                vscbar.MinValue      = 0;
                vscbar.MaxValue      = innerBox.VisualHeight;
                vscbar.SmallChange   = 20;
                //add relation between viewpanel and scroll bar
                vscRelation = new ScrollingRelation(vscbar.SliderBox, scrollView);
                //----------------------
                var scBarWrapCssBox = LayoutFarm.Composers.CustomCssBoxGenerator.CreateWrapper(
                    this.vscbar,
                    this.vscbar.GetPrimaryRenderElement((RootGraphic)this.GetInternalRootGfx()),
                    CssBox.UnsafeGetBoxSpec(this), false);
                scBarWrapCssBox.SetLocation(newW, 0);
                this.AppendToAbsoluteLayer(scBarWrapCssBox);
            }

            if (needHScrollBar)
            {
                this.hscbar          = new ScrollBar(needVScrollBar ? newW : originalBoxW, scBarWidth);
                hscbar.ScrollBarType = ScrollBarType.Horizontal;
                hscbar.MinValue      = 0;
                hscbar.MaxValue      = innerBox.VisualHeight;
                hscbar.SmallChange   = 20;
                //add relation between viewpanel and scroll bar
                hscRelation = new ScrollingRelation(hscbar.SliderBox, scrollView);
                //----------------------
                var renderE         = this.hscbar.GetPrimaryRenderElement((RootGraphic)this.GetInternalRootGfx());
                var scBarWrapCssBox = LayoutFarm.Composers.CustomCssBoxGenerator.CreateWrapper(
                    this.hscbar,
                    this.hscbar.GetPrimaryRenderElement((RootGraphic)this.GetInternalRootGfx()),
                    CssBox.UnsafeGetBoxSpec(this), false);
                scBarWrapCssBox.SetLocation(0, newH);
                this.AppendToAbsoluteLayer(scBarWrapCssBox);
            }
        }
コード例 #2
0
        public void SetInnerBox(CssBox innerBox)
        {
            if (this.innerBox != null)
            {
                return;
            }

            this.innerBox = innerBox;
            this.scrollView = new CssScrollWrapper(innerBox);
            //scroll barwidth = 10;
            bool needHScrollBar = false;
            bool needVScrollBar = false;
            int originalBoxW = (int)innerBox.VisualWidth;
            int originalBoxH = (int)innerBox.VisualHeight;
            int newW = originalBoxW;
            int newH = originalBoxH;
            const int scBarWidth = 10;
            if (innerBox.InnerContentHeight > innerBox.ExpectedHeight)
            {
                needVScrollBar = true;
                newW -= scBarWidth;
            }
            if (innerBox.InnerContentWidth > innerBox.ExpectedWidth)
            {
                needHScrollBar = true;
                newH -= scBarWidth;
            }
            innerBox.SetVisualSize(newW, newH);
            innerBox.SetExpectedSize(newW, newH);
            this.AppendToAbsoluteLayer(innerBox);
            //check if need vertical scroll and/or horizontal scroll

            //vertical scrollbar
            if (needVScrollBar)
            {
                this.vscbar = new ScrollBar(scBarWidth, needHScrollBar ? newH : originalBoxH);
                vscbar.ScrollBarType = ScrollBarType.Vertical;
                vscbar.MinValue = 0;
                vscbar.MaxValue = innerBox.VisualHeight;
                vscbar.SmallChange = 20;
                //add relation between viewpanel and scroll bar 
                vscRelation = new ScrollingRelation(vscbar, scrollView);
                //---------------------- 
                var scBarWrapCssBox = LayoutFarm.Composers.CustomCssBoxGenerator.CreateWrapper(
                           this.vscbar,
                           this.vscbar.GetPrimaryRenderElement((RootGraphic)this.RootGfx),
                           CssBox.UnsafeGetBoxSpec(this), false);
                scBarWrapCssBox.SetLocation(newW, 0);
                this.AppendToAbsoluteLayer(scBarWrapCssBox);
            }

            if (needHScrollBar)
            {
                this.hscbar = new ScrollBar(needVScrollBar ? newW : originalBoxW, scBarWidth);
                hscbar.ScrollBarType = ScrollBarType.Horizontal;
                hscbar.MinValue = 0;
                hscbar.MaxValue = innerBox.VisualHeight;
                hscbar.SmallChange = 20;
                //add relation between viewpanel and scroll bar 
                hscRelation = new ScrollingRelation(hscbar, scrollView);
                //---------------------- 
                var renderE = this.hscbar.GetPrimaryRenderElement((RootGraphic)this.RootGfx);
                var scBarWrapCssBox = LayoutFarm.Composers.CustomCssBoxGenerator.CreateWrapper(
                         this.hscbar,
                         this.hscbar.GetPrimaryRenderElement((RootGraphic)this.RootGfx),
                         CssBox.UnsafeGetBoxSpec(this), false);
                scBarWrapCssBox.SetLocation(0, newH);
                this.AppendToAbsoluteLayer(scBarWrapCssBox);
            }
        }