Scrollbars maxvalue er for høj
Jeg har lidt af et problem. Jeg har lavet mig en Control som tegner et blueprint af en bygning og et tilhørende SpotMatrix. Det er muligt at zoome ind på blueprintet, og hvis dens nye størrelse overstiger størrelsen på controlstørrelsen kommer der scrollbars på.Nu sker der dog det underlige, at jo længere man zoomer ind, jo større bliver afvigelsen i scrollbarenes maxvalue's. Dvs. at man kan scrolle for langt til højre og nedaf.
Jeg sætter ZoomLevel sådan her:
public int ZoomLevel
{
set
{
this.zoomPercentage = value;
this.blueprintZoomHeight = (int)(this.blueprint.Height * value/100);
this.blueprintZoomWidth = (int)(this.blueprint.Width * value/100);
this.displayScrollBars();
this.setScrollBarValues();
this.Invalidate();
}
}
og beregner de forskellige værdier for scrollbarene sådan her:
private void setScrollBarValues()
{
//
//TODO: There is a bug wich gives the scrollbars increasingly higher maxvalues than they should
//
this.vScrollBar.Minimum = this.hScrollBar.Minimum = 0;
// If the offset does not make the Maximum less than zero, set its value.
if( (this.blueprintZoomWidth - this.rectToDrawIn.Width) > 0)
{
this.hScrollBar.Maximum = this.blueprintZoomWidth - (int)this.rectToDrawIn.Width;
}
this.hScrollBar.LargeChange = this.hScrollBar.Maximum / 10;
this.hScrollBar.SmallChange = this.hScrollBar.Maximum / 20;
this.hScrollBar.Maximum += this.hScrollBar.LargeChange;
// If the offset does not make the Maximum less than zero, set its value.
if( (this.blueprintZoomHeight - this.rectToDrawIn.Height) > 0)
{
this.vScrollBar.Maximum = this.blueprintZoomHeight - (int)this.rectToDrawIn.Height;
}
this.vScrollBar.LargeChange = this.vScrollBar.Maximum / 10;
this.vScrollBar.SmallChange = this.vScrollBar.Maximum / 20;
this.vScrollBar.Maximum += this.vScrollBar.LargeChange;
}
Er der nogen der umiddelbart kan se en fejl? Jeg er ved at stirre mig blind på det :S
