private void btnDownload_Click(object sender, EventArgs e) { if (lvSubtitles.SelectedItems != null && lvSubtitles.SelectedItems.Count > 0) { ListViewItem item = lvSubtitles.SelectedItems[0]; SubtitleDownloadInfo sdi = (SubtitleDownloadInfo)item.Tag; string downloadedSubtitleFile = sdi.sd.DownloadCompressedSubtitle(_movieFilePath, sdi.si); if (!string.IsNullOrEmpty(downloadedSubtitleFile)) { string movieFileName = Path.GetFileName(_movieFilePath); if (SubtitleDownloadNotify != null) { SubtitleDownloadNotify(_movieFilePath, downloadedSubtitleFile); } } } }
void SubtitleDownloadNotifyForm_Load(object sender, EventArgs e) { foreach (SubtitleDownloader sd in _subtitleDownloadInfo.Keys) { if (sd.Priority < _highestPrio) _highestPrio = sd.Priority; } foreach (KeyValuePair<SubtitleDownloader, List<SubtitleInfo>> kvp in _subtitleDownloadInfo) { SubtitleDownloader sd = kvp.Key; List<SubtitleInfo> list = kvp.Value; if (sd != null && list != null) { foreach (SubtitleInfo si in list) { string[] data = new string[] { string.IsNullOrEmpty(si.SubFileName) ? none : si.SubFileName, string.IsNullOrEmpty(sd.ServerUrl) ? none : sd.ServerUrl, sd.Priority.ToString(), string.IsNullOrEmpty(si.LanguageName) ? none : si.LanguageName, string.IsNullOrEmpty(si.SubSize) ? none : si.SubSize }; ListViewItem item = new ListViewItem(data); SubtitleDownloadInfo sdi = new SubtitleDownloadInfo(); sdi.sd = sd; sdi.si = si; item.Tag = sdi; lvSubtitles.Items.Add(item); //item.UseItemStyleForSubItems = true; if (SubtitleLanguage.IsPrefferedLanguage(si.LanguageName)) { item.ForeColor = ThemeManager.HighlightColor; foreach (ListViewItem.ListViewSubItem lvsi in item.SubItems) { lvsi.ForeColor = ThemeManager.HighlightColor; } } if (_highestPrio == sd.Priority) { item.Font = ThemeManager.SmallFont; foreach (ListViewItem.ListViewSubItem lvsi in item.SubItems) { lvsi.Font = ThemeManager.SmallFont; } } } } } int count = lvSubtitles.Items.Count; string movieName = string.Format("'{0}'", Path.GetFileName(_movieFilePath)); lvSubtitles.ListViewItemSorter = new SubtitleFormComparer(Columns.Language, _sortOrderParam); lvSubtitles.Sort(); SetTitle(Translator.Translate("TXT_SUBTITLEDOWNLOADNOTIFY", count, movieName)); }