Browse Source

Show 'Searching...' entry while search is in progress.

pull/166/head
Daniel Grunwald 16 years ago
parent
commit
db015f3be6
  1. 21
      ILSpy/SearchPane.cs
  2. 2
      ILSpy/SearchPane.xaml

21
ILSpy/SearchPane.cs

@ -129,7 +129,7 @@ namespace ICSharpCode.ILSpy
void ListBox_KeyDown(object sender, KeyEventArgs e) void ListBox_KeyDown(object sender, KeyEventArgs e)
{ {
if (e.Key == Key.Space || e.Key == Key.Return) { if (e.Key == Key.Return) {
e.Handled = true; e.Handled = true;
JumpToSelectedItem(); JumpToSelectedItem();
} }
@ -155,6 +155,15 @@ namespace ICSharpCode.ILSpy
} }
} }
void SearchBox_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Down && listBox.HasItems) {
e.Handled = true;
listBox.MoveFocus(new TraversalRequest(FocusNavigationDirection.First));
listBox.SelectedIndex = 0;
}
}
sealed class RunningSearch sealed class RunningSearch
{ {
readonly Dispatcher dispatcher; readonly Dispatcher dispatcher;
@ -173,6 +182,8 @@ namespace ICSharpCode.ILSpy
this.searchTerm = searchTerm; this.searchTerm = searchTerm;
this.language = language; this.language = language;
this.searchMode = searchMode; this.searchMode = searchMode;
this.Results.Add(new SearchResult { Name = "Searching..." });
} }
public void Cancel() public void Cancel()
@ -196,6 +207,10 @@ namespace ICSharpCode.ILSpy
} catch (OperationCanceledException) { } catch (OperationCanceledException) {
// ignore cancellation // ignore cancellation
} }
// remove the 'Searching...' entry
dispatcher.BeginInvoke(
DispatcherPriority.Normal,
new Action(delegate { this.Results.RemoveAt(this.Results.Count - 1); }));
} }
void AddResult(SearchResult result) void AddResult(SearchResult result)
@ -206,7 +221,7 @@ namespace ICSharpCode.ILSpy
} }
dispatcher.BeginInvoke( dispatcher.BeginInvoke(
DispatcherPriority.Normal, DispatcherPriority.Normal,
new Action(delegate { this.Results.Add(result); })); new Action(delegate { this.Results.Insert(this.Results.Count - 1, result); }));
cts.Token.ThrowIfCancellationRequested(); cts.Token.ThrowIfCancellationRequested();
} }
@ -284,7 +299,7 @@ namespace ICSharpCode.ILSpy
} }
} }
class SearchResult : INotifyPropertyChanged sealed class SearchResult : INotifyPropertyChanged, IMemberTreeNode
{ {
event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged { event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged {
add { } add { }

2
ILSpy/SearchPane.xaml

@ -8,7 +8,7 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<controls:SearchBox DockPanel.Dock="Top" WatermarkText="Search" WatermarkColor="Gray" ToolTip="Search" Text="{Binding SearchTerm, ElementName=self}" x:Name="searchBox" Grid.Column="0" Grid.Row="0" /> <controls:SearchBox DockPanel.Dock="Top" WatermarkText="Search" WatermarkColor="Gray" ToolTip="Search" Text="{Binding SearchTerm, ElementName=self}" x:Name="searchBox" Grid.Column="0" Grid.Row="0" UpdateDelay="0:0:0.1" PreviewKeyDown="SearchBox_PreviewKeyDown" />
<StackPanel Grid.Column="1" Grid.Row="0" Orientation="Horizontal"> <StackPanel Grid.Column="1" Grid.Row="0" Orientation="Horizontal">
<Label Margin="0,-1">Search _for:</Label> <Label Margin="0,-1">Search _for:</Label>
<ComboBox Name="searchModeComboBox" Width="100" SelectionChanged="SearchModeComboBox_SelectionChanged"> <ComboBox Name="searchModeComboBox" Width="100" SelectionChanged="SearchModeComboBox_SelectionChanged">

Loading…
Cancel
Save