Skip to content

Commit 745f054

Browse files
committed
Bold lables if a node is collapsed and has children
1 parent a8d5af6 commit 745f054

File tree

13 files changed

+259
-13
lines changed

13 files changed

+259
-13
lines changed

CSharpCodeAnalyst/Areas/GraphArea/MsaglBuilderBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private static Color ToColor(int colorValue)
100100
return new Color((byte)r, (byte)g, (byte)b);
101101
}
102102

103-
protected static Node CreateNode(Graph graph, CodeElement codeElement, PresentationState presentationState)
103+
protected virtual Node CreateNode(Graph graph, CodeElement codeElement, PresentationState presentationState)
104104
{
105105
var node = graph.AddNode(codeElement.Id);
106106
node.LabelText = codeElement.Name;

CSharpCodeAnalyst/Areas/GraphArea/MsaglFlatBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public override Graph CreateGraph(CodeGraph codeGraph, PresentationState present
1212
return CreateFlatGraph(codeGraph, presentationState, showInformationFlow, hideFilter);
1313
}
1414

15-
private static Graph CreateFlatGraph(CodeGraph codeGraph, PresentationState presentationState, bool showInformationFlow, GraphHideFilter hideFilter)
15+
private Graph CreateFlatGraph(CodeGraph codeGraph, PresentationState presentationState, bool showInformationFlow, GraphHideFilter hideFilter)
1616
{
1717
// Since we start with a fresh graph we don't need to check for existing nodes and edges.
1818

CSharpCodeAnalyst/Areas/GraphArea/MsaglHierarchicalBuilder.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,20 @@ private static void CollectVisibleNodes(CodeElement root, PresentationState stat
6464
}
6565
}
6666

67-
private static void AddNodesToHierarchicalGraph(Graph graph, CodeGraph visibleGraph, CodeGraph codeGraph,
67+
protected override Node CreateNode(Graph graph, CodeElement codeElement, PresentationState presentationState)
68+
{
69+
var node = base.CreateNode(graph, codeElement, presentationState);
70+
71+
if (codeElement.Children.Any() && presentationState.IsCollapsed(codeElement.Id))
72+
{
73+
// This is a collapsed node. Show bold if it hides children and can be expanded.
74+
node.Label.FontStyle = FontStyle.Bold;
75+
}
76+
77+
return node;
78+
}
79+
80+
private void AddNodesToHierarchicalGraph(Graph graph, CodeGraph visibleGraph, CodeGraph codeGraph,
6881
Dictionary<string, Subgraph> subGraphs, PresentationState presentationState)
6982
{
7083
// Add nodes and sub graphs. Each node that has children becomes a subgraph.
@@ -99,7 +112,7 @@ private static void AddSubgraphToParent(Graph graph, CodeElement visibleNode, Su
99112
}
100113
}
101114

102-
private static void AddNodeToParent(Graph graph, CodeElement node, Dictionary<string, Subgraph> subGraphs, PresentationState presentationState)
115+
private void AddNodeToParent(Graph graph, CodeElement node, Dictionary<string, Subgraph> subGraphs, PresentationState presentationState)
103116
{
104117
var newNode = CreateNode(graph, node, presentationState);
105118
if (node.Parent != null)

CSharpCodeAnalyst/AssemblyInfo.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Windows;
2+
using System.Runtime.CompilerServices;
23

34
[assembly: ThemeInfo(
45
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
@@ -7,4 +8,7 @@
78
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
89
//(used if a resource is not found in the page,
910
// app, or any theme specific resource dictionaries)
10-
)]
11+
)]
12+
13+
// Allow test project to access internal types for unit testing (e.g., MsaglHierarchicalBuilder)
14+
[assembly: InternalsVisibleTo("Tests")]

CSharpCodeAnalyst/MainViewModel.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,15 +1047,10 @@ private void RestoreProjectData(ProjectData projectData)
10471047
// Restore analyzer data
10481048
_analyzerManager.RestoreAnalyzerData(projectData.AnalyzerData);
10491049
}
1050-
1051-
1052-
1053-
1054-
10551050

10561051
public void ClearQuickInfo()
10571052
{
10581053
_infoPanelViewModel?.ClearQuickInfo();
1059-
_graphViewModel.ClearQuickInfo();
1054+
_graphViewModel?.ClearQuickInfo();
10601055
}
10611056
}
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
512 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

ReferencedAssemblies/Note.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
This folder contains the MSAGL assemblies.
22

3-
Instead of the NUGET package, a modified version built from the fork https://github.com/ATrefzer/automatic-graph-layout (branch: `csharp-code-analyst-changes`) is used.
3+
Instead of the NUGET package, a modified version built from the fork https://github.com/ATrefzer/automatic-graph-layout (branch: csharp-code-analyst-changes) is used.
44

55
**Changes**
66

7-
- Hide the collapse button for subgraphs by default and use a context menu for collapse/expand. The original repository had bugs, which are now resolved. However, this approach has the added benefit of enabling lazy loading, allowing handling of very large graphs that are initially collapsed.
7+
- Hide the collapse button for subgraphs by default. I use now my own mechanism to collapse/expand. The original repository had bugs, making it unusable. Instead, I handle collapse now by rendering a completely new graph. This approach has the added benefit of enabling lazy loading, allowing handling of huge graphs that are initially collapsed.
88
- Performance optimized Canvas
9+
- Added possibility to use font styles for the labels.
910

11+
12+
13+
**Note**
14+
15+
Compile Samples\WpfApplicationSample to get all assemblies at once.

0 commit comments

Comments
 (0)