diff --git a/src/SharpIDE.Photino/Components/SolutionPickerDialog.razor b/src/SharpIDE.Photino/Components/SolutionPickerDialog.razor new file mode 100644 index 0000000..200f93e --- /dev/null +++ b/src/SharpIDE.Photino/Components/SolutionPickerDialog.razor @@ -0,0 +1,30 @@ +@using Ardalis.GuardClauses +@using global::Photino.Blazor + +@inject PhotinoBlazorApp PhotinoBlazorApp + + + + Pick Solution + Open + + +@code { + [CascadingParameter] + public IMudDialogInstance MudDialog { get; set; } = null!; + + private string? _solutionFilePath; + + private async Task PickSolution() + { + var files = await PhotinoBlazorApp.MainWindow.ShowOpenFileAsync("Choose Solution File", filters: [("Solution File", [".sln"])]); + var slnFile = files.SingleOrDefault(); + _solutionFilePath = slnFile; + } + + private void Proceed() + { + Guard.Against.NullOrWhiteSpace(_solutionFilePath); + MudDialog.Close(_solutionFilePath); + } +} diff --git a/src/SharpIDE.Photino/Pages/Home.razor b/src/SharpIDE.Photino/Pages/Home.razor index acb2dae..5b4a894 100644 --- a/src/SharpIDE.Photino/Pages/Home.razor +++ b/src/SharpIDE.Photino/Pages/Home.razor @@ -1,13 +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() { - await Task.Delay(100); - await RoslynTest.Analyse("C:/Users/matth/Documents/Git/SharpIDE.Photino/SharpIDE.Photino.sln"); + 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); } } diff --git a/src/SharpIDE.Photino/SharpIDE.Photino.csproj b/src/SharpIDE.Photino/SharpIDE.Photino.csproj index ed06716..44528f5 100644 --- a/src/SharpIDE.Photino/SharpIDE.Photino.csproj +++ b/src/SharpIDE.Photino/SharpIDE.Photino.csproj @@ -17,6 +17,7 @@ +