コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ViewModel"/> class.
        /// </summary>
        public ViewModel()
        {
            ConnectCommand = new AsyncCommand(Connect, () => IsDisconnected);

            NavigateToServerFolderCommand = new AsyncCommand(NavigateToSelectedServerFolder,
                                                             () => SelectedServerItem != null && SelectedServerItem.IsDir);
            NavigateToClientFolderCommand = new Command(NavigateToSelectedClientFolder, () => SelectedClientFolder != null);
            NavigateToSelectedClientFolder();

            DownloadCommand = new AsyncCommand(async() =>
            {
                filesToDownload.Add(SelectedServerItem);
                await DownloadSelectedFiles();
            }, () => SelectedServerItem != null && !SelectedServerItem.IsDir);

            DownloadAllCommand = new AsyncCommand(async() =>
            {
                foreach (var item in ServerFoldersAndFiles)
                {
                    if (!item.IsDir)
                    {
                        filesToDownload.Add(item);
                    }
                }
                await DownloadSelectedFiles();
            }, () => ServerFoldersAndFiles.Any(item => !item.IsDir));

            ClearCommand = new Command(ClearDownloads, () => Downloads.Count() > 0);
        }
コード例 #2
0
 public async void LoadAsync()
 {
     await Task.Factory.StartNew(async() =>
     {
         await DispatcherHelper.RunAsync(() =>
         {
             Downloads = ConvertToObservable(_service.GetDownloads());
             Message   = (Downloads != null && Downloads.Count() > 0)
             ? Core.StringMessage.NoMessge
             : Core.StringMessage.EmptyMessage;
         });
     });
 }
コード例 #3
0
        private async Task Start()
        {
            var currentlyRunning = Downloads.Count(dt => dt.Task.Status == TaskStatus.Running);

            if (currentlyRunning >= ConcurrentConnections)
            {
                return;
            }

            var startNew = Downloads.FirstOrDefault(dt => dt.Image.State == Image.DownloadState.Enqueued);

            if (startNew == null)
            {
                return;
            }

            startNew.Image.State = Image.DownloadState.Downloading;
            startNew.Task.Start();
            int i = 0;

            i++;
        }
コード例 #4
0
        /// <summary>
        /// 処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Timer_Tick(object sender, EventArgs e)
        {
            if (Current != null)
            {
                // ダウンロード中データが存在する場合は中断
                return;
            }
            if (!Downloads.Any())
            {
                // ステータス完了状態に移行
                IsDownloding = false;
                Message      = "";

                // ダウンロード待ちが存在しない場合は中断
                return;
            }

            // ダウンロード中に設定
            Current = Downloads.First();
            Downloads.Remove(Current);

            // ステータス更新
            IsDownloding = true;
            Message      = string.Format("ID:{0} ダウンロード中 / {1} ファイル ダウンロード待ち ", Current.VideoId, Downloads.Count());

            // ダウンロード開始
            await Download(Current);

            Current = null;
        }
コード例 #5
0
 private void SetTotalFilesProgress()
 {
     TotalFilesToDownload = Downloads.Count();
 }
コード例 #6
0
 private void SetFilesToDownloadProgress()
 {
     FilesToDownload = Downloads.Count(x => x.Download.State == CurrentDownloadState.Download);
 }