示例#1
0
 static void ToViewModel(HttpTransferViewModel viewModel, HttpTransfer transfer)
 {
     // => Math.Round(this.transfer.BytesPerSecond.Bytes().Kilobytes, 2) + " Kb/s";
     //public string EstimateMinsRemaining => Math.Round(this.transfer.EstimatedCompletionTime.TotalMinutes, 1) + " min(s)";
     //viewModel.EstimateMinsRemaining =
     viewModel.PercentComplete     = transfer.PercentComplete;
     viewModel.PercentCompleteText = $"{transfer.PercentComplete * 100}%";
     viewModel.Status = transfer.Status.ToString();
 }
示例#2
0
        public PendingViewModel(INavigationService navigation,
                                IHttpTransferManager httpTransfers,
                                IUserDialogs dialogs)
        {
            this.httpTransfers = httpTransfers;
            this.dialogs       = dialogs;

            this.Create = navigation.NavigateCommand("CreateTransfer");

            this.Load = ReactiveCommand.CreateFromTask(async() =>
            {
                var transfers  = await httpTransfers.GetTransfers();
                this.Transfers = transfers
                                 .Select(transfer =>
                {
                    var vm = new HttpTransferViewModel
                    {
                        Identifier = transfer.Identifier,
                        Uri        = transfer.Uri,
                        IsUpload   = transfer.IsUpload,

                        Cancel = ReactiveCommand.CreateFromTask(async() =>
                        {
                            var confirm = await dialogs.Confirm("Are you sure you want to cancel all transfers?", "Confirm", "Yes", "No");
                            if (confirm)
                            {
                                await this.httpTransfers.Cancel(transfer.Identifier);
                                await this.Load.Execute();
                            }
                        })
                    };

                    ToViewModel(vm, transfer);
                    return(vm);
                })
                                 .ToList();
            });
            this.CancelAll = ReactiveCommand.CreateFromTask(async() =>
            {
                await httpTransfers.Cancel();
                await this.Load.Execute().ToTask();
            });
            this.BindBusyCommand(this.Load);
        }
示例#3
0
 static void ToViewModel(HttpTransferViewModel viewModel, HttpTransfer transfer)
 {
     viewModel.PercentComplete     = transfer.PercentComplete;
     viewModel.PercentCompleteText = $"{transfer.PercentComplete * 100}%";
     viewModel.Status = transfer.Status.ToString();
 }