Wraparound when using the arrow keys to select search results.

master
Pacman Ghost 5 years ago
parent 51ed8b1057
commit 92094c6818
  1. 13
      src/AppImageListView.cs
  2. 2
      src/MainForm.cs
  3. 12
      src/MainForm.ui.cs

@ -4,11 +4,22 @@ using Manina.Windows.Forms ;
// --------------------------------------------------------------------
public class AppImageListView
public class AppImageListView : ImageListView
{
public class AppImageListViewRenderer : ImageListView.ImageListViewRenderer
{
// NOTE: This disables the large preview image in Gallery mode.
public override void DrawGalleryImage( Graphics g, ImageListViewItem lvi , Image img, Rectangle rc ) {}
}
public void setSelection( int selIndex )
{
// set the selected item
for ( int i=0 ; i < Items.Count ; ++i )
Items[i].Selected = (i == selIndex) ;
Items.FocusedItem = Items[selIndex] ;
EnsureVisible( selIndex ) ;
}
}

@ -23,7 +23,7 @@ public partial class MainForm : Form
private UserControl mSearchUserControl = new UserControl() ;
private Label mSearchLabel = new Label() ;
private TextBox mSearchQuery = new TextBox() ;
private ImageListView mSearchResults = new ImageListView() ;
private AppImageListView mSearchResults = new AppImageListView() ;
private WebBrowser mWebBrowser = new WebBrowser() ;
private Panel mChartImagePanel = new Panel() ;
private PictureBox mChartImagePictureBox = new PictureBox() ;

@ -146,6 +146,18 @@ public partial class MainForm : Form
// 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.
if ( mSearchResults.Items.Count > 1 && mSearchResults.SelectedItems.Count > 0 ) {
// check for wrap-around
ImageListViewItem selItem = mSearchResults.SelectedItems[0] ;
if ( keyCode == Keys.Left && Object.ReferenceEquals( selItem, mSearchResults.Items[0] ) ) {
mSearchResults.setSelection( mSearchResults.Items.Count-1 ) ;
return true ;
}
if ( keyCode == Keys.Right && Object.ReferenceEquals( selItem, mSearchResults.Items[mSearchResults.Items.Count-1] ) ) {
mSearchResults.setSelection( 0 ) ;
return true ;
}
}
mSearchResults.Focus() ;
mDisableProcessCmdKey = true ;
SendKeys.SendWait( "{" + keyCode.ToString() + "}" ) ;

Loading…
Cancel
Save