Highlight multiple selection when clicking in project explorer

This commit is contained in:
dexy 2020-01-15 19:14:59 +11:00
parent 5cd2ebdd85
commit 6ed3996afa

View File

@ -2264,6 +2264,16 @@ namespace CodeWalker.Project.Panels
public event ProjectExplorerItemActivateHandler OnItemActivated; public event ProjectExplorerItemActivateHandler OnItemActivated;
private void ClearSelectedNodes()
{
foreach (var node in SelectedNodes)
{
node.BackColor = Color.Empty;
node.ForeColor = Color.Empty;
}
SelectedNodes.Clear();
}
private void ProjectTreeView_AfterSelect(object sender, TreeViewEventArgs e) private void ProjectTreeView_AfterSelect(object sender, TreeViewEventArgs e)
{ {
@ -2273,6 +2283,8 @@ namespace CodeWalker.Project.Panels
{ {
if (SelectedNodes.Contains(e.Node)) if (SelectedNodes.Contains(e.Node))
{ {
e.Node.BackColor = Color.Empty;
e.Node.ForeColor = Color.Empty;
SelectedNodes.Remove(e.Node); SelectedNodes.Remove(e.Node);
} }
else else
@ -2292,7 +2304,7 @@ namespace CodeWalker.Project.Panels
else else
{ {
bool start = false; bool start = false;
SelectedNodes.Clear(); ClearSelectedNodes();
foreach (TreeNode cnode in pnode.Nodes) foreach (TreeNode cnode in pnode.Nodes)
{ {
if (start) if (start)
@ -2316,7 +2328,7 @@ namespace CodeWalker.Project.Panels
} }
else else
{ {
SelectedNodes.Clear(); ClearSelectedNodes();
SelectedNodes.Add(e.Node); SelectedNodes.Add(e.Node);
} }
if (SelectedNodes.Count > 1) if (SelectedNodes.Count > 1)
@ -2324,6 +2336,8 @@ namespace CodeWalker.Project.Panels
var objs = new List<object>(); var objs = new List<object>();
foreach (var node in SelectedNodes) foreach (var node in SelectedNodes)
{ {
node.BackColor = SystemColors.Highlight;
node.ForeColor = SystemColors.HighlightText;
objs.Add(node.Tag); objs.Add(node.Tag);
} }
OnItemSelected?.Invoke(objs.ToArray()); OnItemSelected?.Invoke(objs.ToArray());