Beispiel #1
0
        private NetworkViewmodel()
        {
            this.downloading = new ObservableCollection <DownloadItem>();
            this.Downloading = new ReadOnlyObservableCollection <DownloadItem>(this.downloading);

            this.allQueued = new ObservableCollection <DownloadItem>();
            this.AllQueued = new ReadOnlyObservableCollection <DownloadItem>(this.allQueued);

            this.waitForDownloads = new ObservableQueue <DownloadItem>();
            this.WaitForDownloads = new ReadonlyObservableQueue <DownloadItem>(this.waitForDownloads);
            this.cancellation     = new CancellationTokenSource();

            this.CancelAllCommand = new DelegateCommand(() =>
            {
                this.CancelAllDownloads();
            }, () => this.downloading.Count > 0 || this.waitForDownloads.Count > 0);

            this.downloading.CollectionChanged += (sender, e) =>
            {
                ((DelegateCommand)this.CancelAllCommand).FireCanExecuteChanged();
            };

            this.waitForDownloads.CollectionChanged += (sender, e) =>
            {
                ((DelegateCommand)this.CancelAllCommand).FireCanExecuteChanged();
            };

            this.DownloadLoop();
        }
Beispiel #2
0
 public ReadonlyObservableQueue(ObservableQueue <T> queue)
 {
     this.queue = queue;
 }