private void ReloadPatchesButton_Click(object sender, EventArgs e) { var selectedItem = SelectedPatch; OnWorkspaceReset(); OnFirmwareLoaded(m_firmware); CheckForUpdatesButton.Enabled = true; if (selectedItem != null) { var found = false; foreach (ListViewItem item in PatchListView.Items) { var patch = item.Tag as Patch; if (patch == null || !string.Equals(selectedItem.Name, patch.Name)) { continue; } PatchListView.SelectedIndices.Add(item.Index); found = true; break; } if (!found && PatchListView.Items.Count > 0) { PatchListView.SelectedIndices.Add(0); } } PatchListView.Focus(); }
private void CheckForUpdatesWithUserInteraction(bool notifyWhenNoUpdatesAvailable) { this.UpdateUI(() => { CheckForUpdatesButton.Enabled = false; PatchListView.Focus(); }); var checkForUpdates = new Action(() => { var newPatches = UpdatesManager.CheckForNewPatches(m_firmware.Definition, m_suitablePatches); this.UpdateUI(() => { CheckForUpdatesButton.Enabled = true; if (newPatches == null || newPatches.Count == 0) { if (notifyWhenNoUpdatesAvailable) { InfoBox.Show("No updates available!"); } return; } using (var newPatchesWindow = new PatchUpdatesAvailableWindow(m_firmware.Definition, newPatches)) { if (newPatchesWindow.ShowDialog() != DialogResult.OK) { return; } ReloadPatchesButton_Click(null, EventArgs.Empty); } }); }); checkForUpdates.BeginInvoke(null, null); }
private void ReloadPatchesButton_Click(object sender, EventArgs e) { m_allPatches = m_patchManager.LoadAll(); OnWorkspaceReset(); OnFirmwareLoaded(m_firmware); PatchListView.Focus(); }
private void ApplyPatchesButton_Click(object sender, EventArgs e) { if (!CheckedPatches.Any()) { return; } var candidates = CheckedPatches.Where(x => !x.IsApplied).ToList(); PatchListView.CheckedItems.ForEach(x => x.Checked = false); PatchListView.Focus(); if (!candidates.Any()) { InfoBox.Show("Selected patches were already installed."); return; } var result = m_patchManager.BulkOperation(candidates, p => m_patchManager.ApplyPatch(p, m_firmware)); //UpdatePatchStatuses(); if (result.ProceededPatches.Count > 0) { m_host.ReloadFirmware(this); } var sb = new StringBuilder(); if (result.ProceededPatches.Count > 0) { sb.AppendLine("Patching is completed."); sb.AppendLine(); sb.AppendLine("List of installed patches:"); foreach (var patch in result.ProceededPatches) { sb.AppendLine(" - " + patch.Name); } IsDirty = true; } if (result.ConflictedPatches.Count > 0) { if (result.ConflictedPatches.Count == 0) { sb.AppendLine("Patching is not completed."); } sb.AppendLine(); sb.AppendLine("Patches that have not been installed because of conflicts:"); foreach (var patch in result.ConflictedPatches) { sb.AppendLine(" - " + patch.Name); } } InfoBox.Show(sb.ToString()); }