From dea219ea90783e8871b6aade845892917818f565 Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Thu, 31 Jul 2025 19:43:02 +1000 Subject: [PATCH] Load solution explorer from dialog --- src/SharpIDE.Photino/App.razor | 4 ++ .../Components/SolutionExplorer.razor | 8 ++- src/SharpIDE.Photino/Layout/MainLayout.razor | 28 ++++++++--- src/SharpIDE.Photino/Pages/Home.razor | 50 +++++++++---------- 4 files changed, 57 insertions(+), 33 deletions(-) diff --git a/src/SharpIDE.Photino/App.razor b/src/SharpIDE.Photino/App.razor index d832b2f..a5b54ca 100644 --- a/src/SharpIDE.Photino/App.razor +++ b/src/SharpIDE.Photino/App.razor @@ -1,3 +1,7 @@ + + + + diff --git a/src/SharpIDE.Photino/Components/SolutionExplorer.razor b/src/SharpIDE.Photino/Components/SolutionExplorer.razor index be350e5..9e29879 100644 --- a/src/SharpIDE.Photino/Components/SolutionExplorer.razor +++ b/src/SharpIDE.Photino/Components/SolutionExplorer.razor @@ -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 _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) diff --git a/src/SharpIDE.Photino/Layout/MainLayout.razor b/src/SharpIDE.Photino/Layout/MainLayout.razor index cf970f9..c9503a3 100644 --- a/src/SharpIDE.Photino/Layout/MainLayout.razor +++ b/src/SharpIDE.Photino/Layout/MainLayout.razor @@ -1,21 +1,25 @@ @inherits LayoutComponentBase - - - - +@inject IDialogService DialogService - + @if (_solutionFilePath is not null) + { + + } @* *@ - @Body + @* @Body *@ + @if (_solutionFilePath is not null) + { + + } @@ -27,4 +31,16 @@ { _drawerOpen = !_drawerOpen; } + + private string? _solutionFilePath; + + protected override async Task OnInitializedAsync() + { + var dialogRef = await DialogService.ShowAsync("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; + } } diff --git a/src/SharpIDE.Photino/Pages/Home.razor b/src/SharpIDE.Photino/Pages/Home.razor index 5b4a894..9447846 100644 --- a/src/SharpIDE.Photino/Pages/Home.razor +++ b/src/SharpIDE.Photino/Pages/Home.razor @@ -1,27 +1,27 @@ @page "/" -@using SharpIDE.Application.Features.SolutionDiscovery - -@inject IDialogService DialogService - -@if (_solutionFilePath is not null) -{ - -} - -@code -{ - - private string? _solutionFilePath; - - protected override async Task OnInitializedAsync() - { - var dialogRef = await DialogService.ShowAsync("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) *@ +@* { *@ +@* *@ +@* } *@ +@* *@ +@* @code *@ +@* { *@ +@* *@ +@* private string? _solutionFilePath; *@ +@* *@ +@* protected override async Task OnInitializedAsync() *@ +@* { *@ +@* var dialogRef = await DialogService.ShowAsync("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); *@ +@* } *@ +@* } *@