Ejemplo n.º 1
0
        void ProcessTransferUpdate(FileTransfer transfer)
        {
            int idx = this.ViewModel.FindIndexById(transfer.Id);

            if (idx == -1)
            {
                Log.WarnFormat("Could not notify ViewModel, id={0}", transfer.Id);
            }
            else
            {
                // update items
                FileTransferViewItem viewItem = this.ViewModel.FileTransfers[idx];
                viewItem.Progress   = transfer.PercentComplete;
                viewItem.Status     = transfer.TransferStatus;
                viewItem.Message    = transfer.TransferStatusMsg;
                viewItem.Start      = transfer.StartTime;
                viewItem.End        = transfer.EndTime;
                viewItem.CanCancel  = FileTransfer.CanCancel(viewItem.Status);
                viewItem.CanRestart = FileTransfer.CanRestart(viewItem.Status);
                viewItem.CanDelete  = FileTransfer.CanRestart(viewItem.Status);

                // notify on update
                this.ViewModel.FileTransfers.ResetItem(idx);
            }
        }
Ejemplo n.º 2
0
        public void Restart(int id)
        {
            FileTransfer transfer = GetById(id);

            if (transfer != null)
            {
                if (FileTransfer.CanRestart(transfer.TransferStatus))
                {
                    transfer.Start();
                }
                else
                {
                    throw new InvalidOperationException("Can not restart active transfer, id=" + id);
                }
            }
        }
Ejemplo n.º 3
0
        public void Remove(int id)
        {
            FileTransfer transfer = GetById(id);

            if (transfer != null)
            {
                if (FileTransfer.CanRestart(transfer.TransferStatus))
                {
                    this.fileTranfers.Remove(id);
                    transfer.Update -= transfer_Update;
                    int idx = this.ViewModel.FindIndexById(id);
                    if (idx != -1)
                    {
                        this.ViewModel.FileTransfers.RemoveAt(idx);
                    }
                }
                else
                {
                    Log.WarnFormat("Could not remove active FileTransfer, id={0}", id);
                }
            }
        }