-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndex.razor
More file actions
170 lines (137 loc) · 6.86 KB
/
Copy pathIndex.razor
File metadata and controls
170 lines (137 loc) · 6.86 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
@using NodeDev.Blazor.Services
@inject Services.DebuggedPathService DebuggedPathService
@inject NavigationManager NavigationManager
@inject ISnackbar Snackbar
@inject ProjectService ProjectService
@implements IDisposable
<MudThemeProvider />
<MudPopoverProvider />
<MudDialogProvider />
<MudSnackbarProvider />
<MudLayout Style="height: 100vh; width: 100%; overflow: hidden">
<MudAppBar Elevation="1" data-test-id="appBar">
<ProjectToolbar />
</MudAppBar>
<MudMainContent Style="width: 100%; height: 100%; overflow-y: hidden">
<MudExtensions.MudSplitter EnableSlide="true" Sensitivity="0.01" @bind-Dimension="ProjectExplorerGraphPercentage" Class="wh100 overflow-hidden relative">
<StartContent>
<MudTabs Elevation="2" Rounded="true" ApplyEffectsToContainer="true" PanelClass="pa-2 wh100" KeepPanelsAlive="true" Class="wh100" data-test-id="ProjectExplorerSection">
<MudTabPanel Text="Project">
<ProjectExplorer Project="ProjectService.Project" @bind-SelectedClass="SelectedClass"></ProjectExplorer>
</MudTabPanel>
<MudTabPanel Text="Class">
@if (SelectedClass != null)
{
<ClassExplorer @key="SelectedClass" Class="SelectedClass" SelectedMethodChanged="OpenMethod"></ClassExplorer>
}
</MudTabPanel>
</MudTabs>
</StartContent>
<EndContent>
<MudExtensions.MudSplitter Class="wh100 pa-1 relative overflow-y-hidden" ClassContent="relative" @bind-Dimension="SourceViewerGraphPercentage">
<StartContent>
@* The 'relative' div is used to control the "Open/Close" icon for the debugger console panel as well as the source viewer open icon *@
<div class="wh100 relative flex-1 overflow-y-hidden">
<div class="h100 absolute d-flex" style="left: 0px; z-index: 99999">
<MudIconButton Icon="@(ProjectExplorerGraphPercentage >= ProjectExplorer_OpenedGraphPercentage ? Icons.Material.Filled.ArrowLeft : Icons.Material.Filled.ArrowRight)" OnClick="SwitchProjectViewerGraph" Style="margin-top: auto; margin-bottom: auto" />
</div>
<MudStack Row="false" Class="wh100">
<DebuggedPathView OpenMethod="OpenMethodFromDebuggedPath" />
<CascadingValue Value="this" IsFixed="true">
<MudTabs @ref="Tabs" Elevation="2" Rounded="true" ApplyEffectsToContainer="true" PanelClass="pa-2 wh100" KeepPanelsAlive="true" Class="wh100" @bind-ActivePanelIndex="ActivePanelIndex">
@foreach (var method in OpenedMethods)
{
<MudTabPanel ID="method" @key="method" Text="@method.Name">
<GraphCanvas @key="method.Graph" Graph="method.Graph"></GraphCanvas>
</MudTabPanel>
}
</MudTabs>
</CascadingValue>
<DebuggerConsolePanel Project="ProjectService.Project" />
</MudStack>
</div>
<div class="h100 absolute d-flex" style="right: 0px">
<MudIconButton Icon="@(SourceViewerGraphPercentage <= SourceViewer_OpenedGraphPercentage ? Icons.Material.Filled.ArrowRight : Icons.Material.Filled.ArrowLeft)" OnClick="SwitchSourceViewerGraph" Style="margin-top: auto; margin-bottom: auto" />
</div>
</StartContent>
<EndContent>
<SourceViewer Method="@(OpenedMethods.Count > 0 ? OpenedMethods[ActivePanelIndex] : null)" IsVisible="@(SourceViewerGraphPercentage != 100)" />
</EndContent>
</MudExtensions.MudSplitter>
</EndContent>
</MudExtensions.MudSplitter>
</MudMainContent>
</MudLayout>
@code {
private Core.Class.NodeClass? SelectedClass { get; set; }
private List<Core.Class.NodeClassMethod> OpenedMethods { get; } = new();
private MudTabs Tabs { get; set; } = null!;
private int ActivePanelIndex = 0;
private const double SourceViewer_OpenedGraphPercentage = 75;
private double SourceViewerGraphPercentage = 100;
private double SourceOpenedGraphPercentage = SourceViewer_OpenedGraphPercentage;
private const double ProjectExplorer_OpenedGraphPercentage = 18;
private double ProjectExplorerGraphPercentage = ProjectExplorer_OpenedGraphPercentage;
private double ProjectOpenedGraphPercentage = ProjectExplorer_OpenedGraphPercentage;
protected override void OnInitialized()
{
ProjectService.ProjectChanged += OnProjectChanged;
DebuggedPathService.ChangeProject(ProjectService.Project);
}
private void OnProjectChanged()
{
_ = InvokeAsync(() =>
{
DebuggedPathService.ChangeProject(ProjectService.Project);
NavigationManager.Refresh(true);
});
}
private void SwitchSourceViewerGraph()
{
if (SourceViewerGraphPercentage <= SourceViewer_OpenedGraphPercentage)
{
SourceOpenedGraphPercentage = SourceViewerGraphPercentage;
SourceViewerGraphPercentage = 100;
}
else
{
SourceViewerGraphPercentage = SourceOpenedGraphPercentage;
}
}
private void SwitchProjectViewerGraph()
{
if (ProjectExplorerGraphPercentage >= ProjectExplorer_OpenedGraphPercentage)
{
ProjectOpenedGraphPercentage = ProjectExplorerGraphPercentage;
ProjectExplorerGraphPercentage = 0;
}
else
{
ProjectExplorerGraphPercentage = ProjectOpenedGraphPercentage;
}
}
public void OpenMethodFromDebuggedPath(Core.Class.NodeClassMethod? method)
{
if (method == null)
{
// Find the main method
var program = ProjectService.Project.Classes.FirstOrDefault(x => x.Name == "Program");
// Find the main method in the program class
method = program?.Methods.FirstOrDefault(x => x.Name == "Main");
}
OpenMethod(method);
}
public void OpenMethod(Core.Class.NodeClassMethod? method)
{
if (method == null)
return;
if (!OpenedMethods.Contains(method))
OpenedMethods.Add(method);
ActivePanelIndex = OpenedMethods.IndexOf(method);
StateHasChanged();
}
public void Dispose()
{
ProjectService.ProjectChanged -= OnProjectChanged;
}
}