private static void OnDownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) { if (sender is MightyWebClient mightyWebClient) { DownloadingWindowUtilities.SetPercent((float)e.BytesReceived / mightyWebClient.DocVersion.byteSize); } }
private static void OnDownloadDocCompleted(object sender, AsyncCompletedEventArgs e) { DownloadingWindowUtilities.Close(); if (!(sender is MightyWebClient mightyWebClient)) { return; } MightySettingsServices.DocPath = mightyWebClient.Path; FileUtilities.OpenAtPath(FileUtilities.GetDirectoryPath(mightyWebClient.Path)); UpdateDocVersion(mightyWebClient.DocVersion.versionNumber); }
private static void DownloadDocAtPath(string path, MightyDocVersion docVersion) { using (var client = new MightyWebClient()) { client.Path = path; client.DocVersion = docVersion; client.DownloadFileCompleted += OnDownloadDocCompleted; client.DownloadProgressChanged += OnDownloadProgressChanged; client.DownloadFileAsync(new Uri(docVersion.docURL), path); DownloadingWindowUtilities.Open(); } }