Worked around a weird problem setting the scrollbar positions on Windows.

master
Pacman Ghost 5 years ago
parent 778610390d
commit f20a026292
  1. 14
      src/MainForm.cs
  2. 14
      src/MainForm.ui.cs

@ -188,4 +188,18 @@ public partial class MainForm : Form
mSearchResults.ResumeLayout( true ) ;
mSearchResultsKey = key ;
}
private void setChartImagePanelScrollPos( int? hscrollPos, int? vscrollPos )
{
// FUDGE! These need to be set twice to take effect on Windows :-/
if ( hscrollPos != null ) {
mChartImagePanel.HorizontalScroll.Value = hscrollPos.Value ;
mChartImagePanel.HorizontalScroll.Value = hscrollPos.Value ;
}
if ( vscrollPos != null ) {
mChartImagePanel.VerticalScroll.Value = vscrollPos.Value ;
mChartImagePanel.VerticalScroll.Value = vscrollPos.Value ;
}
}
}

@ -225,8 +225,7 @@ public partial class MainForm : Form
double prevRelScrollPosY = (double)prevScrollPosY / (double)prevMaxScrollY ;
// resize and position the ChartImage
mChartImagePanel.HorizontalScroll.Value = 0 ;
mChartImagePanel.VerticalScroll.Value = 0 ;
setChartImagePanelScrollPos( 0, 0 ) ;
Size prevChartImagePictureBoxSize = new Size( mChartImagePictureBox.Size.Width, mChartImagePictureBox.Size.Height ) ;
mChartImagePictureBox.Size = new Size( width, height ) ;
if ( width < availableWidth )
@ -320,18 +319,14 @@ public partial class MainForm : Form
{
// update the scroll position
if ( scrollX != null ) {
HScrollProperties hscroll = mChartImagePanel.HorizontalScroll ;
int maxScrollX = ChartImagePanel_MaxScrollX() ;
int scrollPos = Math.Max( 0, Math.Min( maxScrollX, scrollX.Value ) ) ;
hscroll.Value = scrollPos ;
hscroll.Value = scrollPos ; // nb: for Windows :shrug:
setChartImagePanelScrollPos( scrollPos, null ) ;
}
if ( scrollY != null ) {
VScrollProperties vscroll = mChartImagePanel.VerticalScroll ;
int maxScrollY = ChartImagePanel_MaxScrollY() ;
int scrollPos = Math.Max( 0, Math.Min( maxScrollY, scrollY.Value ) ) ;
vscroll.Value = scrollPos ;
vscroll.Value = scrollPos ; // nb: for Windows :shrug:
setChartImagePanelScrollPos( null, scrollPos ) ;
}
}
@ -351,8 +346,7 @@ public partial class MainForm : Form
mChartImagePictureBox.Image = chartImage.image ;
} else
mChartImagePictureBox.Image = null ;
mChartImagePanel.HorizontalScroll.Value = 0 ;
mChartImagePanel.VerticalScroll.Value = 0 ;
setChartImagePanelScrollPos( 0, 0 ) ;
mUserZoom = 1.0 ;
doMainFormResize( null ) ;
}

Loading…
Cancel
Save