From 505080e9b170c19d83a32865852a3d08b0c5952a Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Sun, 3 Aug 2025 01:32:19 +1000 Subject: [PATCH] open another sln --- .../Components/SolutionPickerDialog.razor | 5 +++- src/SharpIDE.Photino/Layout/MainLayout.razor | 26 ++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/SharpIDE.Photino/Components/SolutionPickerDialog.razor b/src/SharpIDE.Photino/Components/SolutionPickerDialog.razor index eabbd9d..e9123c6 100644 --- a/src/SharpIDE.Photino/Components/SolutionPickerDialog.razor +++ b/src/SharpIDE.Photino/Components/SolutionPickerDialog.razor @@ -17,6 +17,9 @@ [CascadingParameter] public IMudDialogInstance MudDialog { get; set; } = null!; + [Parameter] + public bool AutoOpenLastSolution { get; set; } + private string? _solutionFilePath; protected override void OnInitialized() @@ -28,7 +31,7 @@ { if (firstRender) { - if (AppState.IdeSettings.AutoOpenLastSolution && !string.IsNullOrWhiteSpace(_solutionFilePath)) + if (AutoOpenLastSolution && !string.IsNullOrWhiteSpace(_solutionFilePath)) { MudDialog.Close(_solutionFilePath); } diff --git a/src/SharpIDE.Photino/Layout/MainLayout.razor b/src/SharpIDE.Photino/Layout/MainLayout.razor index 72be714..4f883ab 100644 --- a/src/SharpIDE.Photino/Layout/MainLayout.razor +++ b/src/SharpIDE.Photino/Layout/MainLayout.razor @@ -14,7 +14,7 @@ - + @@ -77,15 +77,7 @@ protected override async Task OnInitializedAsync() { - var dialogRef = await DialogService.ShowAsync("Open Solution", new DialogOptions { FullWidth = true, MaxWidth = MaxWidth.Medium, BackdropClick = false }); - 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; - - var solutionModel = await VsPersistenceMapper.GetSolutionModel(_solutionFilePath); - _solutionModel = solutionModel; + await LoadSolutionFromInteractivePicker(AppState.IdeSettings.AutoOpenLastSolution); if (AppState.IdeSettings.AutoOpenTerminalOnLaunch) { _ = Task.Run(async () => @@ -98,6 +90,20 @@ } } + private async Task LoadSolutionFromInteractivePicker() => await LoadSolutionFromInteractivePicker(false); + private async Task LoadSolutionFromInteractivePicker(bool autoOpenLastSolution) + { + var dialogRef = await DialogService.ShowAsync("Open Solution",new DialogParameters { [nameof(SolutionPickerDialog.AutoOpenLastSolution)] = autoOpenLastSolution }, new DialogOptions { FullWidth = true, MaxWidth = MaxWidth.Medium, BackdropClick = false }); + 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; + + var solutionModel = await VsPersistenceMapper.GetSolutionModel(_solutionFilePath); + _solutionModel = solutionModel; + } + private CancellationTokenSource? _cancellationTokenSource = null!; private async Task BuildSolution() => await MsBuildSolution(BuildType.Build); private async Task RebuildSolution() => await MsBuildSolution(BuildType.Rebuild);