public DownloadInformationControl(Download download) { InitializeComponent(); m_Download = download; iconPictureBox.Tag = m_Download.FileName; try { // 2008-10-21 Eroli: Mono-Fix if (!UtilitiesForMono.IsRunningOnMono) { iconPictureBox.Image = ShellIcon.GetLargeSystemIcon((string)iconPictureBox.Tag); } } catch { } fileSizeTextBox.Text = m_Download.FileSizeString; fileNameTextBox.Text = m_Download.FileName; subFolderTextBox.Text = m_Download.SubFolder; fileHashTextBox.Text = m_Download.FileHashString; if (m_Download.LastReception != null) { TimeSpan span = DateTime.Now.Subtract((DateTime)m_Download.LastReception); lastReceptionTextBox.Text = string.Format(Properties.Resources.Date_Diff, span.Days, span.Hours, span.Minutes, span.Seconds); } try { progressPictureBox.Image = ProgressBars.GetProgressBar(m_Download, progressPictureBox.Width, progressPictureBox.Height, Font); } catch { } }
private void updateTimer_Tick(object sender, EventArgs e) { if (!((string)iconPictureBox.Tag).Equals(m_Result.FileName)) { iconPictureBox.Tag = m_Result.FileName; try { // 2008-10-21 Eroli: Mono-Fix if (!UtilitiesForMono.IsRunningOnMono) { iconPictureBox.Image = ShellIcon.GetLargeSystemIcon((string)iconPictureBox.Tag); } } catch { } } fileNameTextBox.Text = m_Result.FileName; }
public SearchResultInformationControl(Search.Result result) { InitializeComponent(); m_Result = result; iconPictureBox.Tag = m_Result.FileName; try { // 2008-10-21 Eroli: Mono-Fix if (!UtilitiesForMono.IsRunningOnMono) { iconPictureBox.Image = ShellIcon.GetLargeSystemIcon((string)iconPictureBox.Tag); } } catch { } fileNameTextBox.Text = m_Result.FileName; fileSizeTextBox.Text = m_Result.FileSizeString; fileHashTextBox.Text = m_Result.FileHashString; }
private void updateTimer_Tick(object sender, EventArgs e) { if (!((string)iconPictureBox.Tag).Equals(m_Download.FileName)) { iconPictureBox.Tag = m_Download.FileName; try { // 2008-10-21 Eroli: Mono-Fix if (!UtilitiesForMono.IsRunningOnMono) { iconPictureBox.Image = ShellIcon.GetLargeSystemIcon((string)iconPictureBox.Tag); } } catch { } } fileNameTextBox.Text = m_Download.FileName; fileSizeTextBox.Text = m_Download.FileSizeString; fileHashTextBox.Text = m_Download.FileHashString; if (m_Download.LastReception != null) { TimeSpan span = DateTime.Now.Subtract((DateTime)m_Download.LastReception); lastReceptionTextBox.Text = string.Format(Properties.Resources.Date_Diff, span.Days, span.Hours, span.Minutes, span.Seconds); } try { progressPictureBox.Image.Dispose(); } catch { } try { progressPictureBox.Image = ProgressBars.GetProgressBar(m_Download, progressPictureBox.Width, progressPictureBox.Height, Font); } catch { } subFolderTextBox.Text = m_Download.SubFolder; }
public SharedFileInformationControl(SharedFile sharedFile) { InitializeComponent(); m_SharedFile = sharedFile; try { // 2008-10-21 Eroli: Mono-Fix if (!UtilitiesForMono.IsRunningOnMono) { iconPictureBox.Image = ShellIcon.GetLargeSystemIcon(sharedFile.FileName); } } catch { } fileNameTextBox.Text = m_SharedFile.FileName; fileSizeTextBox.Text = m_SharedFile.FileSizeString; fileHashTextBox.Text = m_SharedFile.FileHashString; commentTextBox.Text = sharedFile.Comment; switch (m_SharedFile.Rating) { case 1: ratingGoodRadioButton.Checked = true; break; case 2: ratingNeutralRadioButton.Checked = true; break; case 3: ratingBadRadioButton.Checked = true; break; default: ratingUnknownRadioButton.Checked = true; break; } }
private void updateTimer_Tick(object sender, EventArgs e) { try { ((System.Windows.Forms.Timer)sender).Stop(); updateTimer.Interval = Math.Max(1000, sourcesDataGridView.Rows.Count * 10); try { m_Download.Sources.Lock(); { DataGridViewRow row; for (int n = sourcesDataGridView.Rows.Count - 1; n >= 0; n--) { row = sourcesDataGridView.Rows[n]; if (!m_Download.Sources.ContainsKey(((RandomTag <string>)row.Tag).Tag)) { sourcesDataGridView.Rows.RemoveAt(n); } } } DataGridViewRow sourceRow; DataGridViewCell sourceCell; int a = 0; foreach (Download.Source source in m_Download.Sources.Values) { if (a % 50 == 0) { Application.DoEvents(); } a++; sourceRow = null; foreach (DataGridViewRow row in sourcesDataGridView.Rows) { if ((((RandomTag <string>)row.Tag).Tag).Equals(source.PeerIDString)) { sourceRow = row; break; } } if (sourceRow == null) { sourceRow = new DataGridViewRow(); sourceRow.Height = 17; sourceCell = new DataGridViewImageCell(); sourceRow.Cells.Add(sourceCell); try { // 2008-10-21 Eroli: Mono-Fix if (!UtilitiesForMono.IsRunningOnMono) { sourceCell.Value = ShellIcon.GetSmallSystemIcon(source.FileName); } } catch { } sourceCell = new DataGridViewImageCell(); sourceRow.Cells.Add(sourceCell); sourceCell.Value = GetRatingImage(source); sourceCell = new DataGridViewTextBoxCell(); sourceRow.Cells.Add(sourceCell); sourceCell.Value = source.FileName; sourceCell = new DataGridViewTextBoxCell(); sourceRow.Cells.Add(sourceCell); sourceCell.Value = source.Comment; sourceRow.Tag = new RandomTag <string>(source.PeerIDString); sourcesDataGridView.Rows.Add(sourceRow); continue; } if ((string)sourceRow.Cells["FileIcon"].Tag != source.FileName) { sourceRow.Cells["FileIcon"].Tag = source.FileName; try { // 2008-10-21 Eroli: Mono-Fix if (!UtilitiesForMono.IsRunningOnMono) { sourceRow.Cells["FileIcon"].Value = ShellIcon.GetSmallSystemIcon((string)sourceRow.Cells["FileIcon"].Tag); } } catch { } } sourceRow.Cells["Rating"].Value = GetRatingImage(source); // T.Norad: BZ 123: display no info if the source has no information about the filename if (!source.HasInformation) { sourceRow.Cells["FileName"].Value = Properties.Resources.ProgressBar_NoInfo; } else { sourceRow.Cells["FileName"].Value = source.FileName; } sourceRow.Cells["Comment"].Value = source.Comment; } sourcesDataGridView.Sort(sourcesDataGridView.SortedColumn, sourcesDataGridView.SortOrder == SortOrder.Descending ? ListSortDirection.Descending : ListSortDirection.Ascending); } catch (InvalidOperationException) { // TODO } catch (Exception ex) { Logger.Instance.Log(ex, "An exception was thrown! (DownloadResultSourcesControl)"); } finally { m_Download.Sources.Unlock(); } } finally { ((System.Windows.Forms.Timer)sender).Start(); } }
private void searchButton_Click(object sender, EventArgs e) { // T.Norad BZ129 SharedFileCollection searchResults = new SharedFileCollection(); string searchpattern = searchTextBox.Text.Trim().ToLower(); maxSearchCountLabel.Visible = false; // first search in the shared files collection in the core // then display this results in the grid. this reduces the lock-time of the core collection try { Core.SharedFiles.Lock(); foreach (SharedFile sharedFile in Core.SharedFiles.Values) { // if maximum search result reached: display the note and stop this search if (searchResults.Count >= Constants.MaximumSharedFilesSearchesCount) { maxSearchCountLabel.Visible = true; break; } switch (columnComboBox.SelectedIndex) { case 0: if (sharedFile.FileName.ToLower().Contains(searchpattern) == true) { searchResults.Add(sharedFile); } break; case 1: if (sharedFile.DirectoryPath.ToLower().Contains(searchpattern) == true) { searchResults.Add(sharedFile); } break; case 2: if (sharedFile.Album.ToLower().Contains(searchpattern) == true) { searchResults.Add(sharedFile); } break; case 3: if (sharedFile.Artist.ToLower().Contains(searchpattern) == true) { searchResults.Add(sharedFile); } break; case 4: if (sharedFile.Title.ToLower().Contains(searchpattern) == true) { searchResults.Add(sharedFile); } break; } } } finally { Core.SharedFiles.Unlock(); } // now display the search results sharedFilesDataGridView.Rows.Clear(); DataGridViewRow sharedFileRow; DataGridViewCell sharedFileCell; foreach (SharedFile sharedFile in searchResults.Values) { sharedFileRow = new DataGridViewRow(); sharedFileRow.Height = 17; sharedFileCell = new DataGridViewImageCell(); sharedFileRow.Cells.Add(sharedFileCell); try { // 2008-10-21 Eroli: Mono-Fix if (!UtilitiesForMono.IsRunningOnMono) { sharedFileCell.Value = ShellIcon.GetSmallSystemIcon(sharedFile.FilePath); } } catch { } sharedFileCell = new DataGridViewImageCell(); sharedFileRow.Cells.Add(sharedFileCell); sharedFileCell.Value = GetRatingImage(sharedFile); sharedFileCell.Tag = sharedFile.Rating; sharedFileCell = new DataGridViewTextBoxCell(); sharedFileRow.Cells.Add(sharedFileCell); sharedFileCell.Value = sharedFile.FileName; sharedFileCell = new DataGridViewTextBoxCell(); sharedFileRow.Cells.Add(sharedFileCell); sharedFileCell.Value = sharedFile.FileSizeString; sharedFileCell.Tag = sharedFile.FileSize; sharedFileCell = new DataGridViewTextBoxCell(); sharedFileRow.Cells.Add(sharedFileCell); sharedFileCell.Value = sharedFile.DirectoryPath; sharedFileCell = new DataGridViewTextBoxCell(); sharedFileRow.Cells.Add(sharedFileCell); sharedFileCell.Value = sharedFile.Album; sharedFileCell = new DataGridViewTextBoxCell(); sharedFileRow.Cells.Add(sharedFileCell); sharedFileCell.Value = sharedFile.Artist; sharedFileCell = new DataGridViewTextBoxCell(); sharedFileRow.Cells.Add(sharedFileCell); sharedFileCell.Value = sharedFile.Title; //2008-10-25 Eroli: Bugfix sharedFileCell = new DataGridViewTextBoxCell(); sharedFileRow.Cells.Add(sharedFileCell); if (sharedFile.LastRequest != null) { TimeSpan span = DateTime.Now.Subtract((DateTime)sharedFile.LastRequest); sharedFileCell.Value = string.Format(Properties.Resources.Date_Diff, span.Days, span.Hours, span.Minutes, span.Seconds); } sharedFileCell.Tag = sharedFile.LastRequest; //2008-10-25 Eroli: Bugfix-End sharedFileRow.Tag = new RandomTag <string>(sharedFile.FileHashString); sharedFilesDataGridView.Rows.Add(sharedFileRow); continue; } sharedFilesLabel.Text = string.Format(Properties.Resources.SharedFiles, searchResults.Count, Core.SharedFiles.Count); }
private void updateTimer_Tick(object sender, EventArgs e) { try { ((System.Windows.Forms.Timer)sender).Stop(); updateTimer.Interval = Math.Max(Math.Max(1000, searchesDataGridView.Rows.Count * 10), Math.Max(1000, resultsDataGridView.Rows.Count * 10)); if (m_MainForm.ActiveTab == this && !m_MainForm.IsInTray) { Search selectedSearch = null; try { Core.Searches.Lock(); searchesLabel.Text = string.Format(Properties.Resources.Searches, Core.Searches.Count, Constants.MaximumSearchesCount); { DataGridViewRow row; for (int n = searchesDataGridView.Rows.Count - 1; n >= 0; n--) { row = searchesDataGridView.Rows[n]; if (!Core.Searches.ContainsKey(((RandomTag <string>)row.Tag).Tag)) { searchesDataGridView.Rows.RemoveAt(n); } } } DataGridViewRow searchRow; DataGridViewCell searchCell; int a = 0; foreach (Search search in Core.Searches.Values) { if (a % 50 == 0) { Application.DoEvents(); } a++; searchRow = null; foreach (DataGridViewRow row in searchesDataGridView.Rows) { if (((RandomTag <string>)row.Tag).Tag.Equals(search.SearchIDString)) { searchRow = row; break; } } if (searchRow == null) { searchRow = new DataGridViewRow(); searchRow.Height = 17; searchCell = new DataGridViewTextBoxCell(); searchRow.Cells.Add(searchCell); searchCell.Value = search.SearchPattern; searchCell = new DataGridViewTextBoxCell(); searchRow.Cells.Add(searchCell); searchCell.Value = search.IsActive ? Properties.Resources.SearchState_Active : Properties.Resources.SearchState_Passive; searchCell.Tag = search.IsActive; searchCell = new DataGridViewTextBoxCell(); searchRow.Cells.Add(searchCell); searchCell.Value = search.Results.Count.ToString(); searchCell.Tag = search.Results.Count; searchRow.Tag = new RandomTag <string>(search.SearchIDString); searchesDataGridView.Rows.Add(searchRow); continue; } searchCell = searchRow.Cells["IsActive"]; searchCell.Value = search.IsActive ? Properties.Resources.SearchState_Active : Properties.Resources.SearchState_Passive; searchCell.Tag = search.IsActive; searchCell = searchRow.Cells["Results"]; searchCell.Value = search.Results.Count.ToString(); searchCell.Tag = search.Results.Count; } searchesDataGridView.Sort(searchesDataGridView.SortedColumn, searchesDataGridView.SortOrder == SortOrder.Descending ? ListSortDirection.Descending : ListSortDirection.Ascending); if (searchesDataGridView.SelectedRows.Count == 1 && Core.Searches.ContainsKey(((RandomTag <string>)searchesDataGridView.SelectedRows[0].Tag).Tag)) { selectedSearch = Core.Searches[((RandomTag <string>)searchesDataGridView.SelectedRows[0].Tag).Tag]; } } catch (Exception ex) { Logger.Instance.Log(ex, "An exception was thrown! (SearchControl - Searches)"); } finally { Core.Searches.Unlock(); } if (selectedSearch != null) { try { selectedSearch.Results.Lock(); //2009-01-31 Nochbaer if (selectedSearch.TooManySearchDBResults) { searchesLabel.Text += string.Format(Properties.Resources.TooManySearchDBResults, m_Settings["MaxSearchDBResults"], selectedSearch.TotalSearchDBResults); } resultsDataGridView.Tag = selectedSearch.SearchIDString; resultsDataGridView.Enabled = true; { DataGridViewRow row; for (int n = resultsDataGridView.Rows.Count - 1; n >= 0; n--) { row = resultsDataGridView.Rows[n]; if (!selectedSearch.Results.ContainsKey(((RandomTag <string>)row.Tag).Tag)) { resultsDataGridView.Rows.RemoveAt(n); } } } DataGridViewRow resultRow; DataGridViewCell resultCell; int a = 0; foreach (Search.Result result in selectedSearch.Results.Values) { if (a % 50 == 0) { Application.DoEvents(); } a++; resultRow = null; foreach (DataGridViewRow row in resultsDataGridView.Rows) { if (((RandomTag <string>)row.Tag).Tag.Equals(result.FileHashString)) { resultRow = row; break; } } if (resultRow == null) { resultRow = new DataGridViewRow(); resultRow.Height = 17; resultCell = new DataGridViewImageCell(); resultCell.Tag = result.FileName; resultRow.Cells.Add(resultCell); try { // 2008-10-21 Eroli: Mono-Fix if (!UtilitiesForMono.IsRunningOnMono) { resultCell.Value = ShellIcon.GetSmallSystemIcon((string)resultCell.Tag); } } catch { } resultCell = new DataGridViewImageCell(); resultRow.Cells.Add(resultCell); resultCell.Value = GetRatingImage(result); resultCell.Tag = result.Rating; resultCell = new DataGridViewTextBoxCell(); resultRow.Cells.Add(resultCell); resultCell.Value = result.FileName; resultCell = new DataGridViewTextBoxCell(); resultRow.Cells.Add(resultCell); resultCell.Value = result.FileSizeString; resultCell.Tag = result.FileSize; resultCell = new DataGridViewTextBoxCell(); resultRow.Cells.Add(resultCell); string sourcesString; if (result.IsSearchDBResult) { sourcesString = "DB"; } else { sourcesString = result.Sources.Count.ToString(); } resultCell.Value = sourcesString; resultCell.Tag = result.Sources.Count; resultCell = new DataGridViewTextBoxCell(); resultRow.Cells.Add(resultCell); resultCell.Value = result.Album; resultCell = new DataGridViewTextBoxCell(); resultRow.Cells.Add(resultCell); resultCell.Value = result.Artist; resultCell = new DataGridViewTextBoxCell(); resultRow.Cells.Add(resultCell); resultCell.Value = result.Title; resultCell = new DataGridViewTextBoxCell(); resultRow.Cells.Add(resultCell); if (result.IsSearchDBResult) { int days = ((TimeSpan)DateTime.Now.Subtract(result.Date)).Days; if (days == 0) { resultCell.Value = Properties.Resources.Today; } else { resultCell.Value = string.Format(Properties.Resources.Date_Diff_Only_Days, days); } } else { resultCell.Value = RShare.Properties.Resources.Today; } resultCell.Tag = result.Date; resultRow.Tag = new RandomTag <string>(result.FileHashString); resultsDataGridView.Rows.Add(resultRow); GetRowColor(result, resultRow); continue; } resultCell = resultRow.Cells["Icon"]; if ((string)resultCell.Tag != result.FileName) { resultCell.Tag = result.FileName; try { // 2008-10-21 Eroli: Mono-Fix if (!UtilitiesForMono.IsRunningOnMono) { resultCell.Value = ShellIcon.GetSmallSystemIcon((string)resultCell.Tag); } } catch { } } resultCell = resultRow.Cells["RatingIcon"]; resultCell.Value = GetRatingImage(result); resultCell.Tag = result.Rating; resultCell = resultRow.Cells["FileName"]; resultCell.Value = result.FileName; resultCell = resultRow.Cells["Sources"]; string sourcesString2; if (result.IsSearchDBResult) { sourcesString2 = "DB"; } else { sourcesString2 = result.Sources.Count.ToString(); } resultCell.Value = sourcesString2; resultCell.Tag = result.Sources.Count; resultCell = resultRow.Cells["Album"]; resultCell.Value = result.Album; resultCell = resultRow.Cells["Artist"]; resultCell.Value = result.Artist; resultCell = resultRow.Cells["Title"]; resultCell.Value = result.Title; resultCell = resultRow.Cells["Age"]; if (result.IsSearchDBResult) { int days = ((TimeSpan)DateTime.Now.Subtract(result.Date)).Days; if (days == 0) { resultCell.Value = Properties.Resources.Today; } else { resultCell.Value = string.Format(Properties.Resources.Date_Diff_Only_Days, days); } } else { resultCell.Value = RShare.Properties.Resources.Today; } resultCell.Tag = result.Date; GetRowColor(result, resultRow); } resultsDataGridView.Sort(resultsDataGridView.SortedColumn, resultsDataGridView.SortOrder == SortOrder.Descending ? ListSortDirection.Descending : ListSortDirection.Ascending); } catch (Exception ex) { Logger.Instance.Log(ex, "An exception was thrown! (SearchControl - Results)"); } finally { selectedSearch.Results.Unlock(); } } else { resultsDataGridView.Rows.Clear(); resultsDataGridView.Tag = null; resultsDataGridView.Enabled = false; } } } finally { ((System.Windows.Forms.Timer)sender).Start(); } }