Browse Source

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

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

2
ILSpy/SearchPane.xaml

@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</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">
<Label Margin="0,-1">Search _for:</Label>
<ComboBox Name="searchModeComboBox" Width="100" SelectionChanged="SearchModeComboBox_SelectionChanged">

Loading…
Cancel
Save