protected ScrollBarDirections barsNeeded() { ScrollBarDirections ret = ScrollBarDirections.None; System.Drawing.Size intSize = this.Size; System.Drawing.Size scrlSize = _scrolledPanel.Size; if (scrlSize.Width > intSize.Width) { ret |= ScrollBarDirections.Horizontal; } if (scrlSize.Height > intSize.Height) { ret |= ScrollBarDirections.Vertical; } if ((ret & ScrollBarDirections.Horizontal) != 0 && scrlSize.Height > (intSize.Height - HSCROLL_HEIGHT)) { ret |= ScrollBarDirections.Vertical; } if ((ret & ScrollBarDirections.Vertical) != 0 && scrlSize.Width > (intSize.Width - VSCROLL_WIDTH)) { ret |= ScrollBarDirections.Horizontal; } return(ret); }
protected void sizeElements() { ScrollBarDirections barsToShow = 0x0; resizeScrollPanel(); System.Drawing.Size scrlSize = _scrolledPanel.Size; switch (_displayPolicy) { case ScrollBarDisplay.Always: barsToShow = _directionPolicy; break; case ScrollBarDisplay.Never: barsToShow = ScrollBarDirections.None; break; case ScrollBarDisplay.AsNeeded: barsToShow = barsNeeded(); break; } int intWidth = this.Size.Width; int intHeight = this.Size.Height; if ((ScrollBarDirections.Vertical & barsToShow) > 0) { intWidth -= VSCROLL_WIDTH; base.Controls.Add(_vertBar); } else if (((Control)this).Controls.Contains(_vertBar)) { base.Controls.Remove(_vertBar); } // determine settings for the scrollbar if ((ScrollBarDirections.Vertical & barsToShow) > 0) { _vertBar.Minimum = 0; _vertBar.Maximum = scrlSize.Height; _vertBar.LargeChange = intHeight; _vertBar.SmallChange = scrlSize.Height / 20; _vertBar.Location = new System.Drawing.Point(intWidth, 0); _vertBar.Size = new System.Drawing.Size(VSCROLL_WIDTH, intHeight); } System.Drawing.Size newInternalSize = new System.Drawing.Size(intWidth, _scrolledPanel.Size.Height); bool bcmp = !newInternalSize.Equals(_scrolledPanel.Size); _scrolledPanel.Size = newInternalSize; if (bcmp && this.ClientResized != null) { ClientResized(this, new EventArgs()); } }
protected ScrollBarDirections barsNeeded() { ScrollBarDirections ret = ScrollBarDirections.None; System.Drawing.Size intSize = this.Size; System.Drawing.Size scrlSize = _scrolledPanel.Size; if (scrlSize.Height > intSize.Height) { ret |= ScrollBarDirections.Vertical; } return(ret); }
public PhoneScrollingPanel(ScrollBarDisplay dPol, ScrollBarDirections dirPol) { _displayPolicy = dPol; _directionPolicy = dirPol; _scrolledPanel = new Panel(); _vertBar = new VScrollBar(); _scrolledPanel.Location = new System.Drawing.Point(0, 0); ((Control)this).Controls.Add(_scrolledPanel); _collection = new ScrolledCollection(this, _scrolledPanel); this.Resize += new EventHandler(ScrollingPanel_Resize); _vertBar.ValueChanged += new EventHandler(_vertBar_ValueChanged); }