Beispiel #1
0
        private void Client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            if (e.Cancelled || e.Error != null)
            {
                this.DownloaderCompleted?.Invoke(sender, new DownloaderCompletedEventArgs(e.Cancelled, e.Error));
            }
            else
            {
                var    index  = (int)e.UserState;
                SWFile swFile = SWFileManager.GetElementAt(index);
                if (swFile is ArchivedSWFile archivedSWFile)
                {
                    archivedSWFile.Data = e.Result;
                }
                else
                {
                    string swFilePath      = Path.Combine(this.Language.Path, swFile.Path, Path.GetFileName(swFile.PathD));
                    string swFileDirectory = Path.GetDirectoryName(swFilePath);

                    Directory.CreateDirectory(swFileDirectory);
                    File.WriteAllBytes(swFilePath, e.Result);
                }

                if (SWFileManager.Count > ++index)
                {
                    this.DownloadNext(index);
                }
                else
                {
                    this.DownloaderCompleted?.Invoke(sender, new DownloaderCompletedEventArgs(this.Language, e.Cancelled, e.Error));
                }
            }
        }
Beispiel #2
0
        private void DownloadNext(int index)
        {
            string pathname = Language.Path.StartsWith("jpc") ? "jp" + Language.Path.Substring(3) : Language.Path;
            Uri    uri      = new Uri(Urls.TranslationGitHubHome + pathname + '/' + SWFileManager.GetElementAt(index).PathD);

            this.Client.DownloadDataAsync(uri, index);

            Logger.Debug(Methods.MethodFullName(System.Reflection.MethodBase.GetCurrentMethod(), uri.AbsoluteUri));
        }
Beispiel #3
0
 private void Client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
 {
     this.DownloaderProgressChanged?.Invoke(sender, new DownloaderProgressChangedEventArgs((int)e.UserState + 1, SWFileManager.Count, Path.GetFileNameWithoutExtension(SWFileManager.GetElementAt((int)e.UserState).Name), e));
 }
Beispiel #4
0
        private void DownloadNext(int index)
        {
            Uri uri = new Uri(Urls.TranslationGitHubHome + this.Language.Path + '/' + SWFileManager.GetElementAt(index).PathD);

            this.Client.DownloadDataAsync(uri, index);

            Logger.Debug(Methods.MethodFullName(System.Reflection.MethodBase.GetCurrentMethod(), uri.AbsoluteUri));
        }