Automatically start a new search after some time has passed.

master
Pacman Ghost 5 years ago
parent 2c793ef6fd
commit db6cc00a72
  1. 1
      src/MainForm.cs
  2. 17
      src/MainForm.ui.cs

@ -26,6 +26,7 @@ public partial class MainForm : Form
private Point? mMouseDragAnchor = null ; private Point? mMouseDragAnchor = null ;
private Tuple<int,int> mScrollDragAnchor ; private Tuple<int,int> mScrollDragAnchor ;
private double mUserZoom = 1.0 ; private double mUserZoom = 1.0 ;
private DateTime mLastKeyPressTimeStamp = DateTime.Now ;
public MainForm() public MainForm()
{ {

@ -73,6 +73,7 @@ public partial class MainForm : Form
this.FormClosing += new FormClosingEventHandler( this.MainForm_FormClosing ) ; this.FormClosing += new FormClosingEventHandler( this.MainForm_FormClosing ) ;
this.Resize += new EventHandler( this.MainForm_Resize ) ; this.Resize += new EventHandler( this.MainForm_Resize ) ;
this.mSearchQuery.TextChanged += new EventHandler( this.SearchQuery_TextChanged ) ; this.mSearchQuery.TextChanged += new EventHandler( this.SearchQuery_TextChanged ) ;
this.mSearchQuery.KeyPress += new KeyPressEventHandler( this.SearchQuery_KeyPress ) ;
this.mSearchQuery.KeyDown += new KeyEventHandler( this.SearchQuery_KeyDown ) ; this.mSearchQuery.KeyDown += new KeyEventHandler( this.SearchQuery_KeyDown ) ;
this.mSearchResults.KeyPress += new KeyPressEventHandler( this.SearchResults_KeyPress ) ; this.mSearchResults.KeyPress += new KeyPressEventHandler( this.SearchResults_KeyPress ) ;
this.mSearchResults.SelectionChanged += new EventHandler( this.SearchResults_SelectionChanged ) ; this.mSearchResults.SelectionChanged += new EventHandler( this.SearchResults_SelectionChanged ) ;
@ -338,6 +339,20 @@ public partial class MainForm : Form
updateSearchResults( mSearchQuery.Text.Trim() ) ; updateSearchResults( mSearchQuery.Text.Trim() ) ;
} }
private void SearchQuery_KeyPress( object sender, KeyPressEventArgs e )
{
// check how much time has passed since the last keypress
int ch = (int) e.KeyChar ;
if ( ch >= 32 && ch < 127 ) {
int ttl = Program.appConfig.getIntVal( new string[]{"SearchQueryTTL"}, 5 ) ;
if ( (DateTime.Now - mLastKeyPressTimeStamp).TotalSeconds > ttl ) {
// it's been a while - start a new search query
mSearchQuery.Text = "" ;
}
mLastKeyPressTimeStamp = DateTime.Now ;
}
}
private void SearchQuery_KeyDown( object sender, KeyEventArgs e ) private void SearchQuery_KeyDown( object sender, KeyEventArgs e )
{ {
// check if there are any ChartImage's associated with the keypress // check if there are any ChartImage's associated with the keypress
@ -375,8 +390,8 @@ public partial class MainForm : Form
if ( ch == 27 ) if ( ch == 27 )
mSearchQuery.Text = "" ; mSearchQuery.Text = "" ;
else if ( ch >= 32 && ch < 127 ) { else if ( ch >= 32 && ch < 127 ) {
mSearchQuery.AppendText( e.KeyChar.ToString() ) ;
mSearchQuery.Focus() ; mSearchQuery.Focus() ;
SendKeys.Send( e.KeyChar.ToString() ) ;
} }
} }
} }

Loading…
Cancel
Save