|
|
|
|
@ -61,9 +61,15 @@ namespace ICSharpCode.ILSpy
@@ -61,9 +61,15 @@ namespace ICSharpCode.ILSpy
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const int SearchMode_Type = 0; |
|
|
|
|
const int SearchMode_Member = 1; |
|
|
|
|
|
|
|
|
|
private SearchPane() |
|
|
|
|
{ |
|
|
|
|
InitializeComponent(); |
|
|
|
|
searchModeComboBox.Items.Add(new { Image = Images.Class, Name = "Type" }); |
|
|
|
|
searchModeComboBox.Items.Add(new { Image = Images.Property, Name = "Member" }); |
|
|
|
|
searchModeComboBox.SelectedIndex = SearchMode_Type; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void Show() |
|
|
|
|
@ -89,6 +95,11 @@ namespace ICSharpCode.ILSpy
@@ -89,6 +95,11 @@ namespace ICSharpCode.ILSpy
|
|
|
|
|
((SearchPane)o).StartSearch((string)e.NewValue); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SearchModeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) |
|
|
|
|
{ |
|
|
|
|
StartSearch(this.SearchTerm); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void StartSearch(string searchTerm) |
|
|
|
|
{ |
|
|
|
|
if (currentSearch != null) { |
|
|
|
|
@ -99,7 +110,7 @@ namespace ICSharpCode.ILSpy
@@ -99,7 +110,7 @@ namespace ICSharpCode.ILSpy
|
|
|
|
|
listBox.ItemsSource = null; |
|
|
|
|
} else { |
|
|
|
|
MainWindow mainWindow = MainWindow.Instance; |
|
|
|
|
currentSearch = new RunningSearch(mainWindow.CurrentAssemblyList.GetAssemblies(), searchTerm, mainWindow.CurrentLanguage); |
|
|
|
|
currentSearch = new RunningSearch(mainWindow.CurrentAssemblyList.GetAssemblies(), searchTerm, searchModeComboBox.SelectedIndex, mainWindow.CurrentLanguage); |
|
|
|
|
listBox.ItemsSource = currentSearch.Results; |
|
|
|
|
new Thread(currentSearch.Run).Start(); |
|
|
|
|
} |
|
|
|
|
@ -131,6 +142,17 @@ namespace ICSharpCode.ILSpy
@@ -131,6 +142,17 @@ namespace ICSharpCode.ILSpy
|
|
|
|
|
MainWindow.Instance.JumpToReference(result.Member); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected override void OnKeyDown(KeyEventArgs e) |
|
|
|
|
{ |
|
|
|
|
base.OnKeyDown(e); |
|
|
|
|
if (e.Key == Key.T && e.KeyboardDevice.Modifiers == ModifierKeys.Control) { |
|
|
|
|
searchModeComboBox.SelectedIndex = SearchMode_Type; |
|
|
|
|
e.Handled = true; |
|
|
|
|
} else if (e.Key == Key.M && e.KeyboardDevice.Modifiers == ModifierKeys.Control) { |
|
|
|
|
searchModeComboBox.SelectedIndex = SearchMode_Member; |
|
|
|
|
e.Handled = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sealed class RunningSearch |
|
|
|
|
@ -139,16 +161,18 @@ namespace ICSharpCode.ILSpy
@@ -139,16 +161,18 @@ namespace ICSharpCode.ILSpy
|
|
|
|
|
readonly CancellationTokenSource cts = new CancellationTokenSource(); |
|
|
|
|
readonly LoadedAssembly[] assemblies; |
|
|
|
|
readonly string searchTerm; |
|
|
|
|
readonly int searchMode; |
|
|
|
|
readonly Language language; |
|
|
|
|
public readonly ObservableCollection<SearchResult> Results = new ObservableCollection<SearchResult>(); |
|
|
|
|
int resultCount; |
|
|
|
|
|
|
|
|
|
public RunningSearch(LoadedAssembly[] assemblies, string searchTerm, Language language) |
|
|
|
|
public RunningSearch(LoadedAssembly[] assemblies, string searchTerm, int searchMode, Language language) |
|
|
|
|
{ |
|
|
|
|
this.dispatcher = Dispatcher.CurrentDispatcher; |
|
|
|
|
this.assemblies = assemblies; |
|
|
|
|
this.searchTerm = searchTerm; |
|
|
|
|
this.language = language; |
|
|
|
|
this.searchMode = searchMode; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void Cancel() |
|
|
|
|
@ -196,7 +220,7 @@ namespace ICSharpCode.ILSpy
@@ -196,7 +220,7 @@ namespace ICSharpCode.ILSpy
|
|
|
|
|
|
|
|
|
|
void PerformSearch(TypeDefinition type) |
|
|
|
|
{ |
|
|
|
|
if (IsMatch(type.Name)) { |
|
|
|
|
if (searchMode == SearchMode_Type && IsMatch(type.Name)) { |
|
|
|
|
AddResult(new SearchResult { |
|
|
|
|
Member = type, |
|
|
|
|
Image = TypeTreeNode.GetIcon(type), |
|
|
|
|
@ -210,6 +234,9 @@ namespace ICSharpCode.ILSpy
@@ -210,6 +234,9 @@ namespace ICSharpCode.ILSpy
|
|
|
|
|
PerformSearch(nestedType); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (searchMode == SearchMode_Type) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
foreach (FieldDefinition field in type.Fields) { |
|
|
|
|
if (IsMatch(field.Name)) { |
|
|
|
|
AddResult(new SearchResult { |
|
|
|
|
@ -276,13 +303,15 @@ namespace ICSharpCode.ILSpy
@@ -276,13 +303,15 @@ namespace ICSharpCode.ILSpy
|
|
|
|
|
return Name; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[ExportMainMenuCommand(Menu = "_View", Header = "_Search", MenuIcon="Images/Find.png", MenuCategory = "ShowPane", MenuOrder = 100)] |
|
|
|
|
sealed class ShowSearchCommand : SimpleCommand |
|
|
|
|
[ExportToolbarCommand(ToolTip = "Search (F3)", ToolbarIcon = "Images/Find.png", ToolbarCategory = "View", ToolbarOrder = 100)] |
|
|
|
|
sealed class ShowSearchCommand : CommandWrapper |
|
|
|
|
{ |
|
|
|
|
public override void Execute(object parameter) |
|
|
|
|
public ShowSearchCommand() |
|
|
|
|
: base(NavigationCommands.Search) |
|
|
|
|
{ |
|
|
|
|
SearchPane.Instance.Show(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |