Allow the current ChartImage to be scrolled using the keyboard.

master
Pacman Ghost 5 years ago
parent 5541661944
commit 9ad0ce469f
  1. 40
      src/MainForm.ui.cs

@ -131,12 +131,52 @@ public partial class MainForm : Form
// check for special keypresses
if ( keyCode == Keys.Left || keyCode == Keys.Right ) {
// send the keypress to the search results
// NOTE: We could also respond to Up/Down and scroll the ChartImage vertically,
// but that would be confusing, given that Left/Right selects a search result.
mSearchResults.Focus() ;
mDisableProcessCmdKey = true ;
SendKeys.SendWait( "{" + keyCode.ToString() + "}" ) ;
mDisableProcessCmdKey = false ;
return true ;
}
if ( keyCode == Keys.PageUp || keyCode == Keys.PageDown ) {
// scroll the ChartImage up/down
if ( mChartImagePictureBox.Image == null )
return false ;
double ratio = (double)mChartImagePanel.Height / (double)mChartImagePictureBox.Height ;
VScrollProperties vscroll = mChartImagePanel.VerticalScroll ;
int scrollRange = vscroll.Maximum - vscroll.Minimum ;
int pageSize = (int)( ratio * scrollRange * 0.8 ) ;
if ( keyCode == Keys.PageUp )
pageSize = - pageSize ;
int scrollY = vscroll.Value + pageSize ;
scrollChartImagePanel( null, scrollY ) ;
return true ;
}
if ( keyCode == Keys.Home ) {
int? scrollX=null, scrollY=null ;
if ( (modifierKeys & Keys.Control) != 0 )
scrollX = scrollY = 0 ;
if ( (modifierKeys & Keys.Shift) != 0 )
scrollX = 0 ;
else
scrollY = 0 ;
setChartImagePanelScrollPos( scrollX, scrollY ) ;
return true ;
}
if ( keyCode == Keys.End ) {
int? scrollX=null, scrollY=null ;
if ( (modifierKeys & Keys.Control) != 0 ) {
scrollX = 0 ;
scrollY = ChartImagePanel_MaxScrollY() ;
}
if ( (modifierKeys & Keys.Shift) != 0 )
scrollX = ChartImagePanel_MaxScrollX() ;
else
scrollY = ChartImagePanel_MaxScrollY() ;
setChartImagePanelScrollPos( scrollX, scrollY ) ;
return true ;
}
if ( keyCode == Keys.Escape ) {
// clear the search query
mSearchQuery.Text = "" ;

Loading…
Cancel
Save