コード例 #1
0
        public void DownloadStateChanged(CDownload sender, EDownloadStatus state)
        {
            lock (this)
            {
                if (!AllDownloads.Contains(sender))
                {
                    return;
                }
                switch (state)
                {
                case EDownloadStatus.started:
                    if (!RunningDownloads.Contains(sender))
                    {
                        RunningDownloads.Add(sender);
                    }
                    break;

                case EDownloadStatus.failed:
                case EDownloadStatus.canceled:
                case EDownloadStatus.timeout:
                case EDownloadStatus.finished:
                    RunningDownloads.Remove(sender);
                    AllDownloads.Remove(sender);
                    AllDownloadsByFileName.Remove(sender.FullFileName);
                    StartNextDownload();
                    break;
                }
                if (DownloadListener != null)
                {
                    DownloadListener.DownloadStateChanged(sender, state);
                }
            }
        }
コード例 #2
0
ファイル: GoogleApi.cs プロジェクト: KaEuAn/computer_graphics
 void DownloadFile(File file)
 {
     json = Encoding.UTF8.GetString(file.Content);
     Debug.Log("Downloading json " + json);
     textForWalls     = JsonConvert.DeserializeObject <Dictionary <string, string> >(json);
     keyfile          = file;
     textForWallReady = new Dictionary <EWall, bool>()
     {
         { EWall.kWall3, true }, { EWall.kWall4, true }, { EWall.kWall6, true },
     };
     fileStatus = EDownloadStatus.kDownloaded;
 }
コード例 #3
0
ファイル: GoogleApi.cs プロジェクト: KaEuAn/computer_graphics
 void Update()
 {
     if (fileStatus == EDownloadStatus.kDownloadRequested)
     {
         fileStatus = EDownloadStatus.kInProgress;
         GoogleDriveFiles.List().Send().OnDone += RefreshFileList;
     }
     if (fileStatus == EDownloadStatus.kFilesListRefreshed)
     {
         fileStatus = EDownloadStatus.kInProgress;
         keyfile    = files[0];
         GoogleDriveFiles.Download(keyfile.Id).Send().OnDone += DownloadFile;
     }
     if (hasChanges && !(textForWalls is null) && fileStatus == EDownloadStatus.kDownloaded)
     {
         UpdateFile();
     }
 }
コード例 #4
0
ファイル: TopManager.cs プロジェクト: Camel-RD/MyDownloder
        public void OnStatusChenged(Download d, EDownloadStatus oldstatus, EDownloadStatus newstatus)
        {
            if (Deserializing) return;

            if (MainForm != null &&
                !MainForm.Disposing &&
                !MainForm.IsDisposed &&
                MainForm.InvokeRequired)
            {
                try
                {
                    MainForm.Invoke((Action<Download, EDownloadStatus, EDownloadStatus>)OnStatusChengedA,
                        new object[] { d, oldstatus, newstatus });
                }
                catch (Exception) { }
            }
            else
                OnStatusChengedA(d, oldstatus, newstatus);
        }
コード例 #5
0
ファイル: GoogleApi.cs プロジェクト: KaEuAn/computer_graphics
 void RefreshFileList(FileList fileList)
 {
     files = fileList.Files;
     Debug.Log("File list refreshed, found " + files.Count.ToString() + " files");
     fileStatus = EDownloadStatus.kFilesListRefreshed;
 }
コード例 #6
0
ファイル: TopManager.cs プロジェクト: Camel-RD/MyDownloder
        public void OnStatusChengedA(Download d, EDownloadStatus oldstatus, EDownloadStatus newstatus)
        {
            if (Deserializing) return;

            if (newstatus == EDownloadStatus.Running)
            {
                if (RunningDownloads.Contains(d)) return;
                RunningDownloads.Add(d);
                DownloaderState = EDownloaderState.Running;
            }
            else if (newstatus == EDownloadStatus.Completed)
            {
                if (!RunningDownloads.Contains(d)) return;
                RunningDownloads.Remove(d);
                if (IsCompleted())
                    OnAllompleted();
                else if (RunningDownloads.Count < MaxParalelDownloads)
                    StartNext();
            }
            else if (newstatus == EDownloadStatus.Stopped)
            {
                if (!RunningDownloads.Contains(d)) return;
                RunningDownloads.Remove(d);

                if (d.Reseting)
                    d.ResetA();

                if (d.Removing)
                    d.RemoveA();

                if(DownloaderState == EDownloaderState.Stopping)
                {
                    if(RunningDownloads.Count == 0)
                        DownloaderState = EDownloaderState.Stopped;
                }
                else if (DownloaderState == EDownloaderState.Running)
                {
                    if (IsCompleted())
                        OnAllompleted();
                    else if (RunningDownloads.Count < MaxParalelDownloads)
                        StartNext();
                }
            }
            else if (newstatus == EDownloadStatus.Error)
            {
                if (!RunningDownloads.Contains(d)) return;
                RunningDownloads.Remove(d);
                if (DownloaderState == EDownloaderState.Stopping)
                {
                    if (RunningDownloads.Count == 0)
                        DownloaderState = EDownloaderState.Stopped;
                }
                else if (DownloaderState == EDownloaderState.Running)
                {
                    if (IsCompleted())
                        OnAllompleted();
                    else if (RunningDownloads.Count < MaxParalelDownloads)
                        StartNext();
                }
            }
        }
コード例 #7
0
ファイル: Download.cs プロジェクト: Camel-RD/MyDownloder
 public StatusChengeEventArgs(EDownloadStatus oldstatus, EDownloadStatus newstatus)
 {
     OldStatus = oldstatus;
     NewStatus = newstatus;
 }