tsunami
log in
email
password
links
newest items
tag list
syntax reference
tag:time
history
item name
tags
{{ /* We want the final ratio of LargeChange to Maximum to * represent the ratio of panInner visible to total panInner. * However, if we only adjust LargeChange, then the range of values * available is Maximum - LargeChange, so we must adjust Maximum as well * (by adding LargeChange to it). Doing this changes the ratio, so * we use algebra (yay!) to figure out what the initial ratio should be * in order to get the desired ratio. * * L = LargeChange * r = ratio of panOuter.Width / panInner.Width (inital ratio) * m = Original maximum * M = new maximum after adjusted with LargeChange (adjusted maximum) * R = new ratio with new maximum (desired ratio) * * L = m * r * M = m + L * R = L / M * = m * r / (m + m * r) * = r / (1 + r) * R + r * R = r * r = R / (1 - R) * */ int iLarge; int iMax; float fRatio; iMax = panInner.Width - panOuter.Width - 1; if (bShowHSC) { fRatio = (float)panOuter.Width / panInner.Width; fRatio /= (1 - fRatio); iLarge = (int)(fRatio * iMax); hsc.Maximum = iMax + iLarge; hsc.LargeChange = iLarge; hsc.SmallChange = 4; // if panInner is scrolled further than the new maximum, move it back if (-panInner.Left > iMax) panInner.Left = -iMax; hsc.Top = this.Height - hsc.Height - miOffset; hsc.Width = panOuter.Width - miOffset + 1 + (hsc.Visible ? 0 : 1); hsc.Visible = true; } iMax = panInner.Height - panOuter.Height - 1; if (bShowVSC) { fRatio = (float)panOuter.Height / panInner.Height; fRatio /= 1 - fRatio; iLarge = (int)(fRatio * iMax); vsc.Maximum = iMax + iLarge; vsc.LargeChange = iLarge; vsc.SmallChange = 4; if (-panInner.Top > iMax) panInner.Top = -iMax; vsc.Left = this.Width - vsc.Width - miOffset; vsc.Height = panOuter.Height - miOffset + 1 + (vsc.Visible ? 0 : 1); vsc.Visible = true; } if (bHSC != bShowHSC || bVSC != bShowVSC) this.OnScrollVisibleChanged(new EventArgs()); }}
some permissive license goes here
contact