Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit fffcd64

Browse files
committed
Added a search box for adding project references. It is important for big projects
1 parent 69bef7e commit fffcd64

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace ICSharpCode.SharpDevelop.Gui
2727
public class ProjectReferencePanel : ListView, IReferencePanel
2828
{
2929
ISelectReferenceDialog selectDialog;
30+
TextBox filterTextBox;
3031

3132
public ProjectReferencePanel(ISelectReferenceDialog selectDialog)
3233
{
@@ -48,6 +49,15 @@ public ProjectReferencePanel(ISelectReferenceDialog selectDialog)
4849

4950
ItemActivate += delegate { AddReference(); };
5051
PopulateListView();
52+
53+
54+
Panel upperPanel = new Panel { Dock = DockStyle.Top, Height = 20 };
55+
filterTextBox = new TextBox { Width = 150, Dock = DockStyle.Right };
56+
filterTextBox.TextChanged += delegate { Search(); };
57+
58+
upperPanel.Controls.Add(filterTextBox);
59+
60+
this.Controls.Add(upperPanel);
5161
}
5262

5363
public void AddReference()
@@ -60,6 +70,7 @@ public void AddReference()
6070
new ProjectReferenceProjectItem(selectDialog.ConfigureProject, project)
6171
);
6272
}
73+
filterTextBox.Text = "";
6374
}
6475

6576
void PopulateListView()
@@ -74,5 +85,32 @@ void PopulateListView()
7485
Items.Add(newItem);
7586
}
7687
}
88+
89+
static bool ContainsAnyOfTokens(string bigText, string[] tokens)
90+
{
91+
if(tokens.Length==0)
92+
return true;
93+
foreach(var token in tokens)
94+
{
95+
if(bigText.Contains(token))
96+
return true;
97+
}
98+
return false;
99+
}
100+
101+
void Search()
102+
{
103+
Items.Clear();
104+
var tokens = filterTextBox.Text.Split(new []{' '}, StringSplitOptions.RemoveEmptyEntries);
105+
106+
foreach (IProject project in ProjectService.OpenSolution.Projects.
107+
Where(pr=>ContainsAnyOfTokens(pr.Name, tokens))
108+
.OrderBy(p => p.Name, StringComparer.OrdinalIgnoreCase)
109+
) {
110+
ListViewItem newItem = new ListViewItem(new string[] { project.Name, project.Directory });
111+
newItem.Tag = project;
112+
Items.Add(newItem);
113+
}
114+
}
77115
}
78116
}

0 commit comments

Comments
 (0)