public DownloadedPageViewModel(IUnityContainer container, ILocalDiskUserRepository localDiskUserRepository) : base(container) { _localDiskUserRepository = localDiskUserRepository; ClearAllRecordCommand = new Command(ClearAllRecordCommandExecute, () => DownloadTaskList?.Any() ?? false); EventAggregator.GetEvent <DownloadStateChangedEvent>().Subscribe( OnDownloadCompleted, Prism.Events.ThreadOption.UIThread, keepSubscriberReferenceAlive: false, filter: e => e.NewState == DownloadStateEnum.Completed); }
public DownloadingPageViewModel(IUnityContainer container, IMountUserRepository mountUserRepository) : base(container) { _mountUserRepository = mountUserRepository; Func <bool> isAnyElementInDownloadTaskList = () => DownloadTaskList?.Any() ?? false; PauseAllCommand = new Command(PauseAllCommandExecute, isAnyElementInDownloadTaskList); StartAllCommand = new Command(StartAllCommandExecute, isAnyElementInDownloadTaskList); CancelAllCommand = new Command(CancelAllCommandExecute, isAnyElementInDownloadTaskList); EventAggregator.GetEvent <DownloadProgressChangedEvent>().Subscribe(OnDownloadPregressChanged, ThreadOption.UIThread); EventAggregator.GetEvent <DownloadStateChangedEvent>().Subscribe(OnDownloadStateChanged, ThreadOption.UIThread); }
protected override void OnLoaded() { SetProperty(ref _netDiskUser, _mountUserRepository?.FirstOrDefault()?.GetCurrentNetDiskUser()); if (_netDiskUser == null) { DownloadTaskList.Clear(); return; } foreach (var item in _netDiskUser.GetUncompletedFiles()) { if (DownloadTaskList.Any(element => element.FileId == item.FileId)) { continue; } DownloadTaskList.Add(Container.Resolve <DownloadingTaskItemViewModel>(new DependencyOverride <IMountUser>(_mountUserRepository.FirstOrDefault()), new DependencyOverride <IDiskFile>(item))); } }
private void InitialDownloadList() { foreach (var item in TaskManager.GetTaskManagerByLocalDiskUser(_netDiskUser).GetUnCompletedList()) { if (DownloadTaskList.Any(element => element.FileId == item.FileId)) { continue; } var viewmodel = new DownloadingTaskItemViewModel(item); viewmodel.RemoveItemEvent += (task) => { DownloadTaskList.Remove(task); }; DownloadTaskList.Add(viewmodel); } }
protected override void OnLoaded() { TaskManager.GetTaskManagerByLocalDiskUser(MountUserRepository.MountedUser).TaskCollectionChanged += (httpdownload) => { Application.Current.Dispatcher.Invoke(() => { }); }; foreach (var item in TaskManager.GetTaskManagerByLocalDiskUser(MountUserRepository.MountedUser).GetCompletedList()) { if (DownloadTaskList.Any(element => element.FileId == item.FileId)) { continue; } DownloadTaskList.Add(new DownloadedTaskItemViewModel(item)); } }