Current Progress progressbar

This commit is contained in:
2023-07-01 22:28:46 +02:00
parent 01fce38b7d
commit 4f9e69f2ab
4 changed files with 16 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ namespace FileTime.App.Core.ViewModels.Timeline;
public interface ICommandTimeStateViewModel
{
IObservable<int> TotalProgress { get; }
IObservable<int> CurrentProgress { get; }
IObservable<string> DisplayLabel { get; }
IObservable<bool> IsSelected { get; }
}

View File

@@ -6,6 +6,7 @@ namespace FileTime.App.Core.ViewModels.Timeline;
public class CommandTimeStateViewModel : ICommandTimeStateViewModel
{
public IObservable<int> TotalProgress { get; }
public IObservable<int> CurrentProgress { get; }
public IObservable<string> DisplayLabel { get; }
@@ -15,6 +16,7 @@ public class CommandTimeStateViewModel : ICommandTimeStateViewModel
{
DisplayLabel = commandTimeState.Command.DisplayLabel;
TotalProgress = commandTimeState.Command.TotalProgress;
CurrentProgress = commandTimeState.Command.CurrentProgress;
//TODO
IsSelected = new BehaviorSubject<bool>(false);
}

View File

@@ -19,7 +19,6 @@ public class CopyCommand : CommandBase, ITransportationCommand
public FullName Target { get; }
public TransportMode TransportMode { get; }
public IObservable<OperationProgress?> CurrentOperationProgress { get; }
public CopyCommand(
ITimelessContentProvider timelessContentProvider,
@@ -31,7 +30,14 @@ public class CopyCommand : CommandBase, ITransportationCommand
{
_timelessContentProvider = timelessContentProvider;
_commandSchedulerNotifier = commandSchedulerNotifier;
CurrentOperationProgress = _currentOperationProgress.AsObservable();
_currentOperationProgress
.Select(p =>
{
if (p is null) return Observable.Never<int>();
return p.Progress.Select(currentProgress => (int)(currentProgress * 100 / p.TotalCount));
})
.Switch()
.Subscribe(SetCurrentProgress);
if (sources is null) throw new ArgumentException(nameof(Sources) + " can not be null");
if (targetFullName is null) throw new ArgumentException(nameof(Target) + " can not be null");
@@ -111,7 +117,7 @@ public class CopyCommand : CommandBase, ITransportationCommand
if (Sources.Count == 1)
{
SetDisplayLabel($"Copy - {Sources.First().GetName()}");
SetDisplayLabel($"Copy - {Sources[0].GetName()}");
}
else
{

View File

@@ -279,6 +279,10 @@
<Border BorderThickness="1" Classes.SelectedTimelineCommand="{Binding IsSelected}">
<StackPanel>
<TextBlock Text="{Binding DisplayLabel^}" />
<ProgressBar
Margin="0,5,0,0"
Maximum="100"
Value="{Binding CurrentProgress^}" />
<ProgressBar
Margin="0,5,0,0"
Maximum="100"