protected virtual string GetDownloadString(EDownloadTaskState downloadState)
        {
            string str;

            switch (downloadState)
            {
            case EDownloadTaskState.DLTaskPendingAttach:
            case EDownloadTaskState.DLTaskPending:
                str = Shell.LoadString(StringId.IDS_PENDING);
                break;

            case EDownloadTaskState.DLTaskDownloading:
            case EDownloadTaskState.DLTaskPaused:
                str = string.Format(Shell.LoadString(StringId.IDS_DOWNLOAD_PROGRESS), this.m_progress.ToString());
                break;

            case EDownloadTaskState.DLTaskComplete:
                str = Shell.LoadString(StringId.IDS_INCOLLECTION);
                break;

            default:
                str = Shell.LoadString(StringId.IDS_DOWNLOAD);
                break;
            }
            return(str);
        }
 private void UpdateDownloadTask()
 {
     if (this.m_downloadTask == null)
     {
         if (this.m_taskId == null)
         {
             return;
         }
         this.m_downloadTask = DownloadManager.Instance.GetTask(this.m_taskId);
         if (this.m_downloadTask == null)
         {
             return;
         }
         if (this.m_downloadState == EDownloadTaskState.DLTaskPendingAttach || this.m_downloadState == EDownloadTaskState.DLTaskPending || (this.m_downloadState == EDownloadTaskState.DLTaskDownloading || this.m_downloadState == EDownloadTaskState.DLTaskPaused))
         {
             this.m_downloadTask.OnProgressChanged += this.m_progressHandler;
         }
         this.m_progress      = (int)this.m_downloadTask.GetProgress();
         this.m_downloadState = this.m_downloadTask.GetState();
     }
     else
     {
         this.m_downloadState = this.m_downloadTask.GetState();
     }
 }
 public DownloadProgress(DownloadTask downloadTask)
     : base(downloadTask)
 {
     this.m_downloadTask  = downloadTask;
     this.m_downloadState = this.m_downloadTask.GetState();
     this.m_downloadTask.OnProgressChanged += new DownloadProgressHandler(this.OnProgressChanged);
     this.Available = false;
     this.UpdateState(null);
 }
 public void Refresh()
 {
     lock (this.m_myLock)
     {
         this.m_downloadState = this.GetDownloadState();
         if (this.m_downloadState == EDownloadTaskState.DLTaskDownloading)
         {
             this.UpdateDownloadTask();
         }
     }
     this.UpdateCommandState(null);
 }
 protected virtual void OnProgressChanged(DownloadEventArguments args)
 {
     lock (this.m_myLock)
     {
         this.m_downloadState = args.State;
         this.m_progress      = (int)args.Progress;
         if (this.m_downloadState != EDownloadTaskState.DLTaskDownloading)
         {
             if (this.m_downloadState != EDownloadTaskState.DLTaskPaused)
             {
                 if (this.m_downloadState != EDownloadTaskState.DLTaskPending)
                 {
                     if (this.m_downloadState != EDownloadTaskState.DLTaskPendingAttach)
                     {
                         this.m_downloadTask  = null;
                         this.m_downloadState = this.GetDownloadState();
                     }
                 }
             }
         }
     }
     Application.DeferredInvoke(new DeferredInvokeHandler(this.UpdateCommandState), DeferredInvokePriority.Normal);
 }
        private void UpdateState(object args)
        {
            this.Progress = -1f;
            float progress;

            if (args != null)
            {
                DownloadEventArguments downloadEventArguments = (DownloadEventArguments)args;
                this.m_downloadState = downloadEventArguments.State;
                progress             = downloadEventArguments.Progress;
            }
            else
            {
                this.m_downloadState = this.m_downloadTask.GetState();
                progress             = this.m_downloadTask.GetProgress();
            }
            switch (this.m_downloadState)
            {
            case EDownloadTaskState.DLTaskPendingAttach:
            case EDownloadTaskState.DLTaskPending:
                this.Description = Shell.LoadString(StringId.IDS_PENDING);
                this.Available   = false;
                break;

            case EDownloadTaskState.DLTaskDownloading:
                this.UpdateProgress(Guid.Empty, progress);
                if (this.SecondsToProgressivePlayback == 0)
                {
                    this.Description = Shell.LoadString(StringId.IDS_PLAY_SONG);
                }
                else
                {
                    this.Description = string.Format(Shell.LoadString(StringId.IDS_DOWNLOAD_PROGRESS), (int)progress);
                }
                this.Available = true;
                break;

            case EDownloadTaskState.DLTaskPaused:
                this.Description = string.Format(Shell.LoadString(StringId.IDS_DOWNLOAD_PROGRESS), (int)progress);
                this.Progress    = progress / 100f;
                this.Available   = false;
                break;

            case EDownloadTaskState.DLTaskCancelled:
                this.Description = Shell.LoadString(StringId.IDS_CANCELLED);
                this.Available   = false;
                break;

            case EDownloadTaskState.DLTaskFailed:
                this.Description = Shell.LoadString(StringId.IDS_FAILED);
                this.Available   = false;
                break;

            case EDownloadTaskState.DLTaskComplete:
                this.Description = Shell.LoadString(StringId.IDS_INCOLLECTION);
                this.Available   = true;
                break;

            default:
                this.Description = Shell.LoadString(StringId.IDS_PENDING);
                this.Available   = false;
                break;
            }
        }