public override void PageLoaded(PageLoadedDirection direction) { base.PageLoaded(direction); if (direction == PageLoadedDirection.Back) { if (dataGridViewPatches.SelectedRows.Count == 0) { return; } // refresh selected row if the update type is Existing (i.e. the update has been uploaded) int selectedIndex = dataGridViewPatches.SelectedRows[0].Index; string updateName = dataGridViewPatches.Rows[selectedIndex].Cells[ColumnUpdate.Index].Value.ToString(); if (SelectedUpdateType == UpdateType.Existing && (updateName.EndsWith(".xsoem") || updateName.EndsWith(".xsupdate"))) { // remove selected row and add a new one dataGridViewPatches.Rows.RemoveAt(selectedIndex); var row = new PatchGridViewRow(SelectedExistingPatch); if (!dataGridViewPatches.Rows.Contains(row)) { dataGridViewPatches.Rows.Add(row); row.UpdateDetails(); } row.Selected = true; } return; } PopulatePatchesBox(); UpdateEnablement(); }
private void PopulatePatchesBox() { try { var updates = Updates.UpdateAlerts.ToList(); if (dataGridViewPatches.SortedColumn != null) { if (dataGridViewPatches.SortedColumn.Index == ColumnUpdate.Index) { updates.Sort(Alert.CompareOnTitle); } else if (dataGridViewPatches.SortedColumn.Index == ColumnDate.Index) { updates.Sort(Alert.CompareOnDate); } else if (dataGridViewPatches.SortedColumn.Index == ColumnDescription.Index) { updates.Sort(Alert.CompareOnDescription); } if (dataGridViewPatches.SortOrder == SortOrder.Descending) { updates.Reverse(); } } else { updates.Sort(new NewVersionPriorityAlertComparer()); } dataGridViewPatches.SuspendLayout(); dataGridViewPatches.Rows.Clear(); foreach (Alert alert in updates) { if (!(alert is XenServerPatchAlert patchAlert)) { continue; } PatchGridViewRow row = new PatchGridViewRow(patchAlert); if (!dataGridViewPatches.Rows.Contains(row)) { dataGridViewPatches.Rows.Add(row); if (patchAlert.RequiredXenCenterVersion != null) { row.Enabled = false; row.SetToolTip(string.Format(Messages.UPDATES_WIZARD_NEWER_XENCENTER_REQUIRED, patchAlert.RequiredXenCenterVersion.Version)); } } } } finally { dataGridViewPatches.ResumeLayout(); } }
private void PopulatePatchesBox() { dataGridViewPatches.Rows.Clear(); var updates = new List <Alert>(Updates.UpdateAlerts); if (dataGridViewPatches.SortedColumn != null) { if (dataGridViewPatches.SortedColumn.Index == ColumnUpdate.Index) { updates.Sort(Alert.CompareOnTitle); } else if (dataGridViewPatches.SortedColumn.Index == ColumnDate.Index) { updates.Sort(Alert.CompareOnDate); } else if (dataGridViewPatches.SortedColumn.Index == ColumnDescription.Index) { updates.Sort(Alert.CompareOnAppliesTo); } if (dataGridViewPatches.SortOrder == SortOrder.Descending) { updates.Reverse(); } } foreach (Alert alert in updates) { PatchGridViewRow row = new PatchGridViewRow(alert); if (!dataGridViewPatches.Rows.Contains(row)) { dataGridViewPatches.Rows.Add(row); } } }
private void dataGridViewPatches_CellContentClick(object sender, DataGridViewCellEventArgs e) { // The click is on a column header if (e.RowIndex == -1) { return; } PatchGridViewRow row = dataGridViewPatches.Rows[e.RowIndex] as PatchGridViewRow; if (row != null && e.ColumnIndex == 3) { row.UpdateAlert.FixLinkAction(); } }
private void dataGridViewPatches_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.Button != MouseButtons.Left) { return; } if (e.RowIndex < 0) { // The click is on a column header return; } PatchGridViewRow row = (PatchGridViewRow)dataGridViewPatches.Rows[e.RowIndex]; row.toggleExpandedState(); OnPageUpdated(); }
public void AddFile(string fileName) { if (fileName.EndsWith(".xsoem") || fileName.EndsWith(".xsupdate") || fileName.EndsWith(".iso")) { PatchGridViewRow row = new PatchGridViewRow(fileName); int index = dataGridViewPatches.Rows.IndexOf(row); if (index < 0) { dataGridViewPatches.Rows.Insert(0, row); index = 0; } dataGridViewPatches.Rows[index].Selected = true; } else { new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, Messages.UPDATES_WIZARD_NOTVALID_EXTENSION, Messages.UPDATES)).ShowDialog(this); } }
private void PopulatePatchesBox() { dataGridViewPatches.Rows.Clear(); foreach (IXenConnection xenConnection in ConnectionsManager.XenConnectionsCopy) { foreach (Pool_patch patch in xenConnection.Cache.Pool_patches) { if (patch.size > 0) { PatchGridViewRow row = new PatchGridViewRow(patch); if (!dataGridViewPatches.Rows.Contains(row)) { dataGridViewPatches.Rows.Add(row); row.UpdateDetails(); } } } } dataGridViewPatches.Sort(ColumnUpdate, ListSortDirection.Ascending); }
private void PopulatePatchesBox() { try { var updates = Updates.UpdateAlerts; if (dataGridViewPatches.SortedColumn != null) { if (dataGridViewPatches.SortedColumn.Index == ColumnUpdate.Index) { updates.Sort(Alert.CompareOnTitle); } else if (dataGridViewPatches.SortedColumn.Index == ColumnDate.Index) { updates.Sort(Alert.CompareOnDate); } else if (dataGridViewPatches.SortedColumn.Index == ColumnDescription.Index) { updates.Sort(Alert.CompareOnDescription); } if (dataGridViewPatches.SortOrder == SortOrder.Descending) { updates.Reverse(); } } else { updates.Sort(new NewVersionPriorityAlertComparer()); } dataGridViewPatches.SuspendLayout(); dataGridViewPatches.Rows.Clear(); var rowList = new List <DataGridViewRow>(); foreach (Alert alert in updates) { if (!(alert is XenServerPatchAlert patchAlert)) { continue; } PatchGridViewRow row = new PatchGridViewRow(patchAlert); if (!rowList.Contains(row)) { rowList.Add(row); if (patchAlert.RequiredXenCenterVersion != null) { row.Enabled = false; row.SetToolTip(string.Format(Messages.UPDATES_WIZARD_NEWER_XENCENTER_REQUIRED, patchAlert.RequiredXenCenterVersion.Version)); } } } dataGridViewPatches.Rows.AddRange(rowList.ToArray()); if (UpdateAlertFromWeb != null) { var foundRow = dataGridViewPatches.Rows.Cast <PatchGridViewRow>() .FirstOrDefault(r => r.UpdateAlert.Equals(UpdateAlertFromWeb)); if (foundRow != null) { foundRow.Selected = true; UpdateAlertFromWebSelected?.Invoke(); } } } finally { dataGridViewPatches.ResumeLayout(); } }