コード例 #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();
        }
コード例 #2
0
 public ReadonlyObservableQueue(ObservableQueue <T> queue)
 {
     this.queue = queue;
 }