-
Notifications
You must be signed in to change notification settings - Fork 137
/
EntityClassGraphForm.cs
49 lines (40 loc) · 1.82 KB
/
EntityClassGraphForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System.Collections.Generic;
using System.Windows.Forms;
using SolarWinds.InformationService.InformationServiceClient;
using SwqlStudio.Utils;
namespace SwqlStudio
{
public partial class EntityClassGraphForm : Form
{
public EntityClassGraphForm(EntityClassGraph entityClassGraph)
{
DpiHelper.FixFont(this);
InitializeComponent();
LoadTree(entityClassGraph);
//The user will want to always expand the System.Entity node, so let's do it for them.
entityClassGraphTreeView.Nodes[0].Expand();
}
private void LoadTree(EntityClassGraph entityClassGraph)
{
entityClassGraphTreeView.Nodes.Clear();
if (entityClassGraph.Root == null)
return;
Stack<KeyValuePair<EntityMetadata, TreeNode>> baseClasses = new Stack<KeyValuePair<EntityMetadata, TreeNode>>();
//Add the root node.
TreeNode node = entityClassGraphTreeView.Nodes.Add(entityClassGraph.Root.FullName, entityClassGraph.Root.FullName, 3);
baseClasses.Push(new KeyValuePair<EntityMetadata, TreeNode>(entityClassGraph.Root, node));
foreach (EntityMetadata decendent in entityClassGraph.Root.Descendants)
{
//Find the base class that we belong to. Since the enumeration is pre-fix order, then we can find it as
//an ancestor of us.
while (!decendent.BaseClass.Equals(baseClasses.Peek().Key))
{
baseClasses.Pop();
}
//Add this child node.
node = baseClasses.Peek().Value.Nodes.Add(decendent.FullName, decendent.FullName, 3);
baseClasses.Push(new KeyValuePair<EntityMetadata, TreeNode>(decendent, node));
}
}
}
}