Open sln picker
This commit is contained in:
30
src/SharpIDE.Photino/Components/SolutionPickerDialog.razor
Normal file
30
src/SharpIDE.Photino/Components/SolutionPickerDialog.razor
Normal file
@@ -0,0 +1,30 @@
|
||||
@using Ardalis.GuardClauses
|
||||
@using global::Photino.Blazor
|
||||
|
||||
@inject PhotinoBlazorApp PhotinoBlazorApp
|
||||
|
||||
<MudStack Class="mx-4">
|
||||
<MudTextField T="string" Label="Solution File" Value="@_solutionFilePath" ReadOnly="true" />
|
||||
<MudButton OnClick="@PickSolution">Pick Solution</MudButton>
|
||||
<MudButton OnClick="@Proceed" Disabled="@(string.IsNullOrWhiteSpace(_solutionFilePath))">Open</MudButton>
|
||||
</MudStack>
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,27 @@
|
||||
@page "/"
|
||||
|
||||
@using SharpIDE.Application.Features.SolutionDiscovery
|
||||
|
||||
<CodeViewer FilePath="C:\Users\matth\Documents\Git\SharpIDE.Photino\src\SharpIDE.Photino\Program.cs" />
|
||||
@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()
|
||||
{
|
||||
await Task.Delay(100);
|
||||
await RoslynTest.Analyse("C:/Users/matth/Documents/Git/SharpIDE.Photino/SharpIDE.Photino.sln");
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Ardalis.GuardClauses" Version="5.0.0" />
|
||||
<PackageReference Include="BlazorMonaco" Version="3.3.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components" Version="9.0.7" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebView" Version="9.0.7" />
|
||||
|
||||
Reference in New Issue
Block a user