コード例 #1
0
        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());
        }