Skip to content

Commit

Permalink
修复任务进度显示问题
Browse files Browse the repository at this point in the history
  • Loading branch information
YangSpring114 committed Oct 2, 2024
1 parent f4f0c45 commit d423e93
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
5 changes: 4 additions & 1 deletion WonderLab/Classes/Datas/TaskData/TaskStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ namespace WonderLab.Classes.Datas.TaskData;
/// </summary>
public partial class TaskStep : ObservableObject {
[ObservableProperty] private string _stepName;
[ObservableProperty] private double _progress;
[ObservableProperty] private double _maxProgress = 1d;
[ObservableProperty] private TaskStatus _taskStatus = TaskStatus.WaitingToRun;

[ObservableProperty]
[NotifyPropertyChangedFor(nameof(ProgressText))]
private double _progress;

public double ProgressValue => Progress * 100;
public string ProgressText => Progress.ToString("P2");
}
9 changes: 8 additions & 1 deletion WonderLab/Services/Game/LaunchService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Avalonia.Threading;
using Avalonia.Controls.Notifications;
using MinecraftLaunch;
using MinecraftLaunch.Classes.Enums;
using MinecraftLaunch.Classes.Models.Auth;
Expand All @@ -12,6 +12,7 @@
using System.Threading;
using System.Threading.Tasks;
using WonderLab.Classes.Datas.TaskData;
using WonderLab.Classes.Datas.ViewData;
using WonderLab.Services.Auxiliary;

namespace WonderLab.Services.Game;
Expand All @@ -35,6 +36,12 @@ public LaunchService(GameService gameService, TaskService taskService, AccountSe
}

public async Task LaunchWithDisplayTaskAsync(Account account) {
_notificationService.QueueJob(new NotificationViewData {
Title = "信息",
Content = $"已将游戏 \"{_gameService.ActiveGameEntry.Entry.Id}\" 的启动任务添加至调度队列",
NotificationType = NotificationType.Information
});

var task = new LaunchDisplayTask {
JobName = $"{_gameService.ActiveGameEntry.Entry.Id} 的启动任务",
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,14 @@
RippleFill="{DynamicResource DividerBrush}">
<Grid RowDefinitions="1*, Auto">
<Grid ColumnDefinitions="Auto, Auto">
<controls:ProgressRing Height="15"
Width="15"
BorderThickness="2"
VerticalAlignment="Center"
Value="{Binding ProgressValue}"/>

<TextBlock FontSize="12"
Grid.Column="1"
Text="{Binding StepName}"
VerticalAlignment="Center"/>
Margin="8"
VerticalAlignment="Center">
<Run Text="{Binding StepName}"/>
<Run Text=" - "/>
<Run Text="{Binding ProgressText}"/>
</TextBlock>
</Grid>

<Separator Grid.Row="1"
Expand Down

0 comments on commit d423e93

Please sign in to comment.