예제 #1
0
        private void Platform_DownloadStateChanged(object sender, DownloadStateChangedEventArgs e)
        {
            _currentState = e.state;
            switch (e.state)
            {
            case State.DownloadPreparing:
                UserInput    = null;
                Notification = "Preparing download...";
                break;

            case State.DownloadRunning:
                TotalImageCount          = e.TotalImageCount;
                Notification             = $"Downloading {e.TotalImageCount} images";
                RunDownloadCommand       = new RelayCommand(CancelDownload);
                RunDownloadButtonContent = "Cancel";
                RunDLButtonIsEnabled     = true;
                break;

            case State.DownloadCompleted:
                RunDownloadCommand       = new RelayCommand(RunDownload);
                RunDownloadButtonContent = "Download";
                Notification             = "Completed";
                if (e.FailedDownloads > 0)
                {
                    Notification += $", {e.FailedDownloads} images couldn't be downloaded";
                }
                break;

            case State.DownloadCanceled:
                RunDownloadCommand       = new RelayCommand(RunDownload);
                RunDownloadButtonContent = "Download";
                Notification             = "Canceled";
                if (e.ExceptionMsg != null)
                {
                    Notification += ": " + e.ExceptionMsg;
                }
                if (e.FailedDownloads > 0)
                {
                    Notification += $"\n{e.FailedDownloads} images couldn't be downloaded";
                }
                break;

            case State.ExceptionRaised:
#if DEBUG
                Debug.WriteLine($"ERR_MSG: {e.ExceptionMsg}");
#endif
                break;
            }
        }
        private void OnDownloadStateChanged(DownloadStateChangedEventArgs e)
        {
            OnPropertyChanged(nameof(IsStartAll));
            if (e.NewState == DownloadStateEnum.Completed || e.NewState == DownloadStateEnum.Canceled)
            {
                OnDownloadCompletedOrCanceled(e);
            }

            if (e.NewState == DownloadStateEnum.Downloading)
            {
                var temp      = DownloadTaskList.FirstOrDefault(item => item.FileId == e.FileId);
                var indexThis = DownloadTaskList.IndexOf(temp);
                if (indexThis != 0)
                {
                    DownloadTaskList.Insert(0, temp);
                    DownloadTaskList.Remove(temp);
                }
            }
            Debug.WriteLine($"{DateTime.Now}: FileId={e.FileId}, OldState={e.OldState}, NewState={e.NewState}, IsStartAll={IsStartAll}");
        }
예제 #3
0
        private void OnDownloadStateChanged(object sender, DownloadStateChangedEventArgs e)
        {
            RaisePropertyChanged(nameof(IsStartAll));
            if (e.NewState == DownloadStateEnum.Completed || e.NewState == DownloadStateEnum.Canceld)
            {
                OnDownloadCompletedOrCanceled(e);
            }

            if (e.NewState == DownloadStateEnum.Downloading)
            {
                var temp      = DownloadTaskList.FirstOrDefault(item => item.FileId == e.FileId);
                var indexThis = DownloadTaskList.IndexOf(temp);
                if (indexThis != 0)
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        DownloadTaskList.Insert(0, temp);
                        DownloadTaskList.Remove(temp);
                    });
                }
            }
            Debug.WriteLine($"{DateTime.Now}: FileId={e.FileId}, OldState={e.OldState}, NewState={e.NewState}, IsStartAll={IsStartAll}");
        }
예제 #4
0
        private async void Download_DownloadStateChangedEvent(object sender, DownloadStateChangedEventArgs e)
        {
            var info = (HttpDownload)sender;

            Debug.WriteLine($"PercentageChanged: Task: {info.DownloadPath} State: {e.OldState} -> {e.NewState}");


            var fileId = _database.GetFileIdByPath(info.DownloadPath);

            switch (e.NewState)
            {
            case DownloadStateEnum.Completed:
                _database.SetCompleted(info.DownloadPath);
                _downloadingTasks.Remove(info);
                GetNextTask();
                break;

            case DownloadStateEnum.Waiting:
                _downloadingTasks.Remove(info);
                //暂停所做操作
                break;
            }
        }
예제 #5
0
 //--------------------------------------------------------Events:---------------------------------------------------------------------\\
 #region --Events--
 private void DOWNLOAD_HANDLER_DownloadStateChanged(AbstractDownloadableObject o, DownloadStateChangedEventArgs args)
 {
     if (o is ImageTable image)
     {
         ImageDBManager.INSTANCE.setImage(image);
     }
 }
 private void OnDownloadCompletedOrCanceled(DownloadStateChangedEventArgs e)
 {
     DownloadTaskList.Remove(DownloadTaskList.FirstOrDefault(item => item.FileId == e.FileId));
     OnPropertyChanged(nameof(TotalDownloadQuantity));
     OnDownloadPregressChanged(null);
 }
 private void OnDownloadStateChanged(DownloadStateChangedEventArgs e)
 {
     DownloadSpeed = new DataSize();
     DownloadState = e.NewState;
 }
 public void OnDownloadStateChanged(object sender, DownloadStateChangedEventArgs e)
 {
     DownloadSpeed = new DataSize();
     DownloadState = e.NewState;
 }
 private void OnDownloadStateChanged(DownloadStateChangedEventArgs e)
 {
 }
예제 #10
0
 private static void Client_DownloadStateChanged(object sender, DownloadStateChangedEventArgs e)
 {
     Console.WriteLine($"[DOWNLOAD] [{e.Filename}]: {e.PreviousState} ==> {e.State}");
 }
 private async void Img_DownloadStateChanged(ImageTable img, DownloadStateChangedEventArgs args)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => await showImageAsync(img));
 }