private void ClientLogWin_Load(object sender, EventArgs e) { foreach (string msg in _log) { string[] p = msg.Split('|'); DataGridViewRow row = new DataGridViewRow(); if (p.Length == 1) { DataGridViewCell cell = new DataGridViewImageCell(); cell.Value = iconList.Images[0]; row.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(); row.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = p[0]; row.Cells.Add(cell); } else { DataGridViewCell cell = new DataGridViewImageCell(); cell.Value = iconList.Images[Convert.ToInt32(p[0])]; row.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = p[1]; row.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = p[2]; row.Cells.Add(cell); } row.Height = 17; messageList.Rows.Add(row); messageList.FirstDisplayedScrollingRowIndex = messageList.Rows.Count - 1; } }
public void ConfobulateControl() { _control.AutoGenerateColumns = false; _control.SelectionMode = DataGridViewSelectionMode.FullRowSelect; _control.AllowUserToResizeRows = false; _control.AllowUserToOrderColumns = false; _control.BorderStyle = BorderStyle.None; _control.CellBorderStyle = DataGridViewCellBorderStyle.None; _control.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; _control.Font = new Font( _control.Font.FontFamily, 8.0F, GraphicsUnit.Point); _control.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None; _control.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(255, 72, 78, 83); _control.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; _control.ColumnHeadersDefaultCellStyle.Font = new Font(_control.ColumnHeadersDefaultCellStyle.Font.FontFamily, _control.ColumnHeadersDefaultCellStyle.Font.SizeInPoints, FontStyle.Bold, GraphicsUnit.Point); var cellTemplate = new DataGridViewTextBoxCell(); cellTemplate.Style.ForeColor = Color.White; cellTemplate.Style.SelectionBackColor = Color.FromArgb(255, 46, 100, 149); var playingColumnTemplate = new DataGridViewImageCell(); playingColumnTemplate.ValueIsIcon = false; playingColumnTemplate.Style.NullValue = null; playingColumnTemplate.Style.ForeColor = cellTemplate.Style.ForeColor; playingColumnTemplate.Style.SelectionBackColor = cellTemplate.Style.SelectionBackColor; var playingColumn = new DataGridViewColumn(playingColumnTemplate); playingColumn.Width = 16; playingColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; playingColumn.Name = ""; playingColumn.Tag = PlayerAppColumnTypes.NowPlaying; _control.Columns.Add(playingColumn); var titleColumn = new DataGridViewColumn(cellTemplate); titleColumn.Name = "Title"; titleColumn.DataPropertyName = "Title"; titleColumn.Tag = PlayerAppColumnTypes.Title; _control.Columns.Add(titleColumn); var artistColumn = new DataGridViewColumn(cellTemplate); artistColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; artistColumn.Name = "Artist"; artistColumn.DataPropertyName = "Artist"; artistColumn.Tag = PlayerAppColumnTypes.Artist; _control.Columns.Add(artistColumn); var durationColumn = new DataGridViewColumn(cellTemplate); durationColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; durationColumn.Name = "Duration"; durationColumn.DataPropertyName = "Duration"; durationColumn.Tag = PlayerAppColumnTypes.Duration; _control.Columns.Add(durationColumn); _control.RowHeadersVisible = false; _control.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; _control.MultiSelect = false; }
public static void SetDataGridViewCellImage(DataGridViewImageCell imageCell, ValueImage valueImage) { if (!EAppRuntime.Instance.CurrentApp.ResourceManagers.ContainsKey(valueImage.ResourceManagerName)) { return; } imageCell.Value = EAppRuntime.Instance.CurrentApp.ResourceManagers[valueImage.ResourceManagerName].GetImage(valueImage.ImageName); }
public override void DoDefaultAction() { DataGridViewImageCell dataGridViewCell = (DataGridViewImageCell)Owner; DataGridView dataGridView = dataGridViewCell.DataGridView; if (dataGridView != null && dataGridViewCell.RowIndex != -1 && dataGridViewCell.OwningColumn != null && dataGridViewCell.OwningRow != null) { dataGridView.OnCellContentClickInternal(new DataGridViewCellEventArgs(dataGridViewCell.ColumnIndex, dataGridViewCell.RowIndex)); } }
public void Value () { DataGridViewImageCell tbc = new DataGridViewImageCell (); Assert.IsNull (tbc.Value, "#1"); tbc.Value = string.Empty; Assert.AreEqual (string.Empty, tbc.Value, "#2"); tbc.Value = 5; Assert.AreEqual (5, tbc.Value, "#3"); tbc.Value = null; Assert.IsNull (tbc.Value, "#4"); }
public override void DoDefaultAction() { // do nothing if Level < 3 if (AccessibilityImprovements.Level3) { DataGridViewImageCell dataGridViewCell = (DataGridViewImageCell)this.Owner; DataGridView dataGridView = dataGridViewCell.DataGridView; if (dataGridView != null && dataGridViewCell.RowIndex != -1 && dataGridViewCell.OwningColumn != null && dataGridViewCell.OwningRow != null) { dataGridView.OnCellContentClickInternal(new DataGridViewCellEventArgs(dataGridViewCell.ColumnIndex, dataGridViewCell.RowIndex)); } } }
public override object Clone() { DataGridViewImageCell cell; System.Type type = base.GetType(); if (type == cellType) { cell = new DataGridViewImageCell(); } else { cell = (DataGridViewImageCell) Activator.CreateInstance(type); } base.CloneInternal(cell); cell.ValueIsIconInternal = this.ValueIsIcon; cell.Description = this.Description; cell.ImageLayoutInternal = this.ImageLayout; return cell; }
private void DoAddMessage(string msg) { if (msg == null) return; lock (_messageAdder) { string[] p = msg.Split('|'); DataGridViewRow row = new DataGridViewRow(); if (p.Length == 1) { DataGridViewCell cell = new DataGridViewImageCell(); cell.Value = iconList.Images[0]; row.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(); row.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = p[0]; row.Cells.Add(cell); } else { DataGridViewCell cell = new DataGridViewImageCell(); cell.Value = iconList.Images[Convert.ToInt32(p[0])]; row.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = p[1]; row.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = p[2]; row.Cells.Add(cell); } if (messageList.SelectedRows.Count > 0) messageList.SelectedRows[0].Selected = false; while (messageList.Rows.Count > 3000) messageList.Rows.RemoveAt(0); row.Height = 17; messageList.Rows.Add(row); row.Selected = true; messageList.FirstDisplayedScrollingRowIndex = messageList.Rows.Count - 1; } }
public override object Clone() { DataGridViewImageCell cell; System.Type type = base.GetType(); if (type == cellType) { cell = new DataGridViewImageCell(); } else { cell = (DataGridViewImageCell)Activator.CreateInstance(type); } base.CloneInternal(cell); cell.ValueIsIconInternal = this.ValueIsIcon; cell.Description = this.Description; cell.ImageLayoutInternal = this.ImageLayout; return(cell); }
private bool ShouldSerializeDefaultCellStyle() { DataGridViewImageCell templateCell = this.CellTemplate as DataGridViewImageCell; if (templateCell == null) { Debug.Fail("we can't compute the default cell style w/o a template cell"); return(true); } if (!this.HasDefaultCellStyle) { return(false); } object defaultNullValue; if (templateCell.ValueIsIcon) { defaultNullValue = DataGridViewImageCell.ErrorIcon; } else { defaultNullValue = DataGridViewImageCell.ErrorBitmap; } DataGridViewCellStyle defaultCellStyle = this.DefaultCellStyle; return(!defaultCellStyle.BackColor.IsEmpty || !defaultCellStyle.ForeColor.IsEmpty || !defaultCellStyle.SelectionBackColor.IsEmpty || !defaultCellStyle.SelectionForeColor.IsEmpty || defaultCellStyle.Font != null || !defaultNullValue.Equals(defaultCellStyle.NullValue) || !defaultCellStyle.IsDataSourceNullValueDefault || !String.IsNullOrEmpty(defaultCellStyle.Format) || !defaultCellStyle.FormatProvider.Equals(System.Globalization.CultureInfo.CurrentCulture) || defaultCellStyle.Alignment != DataGridViewContentAlignment.MiddleCenter || defaultCellStyle.WrapMode != DataGridViewTriState.NotSet || defaultCellStyle.Tag != null || !defaultCellStyle.Padding.Equals(Padding.Empty)); }
/// <summary> /// Repopulates the table of users. /// </summary> private void refreshUserTable() { grdUsers.Rows.Clear(); foreach (User user in users) { var row = new DataGridViewRow(); var pictureCell = new DataGridViewImageCell(); pictureCell.Value = user.Picture; pictureCell.ImageLayout = DataGridViewImageCellLayout.Zoom; row.MinimumHeight = iconSize; var userIdCell = new DataGridViewTextBoxCell(); userIdCell.Value = user.UserId; var nameCell = new DataGridViewTextBoxCell(); nameCell.Value = user.FullName.ToString(); var roleCell = new DataGridViewTextBoxCell(); roleCell.Value = user.Role.ToString(); row.Cells.AddRange(new DataGridViewCell[]{pictureCell, userIdCell, nameCell, roleCell}); grdUsers.Rows.Add(row); } }
public override object Clone() { DataGridViewImageCell dataGridViewCell; Type thisType = GetType(); if (thisType == cellType) //performance improvement { dataGridViewCell = new DataGridViewImageCell(); } else { // dataGridViewCell = (DataGridViewImageCell)System.Activator.CreateInstance(thisType); } base.CloneInternal(dataGridViewCell); dataGridViewCell.ValueIsIconInternal = ValueIsIcon; dataGridViewCell.Description = Description; dataGridViewCell.ImageLayoutInternal = ImageLayout; return(dataGridViewCell); }
/// <include file='doc\DataGridViewImageCell.uex' path='docs/doc[@for="DataGridViewImageCell.Clone"]/*' /> public override object Clone() { DataGridViewImageCell dataGridViewCell; Type thisType = this.GetType(); if (thisType == cellType) //performance improvement { dataGridViewCell = new DataGridViewImageCell(); } else { // SECREVIEW : Late-binding does not represent a security thread, see bug#411899 for more info.. // dataGridViewCell = (DataGridViewImageCell)System.Activator.CreateInstance(thisType); } base.CloneInternal(dataGridViewCell); dataGridViewCell.ValueIsIconInternal = this.ValueIsIcon; dataGridViewCell.Description = this.Description; dataGridViewCell.ImageLayoutInternal = this.ImageLayout; return(dataGridViewCell); }
private void addSharedDirtoList(string newDirectory) { if (System.IO.Directory.Exists(newDirectory)) { DataGridViewRow sharedDirectoryRow; DataGridViewCell sharedDirectoryCell; sharedDirectoryRow = new DataGridViewRow(); sharedDirectoryRow.Height = 17; sharedDirectoryCell = new DataGridViewImageCell(); sharedDirectoryRow.Cells.Add(sharedDirectoryCell); sharedDirectoryCell.Value = Properties.Resources.directory_16x16; sharedDirectoryCell = new DataGridViewTextBoxCell(); sharedDirectoryRow.Cells.Add(sharedDirectoryCell); sharedDirectoryCell.Value = newDirectory; sharedDirectoryRow.Tag = newDirectory; sharedDirectoriesDataGridView.Rows.Add(sharedDirectoryRow); updateDirectoyCount(); } //if (System.IO.Directory.Exists(path) }
public void Load(WordDefinition[] words) { _picsbox = new PictureBox[words.Length]; _gridview.Rows.Clear(); for (int i = 0; i < words.Length; i++) { //picsbox[i] = new PictureBox(); DataGridViewRow dgvr = new DataGridViewRow(); dgvr.Height = 100; DataGridViewTextBoxCell text = new DataGridViewTextBoxCell() { Value = words[i].Definition }; DataGridViewImageCell img = new DataGridViewImageCell() { Value = null }; DataGridViewTextBoxCell tag = new DataGridViewTextBoxCell() { Value = words[i].Tag }; if (words[i].Image.Length > 1) { _picsbox[i] = new PictureBox(); _picsbox[i].ImageLocation = words[i].Image; _picsbox[i].LoadCompleted += Loaded; _picsbox[i].LoadAsync(); } dgvr.Cells.Add(text); dgvr.Cells.Add(img); dgvr.Cells.Add(tag); _gridview.Rows.Add(dgvr); } }
private DataGridViewRow NewAlertRow(Alert alert) { var expanderCell = new DataGridViewImageCell(); var imageCell = new DataGridViewImageCell(); var appliesCell = new DataGridViewTextBoxCell(); var detailCell = new DataGridViewTextBoxCell(); var dateCell = new DataGridViewTextBoxCell(); var actionItems = GetAlertActionItems(alert); var actionCell = new DataGridViewDropDownSplitButtonCell(actionItems.ToArray()); var newRow = new DataGridViewRow { Tag = alert, MinimumHeight = DataGridViewDropDownSplitButtonCell.MIN_ROW_HEIGHT }; // Get the relevant image for the row depending on the type of the alert Image typeImage = alert is MessageAlert && ((MessageAlert)alert).Message.ShowOnGraphs ? Images.GetImage16For(((MessageAlert)alert).Message.Type) : Images.GetImage16For(alert.Priority); imageCell.Value = typeImage; // Set the detail cell content and expanding arrow if (expandedState.ContainsKey(alert.uuid)) { // show the expanded arrow and the body detail expanderCell.Value = Properties.Resources.expanded_triangle; detailCell.Value = String.Format("{0}\n\n{1}", alert.Title, alert.Description); } else { // show the expand arrow and just the title expanderCell.Value = Properties.Resources.contracted_triangle; detailCell.Value = alert.Title; } appliesCell.Value = alert.AppliesTo; dateCell.Value = HelpersGUI.DateTimeToString(alert.Timestamp.ToLocalTime(), Messages.DATEFORMAT_DMY_HM, true); newRow.Cells.AddRange(expanderCell, imageCell, detailCell, appliesCell, dateCell, actionCell); return newRow; }
private void AddCells() { ImageCell = new DataGridViewImageCell(false) {ValueType = typeof(Image)}; NameCell = new DataGridViewTextBoxCell(); SizeCell = new DataGridViewTextBoxCell(); SrCell = new DataGridViewTextBoxCell(); SharedCell = new DataGridViewTextBoxCell(); Cells.AddRange(ImageCell, NameCell, SrCell, SizeCell, SharedCell); UpdateDetails(); }
private void SetupCells() { _poolCheckBoxCell = new DataGridViewCheckBoxCell { ThreeState = true }; _expansionCell = new DataGridViewImageCell(); if (Tag is Pool || (Tag is Host && !_hasPool)) _poolIconHostCheckCell = new DataGridViewIconCell(); else _poolIconHostCheckCell = new DataGridViewCheckBoxCell(); _nameCell = new DataGridViewNameCell(); _versionCell = new DataGridViewTextBoxCell(); Cells.AddRange(new[] { _expansionCell, _poolCheckBoxCell, _poolIconHostCheckCell, _nameCell, _versionCell }); this.UpdateDetails(); }
public void LoadPropertyPage() { dgv_Properties.Rows.Clear(); foreach (var a in Property.PropertyList.OrderBy(i => i.StreetAddress.State).ThenBy(i => i.StreetAddress.City).ThenBy(i => i.StreetAddress.StreetAddress.Substring(i.StreetAddress.StreetAddress.IndexOf(" ") + 1))) { Bitmap statusImg = null; if (a.Status == "Rented") { statusImg = Properties.Resources.Home_Green; } if (a.Status == "Ready to rent") { statusImg = Properties.Resources.Home_Yellow; } if (a.Status == "Not Ready to rent") { statusImg = Properties.Resources.Home_Red; } DataGridViewRow row = new DataGridViewRow() { Height = 80 }; DataGridViewTextBoxCell ID = new DataGridViewTextBoxCell() { Value = a.PropertyID }; DataGridViewImageCell Image = new DataGridViewImageCell() { Value = a.Image, ImageLayout = a.Image == null ? DataGridViewImageCellLayout.Normal : DataGridViewImageCellLayout.Zoom }; DataGridViewTextBoxCell Address = new DataGridViewTextBoxCell() { Value = a.StreetAddress.StreetAddress }; DataGridViewTextBoxCell Features = new DataGridViewTextBoxCell() { Value = a.PropertyFeatures != null ? a.PropertyFeatures.Bedrooms + "bed " + a.PropertyFeatures.Bathrooms + "bath" : "n/a" }; DataGridViewTextBoxCell Rent = new DataGridViewTextBoxCell() { Value = !ReferenceEquals(null, a.CurrentLease) ? string.Format("{0:C}", a.CurrentLease.Rent) : "n/a" }; DataGridViewImageCell Status = new DataGridViewImageCell() { Value = statusImg }; row.Cells.Add(ID); row.Cells.Add(Image); row.Cells.Add(Address); row.Cells.Add(Features); row.Cells.Add(Rent); row.Cells.Add(Status); dgv_Properties.Rows.Add(row); } }
private void ClickAddEntry(object sender, EventArgs e) { SelectPlotDataDialog dialog = new SelectPlotDataDialog(m_owner.Environment); if (dialog.ShowDialog() != DialogResult.OK) return; string xName = dialog.X; string yName = dialog.Y; int ind = displaySettingDataGrid.Rows.Count; double interval = m_owner.DataManager .GetLoggerPolicy(m_owner.DataManager.GetCurrentSimulationParameterID()) .ReloadInterval; double endTime = m_owner.DataManager.GetCurrentSimulationTime(); LogData dataX = m_owner.DataManager.GetLogData(0.0, endTime, endTime/10000.0, xName); LogData dataY = m_owner.DataManager.GetLogData(0.0, endTime, endTime/10000.0, yName); if (dataX.logValueList.Count != dataY.logValueList.Count) { return; } Bitmap b = new Bitmap(20, 20); Graphics g = Graphics.FromImage(b); g.FillRectangle(Util.GetColorBlush(ind), 3, 3, 14, 14); g.ReleaseHdc(g.GetHdc()); DataGridViewRow r = new DataGridViewRow(); DataGridViewImageCell c1 = new DataGridViewImageCell(); c1.Value = b; r.Cells.Add(c1); DataGridViewTextBoxCell c2 = new DataGridViewTextBoxCell(); c2.Value = xName; r.Cells.Add(c2); DataGridViewTextBoxCell c3 = new DataGridViewTextBoxCell(); c3.Value = yName; r.Cells.Add(c3); r.Tag = m_entryNum; displaySettingDataGrid.Rows.Add(r); c2.ReadOnly = true; c3.ReadOnly = true; LineItem i = m_zCnt.GraphPane.AddCurve(xName, new PointPairList(), Util.GetColor(ind), SymbolType.None); i.Line.Width = 1; m_lineDic.Add(m_entryNum, i); m_entryNum++; for (int j = 0; j < dataX.logValueList.Count; j++) { i.AddPoint(dataX.logValueList[j].value, dataY.logValueList[j].value); } m_zCnt.AxisChange(); Graphics g1 = m_zCnt.CreateGraphics(); g1.ResetClip(); g1.SetClip(m_zCnt.MasterPane.Rect); i.Draw(g1, m_zCnt.GraphPane, 0, 1.5F); g1.ResetClip(); m_zCnt.Refresh(); }
private void AddCells() { ImageCell = new DataGridViewImageCell(false); ImageCell.ValueType = typeof(Image); SizeCell = new DataGridViewTextBoxCell(); SrCell = new DataGridViewTextBoxCell(); SharedCell = new DataGridViewTextBoxCell(); Cells.AddRange(new DataGridViewCell[] { ImageCell, SrCell, SizeCell, SharedCell }); UpdateDetails(); }
private DataGridViewRow NewAlertRow(Alert alert) { DataGridViewImageCell expanderCell = new DataGridViewImageCell(); DataGridViewImageCell imageCell = new DataGridViewImageCell(); DataGridViewTextBoxCell appliesCell = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell detailCell = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell dateCell = new DataGridViewTextBoxCell(); DataGridViewRow newRow = new DataGridViewRow(); newRow.Tag = alert; // Get the relevant image for the row depending on the type of the alert Image typeImage = alert is MessageAlert && ((MessageAlert)alert).Message.ShowOnGraphs ? Images.GetImage16For(((MessageAlert)alert).Message.Type) : Images.GetImage16For(alert.Priority); imageCell.Value = typeImage; // Set the detail cell content and expanding arrow if (expandedState.ContainsKey(alert.uuid)) { // show the expanded arrow and the body detail expanderCell.Value = Properties.Resources.expanded_triangle; detailCell.Value = String.Format("{0}\n\n{1}", alert.Title, alert.Description); } else { // show the expand arrow and just the title expanderCell.Value = Properties.Resources.contracted_triangle; detailCell.Value = alert.Title; } appliesCell.Value = alert.AppliesTo; dateCell.Value = HelpersGUI.DateTimeToString(alert.Timestamp.ToLocalTime(), Messages.DATEFORMAT_DMY_HM, true); newRow.Cells.Add(expanderCell); newRow.Cells.Add(imageCell); newRow.Cells.Add(appliesCell); newRow.Cells.Add(detailCell); newRow.Cells.Add(dateCell); return newRow; }
private void CreateCells() { ImageCell = new DataGridViewImageCell(false); ImageCell.ValueType = typeof (Image); MacCell = new DataGridViewTextBoxCell(); NetworkCell = new DataGridViewTextBoxCell(); Cells.AddRange(new DataGridViewCell[] { ImageCell, MacCell, NetworkCell }); UpdateDetails(); }
private void updateTimer_Tick(object sender, EventArgs e) { try { ((System.Windows.Forms.Timer)sender).Stop(); updateTimer.Interval = Math.Max(1000, uploadsDataGridView.Rows.Count * 10); if (m_MainForm.ActiveTab == this && !m_MainForm.IsInTray) try { // T.Norad: BZ 121. Copy uploads collection to prevent a lock on the uploads collection in core. RIndexedHashtable<string, Upload> uploadsCopy = new RIndexedHashtable<string, Upload>(Core.Uploads); uploadsLabel.Text = string.Format(Properties.Resources.Uploads, uploadsCopy.Count, Constants.MaximumUploadsCount, uploadsCopy.Count - Constants.MaximumUploadsCount < 0 ? 0 : uploadsCopy.Count - Constants.MaximumUploadsCount); { DataGridViewRow row; for (int n = uploadsDataGridView.Rows.Count - 1; n >= 0; n--) { row = uploadsDataGridView.Rows[n]; if (!uploadsCopy.ContainsKey(((RandomTag<string>)row.Tag).Tag)) { try { ((Image)row.Cells["Progress"].Value).Dispose(); } catch { } uploadsDataGridView.Rows.RemoveAt(n); } } } DataGridViewRow uploadRow; DataGridViewCell uploadCell; int a = 0; foreach (Upload upload in uploadsCopy.Values) { if (a % 50 == 0) Application.DoEvents(); a++; uploadRow = null; foreach (DataGridViewRow row in uploadsDataGridView.Rows) if ((((RandomTag<string>)row.Tag).Tag).Equals(upload.UploadIDString)) { uploadRow = row; break; } // get display values from shared files or (swarming) download String fileName; String fileSizeString; long fileSize; try { SharedFile sharedFile; if (Core.SharedFiles.TryGetValue(upload.FileHashString, out sharedFile)) { fileName = sharedFile.FileName; fileSizeString = sharedFile.FileSizeString; fileSize = sharedFile.FileSize; } else { Download download; if (Core.DownloadsAndQueue.TryGetValue(upload.SourceDownloadIDString, out download)) { fileName = download.FileName; fileSizeString = download.FileSizeString; fileSize = download.FileSize; } else continue; } } catch { continue; } // create grid rows if (uploadRow == null) { uploadRow = new DataGridViewRow(); uploadRow.Height = 17; uploadCell = new DataGridViewTextBoxCell(); uploadRow.Cells.Add(uploadCell); uploadCell.Value = fileName; uploadCell = new DataGridViewTextBoxCell(); uploadRow.Cells.Add(uploadCell); uploadCell.Value = fileSizeString; uploadCell.Tag = fileSize; uploadCell = new DataGridViewTextBoxCell(); uploadRow.Cells.Add(uploadCell); uploadCell.Value = upload.CompletedString; uploadCell.Tag = upload.Completed; uploadCell = new DataGridViewImageCell(); uploadRow.Cells.Add(uploadCell); try { uploadCell.Value = ProgressBars.GetProgressBar(upload, uploadsDataGridView.Columns["Progress"].Width, 16); } catch { } uploadCell = new DataGridViewTextBoxCell(); uploadRow.Cells.Add(uploadCell); if (uploadsCopy.IndexOfKey(upload.UploadIDString) < Constants.MaximumUploadsCount) { uploadCell.Value = upload.UpstreamString; uploadCell.Tag = upload.Upstream; } else { uploadCell.Value = string.Empty; uploadCell.Tag = -1; } uploadCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight; uploadRow.Tag = new RandomTag<string>(upload.UploadIDString); uploadsDataGridView.Rows.Add(uploadRow); continue; } uploadCell = uploadRow.Cells["FileName"]; uploadCell.Value = fileName; uploadCell = uploadRow.Cells["FileSize"]; uploadCell.Value = fileSizeString; uploadCell.Tag = fileSize; uploadCell = uploadRow.Cells["Completed"]; uploadCell.Value = upload.CompletedString; uploadCell.Tag = upload.Completed; uploadCell = uploadRow.Cells["Progress"]; try { ((Image)uploadCell.Value).Dispose(); } catch { } try { uploadCell.Value = ProgressBars.GetProgressBar(upload, (int)uploadsDataGridView.Columns["Progress"].Width, 16); } catch { } uploadCell = uploadRow.Cells["lastRequest"]; if (uploadsCopy.IndexOfKey(upload.UploadIDString) < Constants.MaximumUploadsCount) { uploadCell.Value = upload.UpstreamString; uploadCell.Tag = upload.Upstream; } else { uploadCell.Value = string.Empty; uploadCell.Tag = -1; } } uploadsDataGridView.Sort(uploadsDataGridView.SortedColumn, uploadsDataGridView.SortOrder == SortOrder.Descending ? ListSortDirection.Descending : ListSortDirection.Ascending); } catch (Exception ex) { Logger.Instance.Log(ex, "An exception was thrown! (UploadsControl)"); } } finally { ((System.Windows.Forms.Timer)sender).Start(); } }
public VMRestoreRow(VM vm) { // The image cell, shows the current state of the VM DataGridViewImageCell iconCell = new DataGridViewImageCell(); iconCell.Value = Images.GetImage16For(vm); Cells.Add(iconCell); // The VM name cell DataGridViewTextBoxCell nameCell = new DataGridViewTextBoxCell(); nameCell.Value = Helpers.GetName(vm); Cells.Add(nameCell); // The current location cell DataGridViewTextBoxCell locationCell = new DataGridViewTextBoxCell(); locationCell.Value = Helpers.GetName(vm.Connection.Resolve(vm.resident_on)); Cells.Add(locationCell); }
private DataGridViewRow NewUpdateRow(Alert alert) { DataGridViewImageCell expanderCell = new DataGridViewImageCell(); DataGridViewTextBoxCell messageCell = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell appliesToCell = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell dateCell = new DataGridViewTextBoxCell(); DataGridViewLinkCell webPageCell = new DataGridViewLinkCell(); DataGridViewRow newRow = new DataGridViewRow(); newRow.Tag = alert; // Set the detail cell content and expanding arrow if (expandedState.ContainsKey(alert.uuid)) { // show the expanded arrow and the body detail expanderCell.Value = Properties.Resources.expanded_triangle; messageCell.Value = String.Format("{0}\n\n{1}", alert.Title, alert.Description); } else { // show the expand arrow and just the title expanderCell.Value = Properties.Resources.contracted_triangle; messageCell.Value = alert.Title; } dateCell.Value = HelpersGUI.DateTimeToString(alert.Timestamp.ToLocalTime(), Messages.DATEFORMAT_DMY, true); webPageCell.Value = alert.WebPageLabel; appliesToCell.Value = alert.AppliesTo; newRow.Cells.AddRange(expanderCell, messageCell, appliesToCell, dateCell, webPageCell); return newRow; }
public VmWithSettingsRow(VM vm, VM.HA_Restart_Priority? priority) { cellImage = new DataGridViewImageCell {ValueType = typeof(Image)}; cellVm = new DataGridViewTextBoxCell(); cellRestartPriority = new DataGridViewTextBoxCell(); cellStartOrder = new DataGridViewTextBoxCell(); cellDelay = new DataGridViewTextBoxCell(); cellAgile = new DataGridViewTextBoxCell(); Cells.AddRange(cellImage, cellVm, cellRestartPriority, cellStartOrder, cellDelay, cellAgile); UpdateVm(vm); UpdateRestartPriority(priority); UpdateStartOrder(vm.order); UpdateStartDelay(vm.start_delay); SetAgileCalculating(); }
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(1000, connectionsDataGridView.Rows.Count * 10); if (m_MainForm.ActiveTab == this && !m_MainForm.IsInTray) try { Core.Connections.Lock(); RShare.MainForm.SetUILanguage(); connectionsLabel.Text = string.Format(Properties.Resources.Connections, Core.Connections.Count); { DataGridViewRow row; for (int n = connectionsDataGridView.Rows.Count - 1; n >= 0; n--) { row = connectionsDataGridView.Rows[n]; if (!Core.Connections.ContainsKey(((RandomTag<IPAddress>)row.Tag).Tag)) connectionsDataGridView.Rows.RemoveAt(n); } } DataGridViewRow connectionRow; DataGridViewCell connectionCell; int a = 0; foreach (Connection connection in Core.Connections.Values) { if (a % 50 == 0) Application.DoEvents(); a++; connectionRow = null; foreach (DataGridViewRow row in connectionsDataGridView.Rows) if (((RandomTag<IPAddress>)row.Tag).Tag.Equals(connection.RemoteEndPoint.Address)) { connectionRow = row; break; } if (connectionRow == null) { connectionRow = new DataGridViewRow(); connectionRow.Height = 17; connectionCell = new DataGridViewImageCell(); connectionRow.Cells.Add(connectionCell); connectionCell.Value = Properties.Resources.connection_16x16; connectionCell = new DataGridViewTextBoxCell(); connectionRow.Cells.Add(connectionCell); connectionCell.Value = connection.RemoteEndPoint.Address.ToString(); byte[] temp = connection.RemoteEndPoint.Address.GetAddressBytes(); uint ip = (uint)temp[0] << 24; ip += (uint)temp[1] << 16; ip += (uint)temp[2] << 8; ip += (uint)temp[3]; connectionCell.Tag = ip; // 2007-08-15 T.Norad Ticket #42 connectionCell = new DataGridViewTextBoxCell(); connectionRow.Cells.Add(connectionCell); connectionCell.Value = connection.RemoteEndPoint.Port.ToString(); connectionCell.Tag = (long)connection.RemoteEndPoint.Port; connectionCell = new DataGridViewTextBoxCell(); connectionRow.Cells.Add(connectionCell); connectionCell.Value = connection.SentString; connectionCell.Tag = connection.Sent; connectionCell = new DataGridViewTextBoxCell(); connectionRow.Cells.Add(connectionCell); connectionCell.Value = connection.ReceivedString; connectionCell.Tag = connection.Received; connectionCell = new DataGridViewTextBoxCell(); connectionRow.Cells.Add(connectionCell); connectionCell.Value = connection.SentCommands.ToString(); connectionCell.Tag = connection.SentCommands; connectionCell = new DataGridViewTextBoxCell(); connectionRow.Cells.Add(connectionCell); connectionCell.Value = connection.ReceivedCommands.ToString(); connectionCell.Tag = connection.ReceivedCommands; connectionCell = new DataGridViewTextBoxCell(); connectionRow.Cells.Add(connectionCell); connectionCell.Value = connection.EnqueuedCommandsCount.ToString(); connectionCell.Tag = connection.EnqueuedCommandsCount; connectionRow.Tag = new RandomTag<IPAddress>(connection.RemoteEndPoint.Address); connectionsDataGridView.Rows.Add(connectionRow); continue; } connectionCell = connectionRow.Cells["Sent"]; connectionCell.Value = connection.SentString; connectionCell.Tag = connection.Sent; connectionCell = connectionRow.Cells["Received"]; connectionCell.Value = connection.ReceivedString; connectionCell.Tag = connection.Received; connectionCell = connectionRow.Cells["SentCommands"]; connectionCell.Value = connection.SentCommands.ToString(); connectionCell.Tag = connection.SentCommands; connectionCell = connectionRow.Cells["ReceivedCommands"]; connectionCell.Value = connection.ReceivedCommands.ToString(); connectionCell.Tag = connection.ReceivedCommands; connectionCell = connectionRow.Cells["EnqueuedCommands"]; connectionCell.Value = connection.EnqueuedCommandsCount.ToString(); connectionCell.Tag = connection.EnqueuedCommandsCount; } connectionsDataGridView.Sort(connectionsDataGridView.SortedColumn, connectionsDataGridView.SortOrder == SortOrder.Descending ? ListSortDirection.Descending : ListSortDirection.Ascending); } catch (Exception ex) { Logger.Instance.Log(ex, "An exception was thrown! (ConnectionsControl)"); } finally { Core.Connections.Unlock(); } } finally { ((System.Windows.Forms.Timer)sender).Start(); } }
protected void SetupCells() { imageCell = GetImageCell(); detailsCell = GetDetailsCell(); Cells.Add(imageCell); Cells.Add(detailsCell); }
public void DrawStatusIcon(int rowIndex, LicenseDataGridViewRow.Status status) { Program.Invoke(Program.MainWindow, delegate { SuspendLayout(); try { DataGridViewCell cell = new DataGridViewImageCell { ValueIsIcon = true, ValueType = typeof (Bitmap), Value = new Bitmap(1,1) }; if (status == LicenseDataGridViewRow.Status.Information) cell.Value = Resources._000_Alert2_h32bit_16; if (status == LicenseDataGridViewRow.Status.Warning) cell.Value = Resources._000_error_h32bit_16; if (status == LicenseDataGridViewRow.Status.Ok) cell.Value = Resources._000_Tick_h32bit_16; DataGridViewImageColumn col = Columns[statusColumnKey] as DataGridViewImageColumn; if (col == null) return; if (rowIndex < Rows.Count && rowIndex >= 0) { var r = Rows[rowIndex]; if (r.Cells.Count > col.Index) { if (r.Cells[col.Index] is DataGridViewImageCell) r.Cells[col.Index] = cell; } } } finally { ResumeLayout(); } }); }
private DataGridViewRow CreateRow(MoneyItem item) { var row = new DataGridViewRow(); int iconId = 0; Account account = this.User.Accounts[item.AccountId]; Category category = this.User.Categories[item.CategoryId]; Category parentCategory = null; if (category.ParentId > 0) { parentCategory = this.User.Categories[category.ParentId]; } if (item.IconId > 0) { // иконка записи iconId = item.IconId; } else { if (category.IconId > 0) { // иконка категории iconId = category.IconId; } else { // иконка статьи if (parentCategory != null) { iconId = parentCategory.IconId; } } } var iconCell = new DataGridViewImageCell(); if (iconId > 0) { iconCell.Value = this.User.GetIcon(iconId); } else { if (item.EntryType == EntryType.Expense) { iconCell.Value = Properties.Resources.item_еxpense; } else if (item.EntryType == EntryType.Income) { iconCell.Value = Properties.Resources.item_income; } else { iconCell.Value = Properties.Resources.item; } } row.Cells.Add(iconCell); row.Cells.Add(new DataGridViewTextBoxCell { Value = (parentCategory != null ? parentCategory.Name : category.Name) }); row.Cells.Add(new DataGridViewTextBoxCell { Value = (parentCategory != null ? category.Name : "") }); row.Cells.Add(new DataGridViewTextBoxCell { Value = item.Title }); row.Cells.Add(new DataGridViewTextBoxCell { Value = account.Name }); row.Cells.Add(new DataGridViewTextBoxCell { Value = item.DateEntry }); row.Cells.Add(new DataGridViewTextBoxCell { Value = item.Amount }); row.Cells.Add(new DataGridViewTextBoxCell { Value = account.CurrencyCode, Tag = account.CurrencyCode }); //u.Currencies[account.CurrencyCode].ShortName row.Tag = item; // стили row.DefaultCellStyle.BackColor = category.BackColor; row.DefaultCellStyle.ForeColor = category.ForeColor; row.DefaultCellStyle.Font = new Font(this.DataGridView1.Font, category.FontStyle); return row; }
private DataGridViewRow NewUpdateRow(Alert alert) { var expanderCell = new DataGridViewImageCell(); var appliesCell = new DataGridViewTextBoxCell(); var detailCell = new DataGridViewTextBoxCell(); var dateCell = new DataGridViewTextBoxCell(); var actionItems = GetAlertActionItems(alert); var actionCell = new DataGridViewDropDownSplitButtonCell(actionItems.ToArray()); var newRow = new DataGridViewRow { Tag = alert, MinimumHeight = DataGridViewDropDownSplitButtonCell.MIN_ROW_HEIGHT }; // Set the detail cell content and expanding arrow if (expandedState.ContainsKey(alert.uuid)) { // show the expanded arrow and the body detail expanderCell.Value = Properties.Resources.expanded_triangle; detailCell.Value = String.Format("{0}\n\n{1}", alert.Title, alert.Description); } else { // show the expand arrow and just the title expanderCell.Value = Properties.Resources.contracted_triangle; detailCell.Value = alert.Title; } appliesCell.Value = alert.AppliesTo; dateCell.Value = HelpersGUI.DateTimeToString(alert.Timestamp.ToLocalTime(), Messages.DATEFORMAT_DMY, true); newRow.Cells.AddRange(expanderCell, detailCell, appliesCell, dateCell, actionCell); return newRow; }
public baseGridViewImageColumn(DataGridViewImageCell obj) : base(obj) { }
private void updateTimer_Tick(object sender, EventArgs e) { try { ((System.Windows.Forms.Timer)sender).Stop(); updateTimer.Interval = Math.Max(Math.Max(1000, downloadsDataGridView.Rows.Count * 10), Math.Max(1000, Math.Max(downloadsDataGridView.Rows.Count * 10, sourcesDataGridView.Rows.Count * 10))); if (m_MainForm.ActiveTab == this && !m_MainForm.IsInTray) { Download selectedDownload = null; try { Core.DownloadsAndQueue.Lock(); downloadsLabel.Text = string.Format(RShare.Properties.Resources.Downloads, Math.Min(Core.DownloadsAndQueue.Count, Constants.MaximumDownloadsCount), Core.DownloadsAndQueue.Count); { DataGridViewRow row; for (int n = downloadsDataGridView.Rows.Count - 1; n >= 0; n--) { row = downloadsDataGridView.Rows[n]; if (!Core.DownloadsAndQueue.ContainsKey(((RandomTag<string>)row.Tag).Tag)) { try { ((Image)row.Cells["ProgressImage"].Value).Dispose(); } catch { } downloadsDataGridView.Rows.RemoveAt(n); } } } DataGridViewRow downloadRow; DataGridViewCell downloadCell; int a = 0; foreach (Download download in Core.DownloadsAndQueue.Values) { if (a % 50 == 0) Application.DoEvents(); a++; downloadRow = null; foreach (DataGridViewRow row in downloadsDataGridView.Rows) if ((((RandomTag<string>)row.Tag).Tag).Equals(download.DownloadIDString)) { downloadRow = row; break; } if (downloadRow == null) { downloadRow = new DataGridViewRow(); downloadRow.Height = 17; downloadCell = new DataGridViewImageCell(); downloadRow.Cells.Add(downloadCell); downloadCell.Tag = download.FileName; try { // 2008-10-21 Eroli: Mono-Fix if (!UtilitiesForMono.IsRunningOnMono) downloadCell.Value = ShellIcon.GetSmallSystemIcon((string)downloadCell.Tag); } catch { } downloadCell = new DataGridViewImageCell(); downloadRow.Cells.Add(downloadCell); downloadCell.Value = GetRatingImage(download); downloadCell.Tag = download.Rating; downloadCell = new DataGridViewTextBoxCell(); downloadRow.Cells.Add(downloadCell); downloadCell.Value = download.FileName; downloadCell = new DataGridViewTextBoxCell(); downloadRow.Cells.Add(downloadCell); downloadCell.Value = download.FileSizeString; downloadCell.Tag = download.FileSize; downloadCell = new DataGridViewTextBoxCell(); downloadRow.Cells.Add(downloadCell); downloadCell.Value = download.CompletedString; downloadCell.Tag = download.Completed; downloadCell = new DataGridViewImageCell(); downloadRow.Cells.Add(downloadCell); try { downloadCell.Value = ProgressBars.GetProgressBar(download, downloadsDataGridView.Columns["ProgressImage"].Width, 16, Font); } catch { } downloadCell.Tag = download.Progress; //2008-10-21 Eroli: Bugfix downloadCell = new DataGridViewTextBoxCell(); downloadRow.Cells.Add(downloadCell); downloadCell.Value = download.IsActive ? RShare.Properties.Resources.DownloadIsStarted : RShare.Properties.Resources.DownloadIsQueued; downloadCell.Tag = download.QueuePostition; //2008-10-21 Eroli: Bugfix-End downloadCell = new DataGridViewTextBoxCell(); downloadRow.Cells.Add(downloadCell); //2009-01-02 Eroli: Bugfix downloadCell.Value = GetSourceString(download); downloadCell.Tag = download.Sources.Count; downloadCell = new DataGridViewTextBoxCell(); downloadRow.Cells.Add(downloadCell); downloadCell.Value = download.RemainingString; downloadCell.Tag = download.Remaining; //2008-10-21 Eroli: Bugfix downloadCell = new DataGridViewTextBoxCell(); downloadRow.Cells.Add(downloadCell); if (download.LastSeen != null) { TimeSpan span = DateTime.Now.Subtract((DateTime)download.LastSeen); downloadCell.Value = string.Format(Properties.Resources.Date_Diff, span.Days, span.Hours, span.Minutes, span.Seconds); downloadCell.Tag = download.LastSeen; } downloadCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight; downloadCell = new DataGridViewTextBoxCell(); downloadRow.Cells.Add(downloadCell); if (Core.DownloadsAndQueue.IndexOfKey(download.DownloadIDString) < Constants.MaximumDownloadsCount) { downloadCell.Value = download.DownstreamString; downloadCell.Tag = download.Downstream; } else { downloadCell.Value = string.Empty; downloadCell.Tag = -1; } downloadCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight; //2008-10-21 Eroli: Bugfix-End downloadRow.Tag = new RandomTag<string>(download.DownloadIDString); downloadsDataGridView.Rows.Add(downloadRow); continue; } downloadCell = downloadRow.Cells["DownloadIcon"]; if ((string)downloadCell.Tag != download.FileName) { downloadCell.Tag = download.FileName; try { // 2008-10-21 Eroli: Mono-Fix if (!UtilitiesForMono.IsRunningOnMono) downloadCell.Value = ShellIcon.GetSmallSystemIcon((string)downloadCell.Tag); } catch { } } downloadCell = downloadRow.Cells["RatingIcon"]; downloadCell.Value = GetRatingImage(download); downloadCell.Tag = download.Rating; downloadCell = downloadRow.Cells["FileName"]; downloadCell.Value = download.FileName; downloadCell = downloadRow.Cells["FileSize"]; downloadCell.Value = download.FileSizeString; downloadCell.Tag = download.FileSize; downloadCell = downloadRow.Cells["Completed"]; downloadCell.Value = download.CompletedString; downloadCell.Tag = download.Completed; downloadCell = downloadRow.Cells["ProgressImage"]; try { ((Image)downloadCell.Value).Dispose(); } catch { } try { downloadCell.Value = ProgressBars.GetProgressBar(download, downloadsDataGridView.Columns["ProgressImage"].Width, 16, Font); } catch { } downloadCell.Tag = download.Progress; //2008-03-20 Nochbaer downloadCell = downloadRow.Cells["Status"]; downloadCell.Value = download.IsActive ? RShare.Properties.Resources.DownloadIsStarted : RShare.Properties.Resources.DownloadIsQueued; downloadCell.Tag = download.QueuePostition; downloadCell = downloadRow.Cells["Sources"]; downloadCell.Value = GetSourceString(download); downloadCell.Tag = download.Sources.Count; downloadCell = downloadRow.Cells["Remaining"]; downloadCell.Value = download.RemainingString; downloadCell.Tag = download.Remaining; downloadCell = downloadRow.Cells["lastSeen"]; // T.Norad: calculate the date diff for display if (download.LastSeen != null) { TimeSpan span = DateTime.Now.Subtract((DateTime)download.LastSeen); downloadCell.Value = string.Format(Properties.Resources.Date_Diff, span.Days, span.Hours, span.Minutes, span.Seconds); downloadCell.Tag = download.LastSeen; } downloadCell = downloadRow.Cells["lastReception"]; if (Core.DownloadsAndQueue.IndexOfKey(download.DownloadIDString) < Constants.MaximumDownloadsCount) { downloadCell.Value = download.DownstreamString; downloadCell.Tag = download.Downstream; } else { downloadCell.Value = string.Empty; downloadCell.Tag = -1; } downloadCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight; } downloadsDataGridView.Sort(downloadsDataGridView.SortedColumn, downloadsDataGridView.SortOrder == SortOrder.Descending ? ListSortDirection.Descending : ListSortDirection.Ascending); if (downloadsDataGridView.SelectedRows.Count == 1) Core.DownloadsAndQueue.TryGetValue(((RandomTag<string>)downloadsDataGridView.SelectedRows[0].Tag).Tag, out selectedDownload); } catch (InvalidOperationException) { // T.Norad BZ138: Ignore this exception. // cause of this exception is: the enumerator from "Core.DownloadsAndQueue.Values" // comes invalid cause some other code change the collection if we use // the enumerator. // catch this exception is only a workaround. } catch (Exception ex) { Logger.Instance.Log(ex, "An exception was thrown! (DownloadsControl - Downloads)"); } finally { Core.DownloadsAndQueue.Unlock(); } if (selectedDownload != null) { try { selectedDownload.Sources.Lock(); sourcesDataGridView.Tag = selectedDownload.DownloadIDString; sourcesDataGridView.Enabled = true; { DataGridViewRow row; for (int n = sourcesDataGridView.Rows.Count - 1; n >= 0; n--) { row = sourcesDataGridView.Rows[n]; if (!selectedDownload.Sources.ContainsKey(((RandomTag<string>)row.Tag).Tag)) sourcesDataGridView.Rows.RemoveAt(n); } } DataGridViewRow sourceRow; DataGridViewCell sourceCell; int a = 0; foreach (Download.Source source in selectedDownload.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; // column: peer icon sourceCell = new DataGridViewImageCell(); sourceRow.Cells.Add(sourceCell); sourceCell.Value = Properties.Resources.peer_16x16; // column: star icon sourceCell = new DataGridViewImageCell(); sourceRow.Cells.Add(sourceCell); sourceCell.Value = GetTypeImage(source); sourceCell.Tag = source.LastReceived; sourceCell = new DataGridViewTextBoxCell(); sourceRow.Cells.Add(sourceCell); sourceCell.Value = GetTypeString(source); sourceCell.Tag = source.State; // column: progress bar sourceCell = new DataGridViewImageCell(); sourceRow.Cells.Add(sourceCell); try { sourceCell.Value = ProgressBars.GetProgressBar(selectedDownload, source, sourcesDataGridView.Columns["Progress"].Width, 16); } catch { } // column: queue position sourceCell = new DataGridViewTextBoxCell(); sourceRow.Cells.Add(sourceCell); if (source.State == Download.SourceState.NotNeeded) { sourceCell.Value = Properties.Resources.NoNeededSectors; sourceCell.Tag = int.MaxValue - 1; } else if (source.State == Download.SourceState.Verifying || source.State == Download.SourceState.Requesting || source.IsQueueFull) { sourceCell.Value = Properties.Resources.SourceQueuePositionUnknown; sourceCell.Tag = int.MaxValue; } else if (source.State == Download.SourceState.Verified) { sourceCell.Value = source.QueueLength.ToString(); sourceCell.Tag = source.QueueLength + 1; } else if (source.State == Download.SourceState.Requested) { sourceCell.Value = source.QueuePosition.ToString(); sourceCell.Tag = source.QueuePosition + 1; } else if (source.State == Download.SourceState.Active) { sourceCell.Value = Properties.Resources.SourceState_Active; sourceCell.Tag = 0; } // sourceCell = new DataGridViewTextBoxCell(); sourceRow.Cells.Add(sourceCell); sourceCell.Value = source.SentCommands.ToString(); sourceCell.Tag = source.SentCommands; sourceCell = new DataGridViewTextBoxCell(); sourceRow.Cells.Add(sourceCell); sourceCell.Value = source.ReceivedCommands.ToString(); sourceCell.Tag = source.ReceivedCommands; sourceRow.Tag = new RandomTag<string>(source.PeerIDString); sourcesDataGridView.Rows.Add(sourceRow); continue; } sourceCell = sourceRow.Cells["TypeIcon"]; sourceCell.Value = GetTypeImage(source); sourceCell.Tag = source.LastReceived; sourceCell = sourceRow.Cells["Type"]; sourceCell.Value = GetTypeString(source); sourceCell.Tag = source.State; sourceCell = sourceRow.Cells["Progress"]; try { ((Image)sourceCell.Value).Dispose(); } catch { } try { sourceCell.Value = ProgressBars.GetProgressBar(selectedDownload, source, sourcesDataGridView.Columns["Progress"].Width, 16); } catch { } sourceCell = sourceRow.Cells["Queue"]; if (source.State == Download.SourceState.NotNeeded) { sourceCell.Value = Properties.Resources.NoNeededSectors; sourceCell.Tag = int.MaxValue - 1; } else if (source.State == Download.SourceState.Verifying || source.State == Download.SourceState.Requesting || source.IsQueueFull) { sourceCell.Value = Properties.Resources.SourceQueuePositionUnknown; sourceCell.Tag = int.MaxValue; } else if (source.State == Download.SourceState.Verified) { sourceCell.Value = source.QueueLength.ToString(); sourceCell.Tag = source.QueueLength + 1; } else if (source.State == Download.SourceState.Requested) { sourceCell.Value = source.QueuePosition.ToString(); sourceCell.Tag = source.QueuePosition + 1; } else if (source.State == Download.SourceState.Active) { sourceCell.Value = Properties.Resources.SourceState_Active; sourceCell.Tag = 0; } sourceCell = sourceRow.Cells["SentCommands"]; sourceCell.Value = source.SentCommands.ToString(); sourceCell.Tag = source.SentCommands; sourceCell = sourceRow.Cells["ReceivedCommands"]; sourceCell.Value = source.ReceivedCommands.ToString(); sourceCell.Tag = source.ReceivedCommands; } sourcesDataGridView.Sort(sourcesDataGridView.SortedColumn, sourcesDataGridView.SortOrder == SortOrder.Descending ? ListSortDirection.Descending : ListSortDirection.Ascending); } catch (Exception ex) { Logger.Instance.Log(ex, "An exception was thrown! (DownloadsControl - Sources)"); } finally { selectedDownload.Sources.Unlock(); } } else { sourcesDataGridView.Rows.Clear(); sourcesDataGridView.Tag = null; sourcesDataGridView.Enabled = false; } SelectionChanged(); } } finally { ((System.Windows.Forms.Timer)sender).Start(); } }
public void LoadTenantPage() { dgv_Tenant.Rows.Clear(); foreach (var b in Tenant.TenantList.OrderBy(i => i.LastName)) { DataGridViewRow row = new DataGridViewRow() { Height = 80 }; DataGridViewTextBoxCell ID = new DataGridViewTextBoxCell() { Value = b.TenantID }; DataGridViewImageCell Image = new DataGridViewImageCell() { Value = b.Image, ImageLayout = b.Image == null ? DataGridViewImageCellLayout.Normal : DataGridViewImageCellLayout.Zoom }; DataGridViewTextBoxCell FirstName = new DataGridViewTextBoxCell() { Value = b.FirstName }; DataGridViewTextBoxCell LastName = new DataGridViewTextBoxCell() { Value = b.LastName }; DataGridViewTextBoxCell Phone = new DataGridViewTextBoxCell() { Value = b.Phone }; DataGridViewTextBoxCell Email = new DataGridViewTextBoxCell() { Value = b.Email }; row.Cells.Add(ID); row.Cells.Add(Image); row.Cells.Add(FirstName); row.Cells.Add(LastName); row.Cells.Add(Phone); row.Cells.Add(Email); dgv_Tenant.Rows.Add(row); } }