run panel v1

This commit is contained in:
Matt Parker
2025-08-09 02:09:06 +10:00
parent 4ceaafd75e
commit 4ba04c3082
3 changed files with 59 additions and 8 deletions

View File

@@ -50,6 +50,7 @@ public class RunService
}); });
project.Running = true; project.Running = true;
project.OpenInRunPanel = true;
GlobalEvents.InvokeProjectsRunningChanged(); GlobalEvents.InvokeProjectsRunningChanged();
await process.WaitForExitAsync().WaitAsync(project.RunningCancellationTokenSource.Token).ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing); await process.WaitForExitAsync().WaitAsync(project.RunningCancellationTokenSource.Token).ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);
if (project.RunningCancellationTokenSource.IsCancellationRequested) if (project.RunningCancellationTokenSource.IsCancellationRequested)

View File

@@ -34,4 +34,7 @@ public class SharpIdeProjectModel : ISharpIdeNode
public Project MsBuildEvaluationProject => MsBuildEvaluationProjectTask.IsCompletedSuccessfully public Project MsBuildEvaluationProject => MsBuildEvaluationProjectTask.IsCompletedSuccessfully
? MsBuildEvaluationProjectTask.Result ? MsBuildEvaluationProjectTask.Result
: throw new InvalidOperationException("Do not attempt to access the MsBuildEvaluationProject before it has been loaded"); : throw new InvalidOperationException("Do not attempt to access the MsBuildEvaluationProject before it has been loaded");
public bool IsRunnable => MsBuildEvaluationProject.GetPropertyValue("OutputType") is "Exe" or "WinExe";
public bool OpenInRunPanel { get; set; }
} }

View File

@@ -1,19 +1,66 @@
@using SharpIDE.Application.Features.Run @using SharpIDE.Application.Features.Events
@using SharpIDE.Application.Features.Run
@using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence @using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence
@implements IDisposable
@inject RunService RunService @inject RunService RunService
<MudStack Style="height: 100%"> <MudStack Style="height: 100%">
<MudText>Run</MudText> <style>
@foreach(var projects in SolutionModel.AllProjects) .lowercase-tab-header {
{ text-transform: none;
<MudButton OnClick="@(async () => await RunService.RunProject(projects))" Variant="Variant.Filled" Color="Color.Primary" Style="margin: 4px;"> }
<MudText>@projects.Name</MudText> </style>
</MudButton> @* <MudText>Run</MudText> *@
} <MudTabs KeepPanelsAlive="true" TabPanelClass="lowercase-tab-header">
<ChildContent>
@foreach (var tab in OpenTabs)
{
<MudTabPanel ID="@tab" Text="@tab.Name">
Tab content
</MudTabPanel>
}
</ChildContent>
<TabPanelHeader>
@if (context.ID is SharpIdeProjectModel project)
{
@if (project.Running)
{
<MudIcon Icon="@Icons.Material.Filled.Circle" Color="Color.Success"/>
}
else
{
<MudIconButton Class="ml-2 pa-1" Color="Color.Inherit" Size="Size.Small" Icon="@Icons.Material.Filled.Close" OnClick="@(() => CloseTab(project))"/>
}
}
else throw new InvalidOperationException("Tab ID must be of type SharpIdeProjectModel");
</TabPanelHeader>
</MudTabs>
</MudStack> </MudStack>
@code { @code {
[Parameter, EditorRequired] [Parameter, EditorRequired]
public SharpIdeSolutionModel SolutionModel { get; set; } = null!; public SharpIdeSolutionModel SolutionModel { get; set; } = null!;
private IEnumerable<SharpIdeProjectModel> OpenTabs => SolutionModel.AllProjects.Where(s => s.OpenInRunPanel);
protected override async Task OnInitializedAsync()
{
var tasks = SolutionModel.AllProjects.Select(p => p.MsBuildEvaluationProjectTask);
await Task.WhenAll(tasks);
GlobalEvents.ProjectsRunningChanged += OnProjectsRunningChanged;
}
private void CloseTab(SharpIdeProjectModel project)
{
project.OpenInRunPanel = false;
}
private async Task OnProjectsRunningChanged()
{
await InvokeAsync(StateHasChanged);
}
public void Dispose() => GlobalEvents.ProjectsRunningChanged -= OnProjectsRunningChanged;
} }