private void wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { if (e.Error != null) { MessageBox.Show(Configuration.Settings.Language.SettingsMpv.DownloadMpvFailed + Environment.NewLine + Environment.NewLine + $"Manual action: Download \"{_downloadUrl}\" and unpack to \"{Configuration.DataDirectory}\"." + Environment.NewLine + Environment.NewLine + e.Error.Message); labelPleaseWait.Text = string.Empty; buttonOK.Enabled = true; buttonDownload.Enabled = !Configuration.IsRunningOnLinux; Cursor = Cursors.Default; return; } string dictionaryFolder = Configuration.DataDirectory; using (var ms = new MemoryStream(e.Result)) using (ZipExtractor zip = ZipExtractor.Open(ms)) { List <ZipExtractor.ZipFileEntry> dir = zip.ReadCentralDir(); foreach (ZipExtractor.ZipFileEntry entry in dir) { if (entry.FilenameInZip.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) { string fileName = Path.GetFileName(entry.FilenameInZip); string path = Path.Combine(dictionaryFolder, fileName); try { zip.ExtractFile(entry, path); } catch { path = Path.Combine(dictionaryFolder, fileName + ".new-mpv"); zip.ExtractFile(entry, path); } } } } Cursor = Cursors.Default; labelPleaseWait.Text = string.Empty; buttonOK.Enabled = true; buttonDownload.Enabled = !Configuration.IsRunningOnLinux; MessageBox.Show(Configuration.Settings.Language.SettingsMpv.DownloadMpvOk); if (_justDownload) { DialogResult = DialogResult.OK; } }
private void wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { if (e.Error != null) { MessageBox.Show(Configuration.Settings.Language.SettingsMpv.DownloadMpvFailed); labelPleaseWait.Text = string.Empty; buttonOK.Enabled = true; if (!Configuration.IsRunningOnLinux()) { buttonDownload.Enabled = true; } else { buttonDownload.Enabled = false; } Cursor = Cursors.Default; return; } string dictionaryFolder = Configuration.DataDirectory; using (var ms = new MemoryStream(e.Result)) using (ZipExtractor zip = ZipExtractor.Open(ms)) { List <ZipExtractor.ZipFileEntry> dir = zip.ReadCentralDir(); foreach (ZipExtractor.ZipFileEntry entry in dir) { if (entry.FilenameInZip.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) { string fileName = Path.GetFileName(entry.FilenameInZip); string path = Path.Combine(dictionaryFolder, fileName); if (File.Exists(path)) { path = Path.Combine(dictionaryFolder, fileName + ".new-mpv"); } zip.ExtractFile(entry, path); } } } Cursor = Cursors.Default; labelPleaseWait.Text = string.Empty; buttonOK.Enabled = true; if (!Configuration.IsRunningOnLinux()) { buttonDownload.Enabled = true; } else { buttonDownload.Enabled = false; } MessageBox.Show(Configuration.Settings.Language.SettingsMpv.DownloadMpvOk); }
private void wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { if (e.Error != null) { labelPleaseWait.Text = string.Format(LanguageSettings.Current.SettingsFfmpeg.XDownloadFailed, "ffmpeg"); buttonOK.Enabled = true; Cursor = Cursors.Default; return; } string folder = Path.Combine(Configuration.DataDirectory, "ffmpeg"); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } using (var ms = new MemoryStream(e.Result)) using (ZipExtractor zip = ZipExtractor.Open(ms)) { List <ZipExtractor.ZipFileEntry> dir = zip.ReadCentralDir(); foreach (ZipExtractor.ZipFileEntry entry in dir) { string fileName = Path.GetFileName(entry.FilenameInZip); if (fileName != null) { string path = Path.Combine(folder, fileName); if (fileName.EndsWith("ffmpeg.exe", StringComparison.OrdinalIgnoreCase)) { FFmpegPath = path; } zip.ExtractFile(entry, path); } } } Cursor = Cursors.Default; labelPleaseWait.Text = string.Empty; if (AutoClose) { DialogResult = DialogResult.OK; return; } buttonOK.Enabled = true; labelPleaseWait.Text = string.Format(LanguageSettings.Current.SettingsFfmpeg.XDownloadOk, "ffmpeg"); }
private void wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { if (e.Error != null && _xmlName == "Nikse.SubtitleEdit.Resources.OpenOfficeDictionaries.xml.zip") { MessageBox.Show("Unable to connect to extensions.services.openoffice.org... Switching host - please re-try!"); LoadDictionaryList("Nikse.SubtitleEdit.Resources.HunspellDictionaries.xml.gz"); labelPleaseWait.Text = string.Empty; buttonOK.Enabled = true; buttonDownload.Enabled = true; comboBoxDictionaries.Enabled = true; Cursor = Cursors.Default; return; } else if (e.Error != null) { MessageBox.Show(Configuration.Settings.Language.GetTesseractDictionaries.DownloadFailed + Environment.NewLine + Environment.NewLine + e.Error.Message); DialogResult = DialogResult.Cancel; return; } string dictionaryFolder = Utilities.DictionaryFolder; if (!Directory.Exists(dictionaryFolder)) { Directory.CreateDirectory(dictionaryFolder); } int index = comboBoxDictionaries.SelectedIndex; using (var ms = new MemoryStream(e.Result)) using (ZipExtractor zip = ZipExtractor.Open(ms)) { List <ZipExtractor.ZipFileEntry> dir = zip.ReadCentralDir(); // Extract dic/aff files in dictionary folder bool found = false; ExtractDic(dictionaryFolder, zip, dir, ref found); if (!found) // check zip inside zip { foreach (ZipExtractor.ZipFileEntry entry in dir) { if (entry.FilenameInZip.EndsWith(".zip", StringComparison.OrdinalIgnoreCase)) { using (var innerMs = new MemoryStream()) { zip.ExtractFile(entry, innerMs); ZipExtractor innerZip = ZipExtractor.Open(innerMs); List <ZipExtractor.ZipFileEntry> innerDir = innerZip.ReadCentralDir(); ExtractDic(dictionaryFolder, innerZip, innerDir, ref found); } } } } } Cursor = Cursors.Default; labelPleaseWait.Text = string.Empty; buttonOK.Enabled = true; buttonDownload.Enabled = true; comboBoxDictionaries.Enabled = true; MessageBox.Show(string.Format(Configuration.Settings.Language.GetDictionaries.XDownloaded, comboBoxDictionaries.Items[index])); }
private void wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { labelPleaseWait.Text = string.Empty; if (e.Error != null) { MessageBox.Show(Configuration.Settings.Language.GetTesseractDictionaries.DownloadFailed); ChangeControlsState(true); Cursor = Cursors.Default; DialogResult = DialogResult.Cancel; return; } string pluginsFolder = Configuration.PluginsDirectory; if (!Directory.Exists(pluginsFolder)) { try { Directory.CreateDirectory(pluginsFolder); } catch (Exception exception) { MessageBox.Show($"Unable to create plugin folder {pluginsFolder}: {exception.Message}"); ChangeControlsState(true); Cursor = Cursors.Default; return; } } var ms = new MemoryStream(e.Result); using (ZipExtractor zip = ZipExtractor.Open(ms)) { List <ZipExtractor.ZipFileEntry> dir = zip.ReadCentralDir(); // Extract dic/aff files in dictionary folder foreach (ZipExtractor.ZipFileEntry entry in dir) { string fileName = Path.GetFileName(entry.FilenameInZip); string fullPath = Path.Combine(pluginsFolder, fileName); if (File.Exists(fullPath)) { try { File.Delete(fullPath); } catch { MessageBox.Show($"{fullPath} already exists - unable to overwrite it"); Cursor = Cursors.Default; ChangeControlsState(true); return; } } zip.ExtractFile(entry, fullPath); } } Cursor = Cursors.Default; ChangeControlsState(true); if (_updatingAllPlugins) { _updatingAllPluginsCount++; if (_updatingAllPluginsCount == _updateAllListUrls.Count) { MessageBox.Show(string.Format(_language.XPluginsUpdated, _updatingAllPluginsCount)); } } else { MessageBox.Show(string.Format(_language.PluginXDownloaded, _downloadedPluginName)); } ShowInstalledPlugins(); }
void wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { labelPleaseWait.Text = string.Empty; if (e.Error != null) { MessageBox.Show("Download failed!"); DialogResult = DialogResult.Cancel; return; } string pluginsFolder = Configuration.PluginsDirectory; if (!Directory.Exists(pluginsFolder)) { try { Directory.CreateDirectory(pluginsFolder); } catch (Exception exception) { MessageBox.Show("Unable to create plugin folder " + pluginsFolder + ": " + exception.Message); return; } } var ms = new MemoryStream(e.Result); ZipExtractor zip = ZipExtractor.Open(ms); List <ZipExtractor.ZipFileEntry> dir = zip.ReadCentralDir(); // Extract dic/aff files in dictionary folder foreach (ZipExtractor.ZipFileEntry entry in dir) { string fileName = Path.GetFileName(entry.FilenameInZip); string fullPath = Path.Combine(pluginsFolder, fileName); if (File.Exists(fullPath)) { try { File.Delete(fullPath); } catch { MessageBox.Show(string.Format("{0} already exists - unable to overwrite it", fullPath)); Cursor = Cursors.Default; labelPleaseWait.Text = string.Empty; buttonOK.Enabled = true; buttonDownload.Enabled = true; listViewGetPlugins.Enabled = true; return; } } zip.ExtractFile(entry, fullPath); } zip.Close(); ms.Close(); Cursor = Cursors.Default; labelPleaseWait.Text = string.Empty; buttonOK.Enabled = true; buttonDownload.Enabled = true; listViewGetPlugins.Enabled = true; MessageBox.Show(string.Format(_language.PluginXDownloaded, _downloadedPluginName)); ShowInstalledPlugins(); }