Load solution explorer from dialog

This commit is contained in:
Matt Parker
2025-07-31 19:43:02 +10:00
parent f1a9414956
commit dea219ea90
4 changed files with 57 additions and 33 deletions

View File

@@ -1,3 +1,7 @@
<MudThemeProvider Theme="@AppThemeProvider.GetTheme()" IsDarkMode="true" />
<MudPopoverProvider/>
<MudDialogProvider/>
<MudSnackbarProvider/>
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">

View File

@@ -1,4 +1,5 @@
@using Microsoft.Build.Construction
@using Ardalis.GuardClauses
@using Microsoft.Build.Construction
@using SharpIDE.Application.Features.SolutionDiscovery
@if (_solutionFile is null)
@@ -15,6 +16,8 @@
@code {
[Parameter, EditorRequired]
public string SolutionFilePath { get; set; } = null!;
private SolutionFile _solutionFile = null!;
private List<ProjectInSolution> _rootNodes = [];
@@ -53,7 +56,8 @@
protected override async Task OnInitializedAsync()
{
await Task.Run(() => LoadSolution("C:/Users/matth/Documents/Git/SharpIDE.Photino/SharpIDE.Photino.sln"));
Guard.Against.NullOrWhiteSpace(SolutionFilePath);
await Task.Run(() => LoadSolution(SolutionFilePath));
}
private void LoadSolution(string solutionPath)

View File

@@ -1,21 +1,25 @@
@inherits LayoutComponentBase
<MudThemeProvider Theme="@AppThemeProvider.GetTheme()" IsDarkMode="true" />
<MudPopoverProvider/>
<MudDialogProvider/>
<MudSnackbarProvider/>
@inject IDialogService DialogService
<MudLayout>
<MudAppBar Dense="true">
<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="@((e) => DrawerToggle())" />
</MudAppBar>
<MudDrawer @bind-Open="@_drawerOpen" Width="400px" ClipMode="DrawerClipMode.Always">
<SolutionExplorer />
@if (_solutionFilePath is not null)
{
<SolutionExplorer SolutionFilePath="@_solutionFilePath"/>
}
@* <NavMenu/> *@
</MudDrawer>
<MudMainContent>
<MudContainer MaxWidth="MaxWidth.False" Class="mt-2">
@Body
@* @Body *@
@if (_solutionFilePath is not null)
{
<CodeViewer FilePath="C:\Users\matth\Documents\Git\SharpIDE.Photino\src\SharpIDE.Photino\Program.cs" />
}
</MudContainer>
</MudMainContent>
</MudLayout>
@@ -27,4 +31,16 @@
{
_drawerOpen = !_drawerOpen;
}
private string? _solutionFilePath;
protected override async Task OnInitializedAsync()
{
var dialogRef = await DialogService.ShowAsync<SolutionPickerDialog>("Open Solution", new DialogOptions { FullWidth = true, MaxWidth = MaxWidth.Medium });
var result = await dialogRef.Result;
if (result is null) throw new InvalidOperationException("Dialog result is null");
if (result.Canceled) throw new OperationCanceledException("Dialog was canceled");
var solutionFilePath = (string)result.Data!;
_solutionFilePath = solutionFilePath;
}
}

View File

@@ -1,27 +1,27 @@
@page "/"
@using SharpIDE.Application.Features.SolutionDiscovery
@inject IDialogService DialogService
@if (_solutionFilePath is not null)
{
<CodeViewer FilePath="C:\Users\matth\Documents\Git\SharpIDE.Photino\src\SharpIDE.Photino\Program.cs" />
}
@code
{
private string? _solutionFilePath;
protected override async Task OnInitializedAsync()
{
var dialogRef = await DialogService.ShowAsync<SolutionPickerDialog>("Open Solution", new DialogOptions { FullWidth = true, MaxWidth = MaxWidth.Medium });
var result = await dialogRef.Result;
if (result is null) throw new InvalidOperationException("Dialog result is null");
if (result.Canceled) throw new OperationCanceledException("Dialog was canceled");
var solutionFilePath = (string)result.Data!;
_solutionFilePath = solutionFilePath;
await RoslynTest.Analyse(_solutionFilePath);
}
}
@* @using SharpIDE.Application.Features.SolutionDiscovery *@
@* *@
@* @inject IDialogService DialogService *@
@* *@
@* @if (_solutionFilePath is not null) *@
@* { *@
@* <CodeViewer FilePath="C:\Users\matth\Documents\Git\SharpIDE.Photino\src\SharpIDE.Photino\Program.cs" /> *@
@* } *@
@* *@
@* @code *@
@* { *@
@* *@
@* private string? _solutionFilePath; *@
@* *@
@* protected override async Task OnInitializedAsync() *@
@* { *@
@* var dialogRef = await DialogService.ShowAsync<SolutionPickerDialog>("Open Solution", new DialogOptions { FullWidth = true, MaxWidth = MaxWidth.Medium }); *@
@* var result = await dialogRef.Result; *@
@* if (result is null) throw new InvalidOperationException("Dialog result is null"); *@
@* if (result.Canceled) throw new OperationCanceledException("Dialog was canceled"); *@
@* var solutionFilePath = (string)result.Data!; *@
@* _solutionFilePath = solutionFilePath; *@
@* await RoslynTest.Analyse(_solutionFilePath); *@
@* } *@
@* } *@