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)); 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); } 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); } } InfoBox.Show(sb.ToString()); }
public void OnFirmwareLoaded(Firmware firmware) { m_firmware = firmware; m_suitablePatches = m_allPatches.Where(x => string.Equals(x.Definition, m_firmware.Definition.Name)); PatchListView.Fill(m_suitablePatches.Select(patch => { patch.IsApplied = m_patchManager.IsPatchApplied(patch, m_firmware); patch.IsCompatible = m_patchManager.IsPatchCompatible(patch, m_firmware) || patch.IsApplied; return(new ListViewItem(new[] { patch.Name, patch.Version, patch.IsApplied ? "Yes" : "No", patch.IsCompatible ? "Yes" : "No" }) { Tag = patch }); })); ReloadPatchesButton.Enabled = true; }
private void CheckForUpdatesWithUserInteraction(bool notifyWhenNoUpdatesAvailable) { Invoke(new Action(() => { CheckForUpdatesButton.Enabled = false; PatchListView.Focus(); })); var checkForUpdates = new Action(() => { var newPatches = UpdatesManager.CheckForNewPatches(m_firmware.Definition, m_suitablePatches); Invoke(new Action(() => { CheckForUpdatesButton.Enabled = false; PatchListView.Focus(); CheckForUpdatesButton.Enabled = true; if (newPatches == null || newPatches.Count == 0) { if (notifyWhenNoUpdatesAvailable) { InfoBox.Global.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); }