public FirmwareUpdaterWindow(Firmware firmware, FirmwareLoader loader) { InitializeComponent(); Icon = Paths.ApplicationIcon; InitializeControls(); m_firmware = firmware; m_loader = loader; m_worker.DoWork += BackgroundWorker_DoWork; m_worker.ProgressChanged += BackgroundWorker_ProgressChanged; }
private void Save([NotNull] string filePath, Firmware firmware, bool encode) { if (firmware == null) { throw new ArgumentNullException("firmware"); } if (string.IsNullOrEmpty(filePath)) { throw new ArgumentNullException("filePath"); } var data = encode ? m_encoder.Encode(firmware.GetBody()) : firmware.GetBody(); File.WriteAllBytes(filePath, data); }
private void Save([NotNull] string filePath, Firmware firmware, EncryptionType encryptionType) { if (firmware == null) { throw new ArgumentNullException("firmware"); } if (string.IsNullOrEmpty(filePath)) { throw new ArgumentNullException("filePath"); } var data = s_encryptors.ContainsKey(encryptionType) ? s_encryptors[encryptionType].Encode(firmware.GetBody()) : firmware.GetBody(); File.WriteAllBytes(filePath, data); }
public void SaveDecrypted([NotNull] string filePath, [NotNull] Firmware firmware) { Save(filePath, firmware, false); }
public void SaveEncrypted([NotNull] string filePath, [NotNull] Firmware firmware) { Save(filePath, firmware, true); }
private void OpenFirmware(string firmwareFile, Func<string, Firmware> readFirmwareDelegate) { ResetWorkspace(); try { var firmware = readFirmwareDelegate(firmwareFile); if (firmware == null) { throw new InvalidOperationException("No one definition is not appropriate for the selected firmware file."); } m_firmware = firmware; m_firmwareFile = firmwareFile; ImageCacheManager.RebuildCache(m_firmware); m_tabPages.ForEach(x => { x.OnFirmwareLoaded(m_firmware); x.IsDirty = false; }); SaveMenuItem.Enabled = true; SaveEncryptedMenuItem.Enabled = true; SaveDecryptedMenuItem.Enabled = true; StatusLabel.Text = @"Firmware file has been successfully loaded."; m_mruFirmwares.Add(firmwareFile); UpdateOpenedFirmwareInfo(); } catch (Exception ex) { m_mruFirmwares.Remove(firmwareFile); InfoBox.Show("Unable to load firmware.\n{0}", ex.Message); } finally { InitializeMruMenu(); } }
public void SaveDecrypted([NotNull] string filePath, [NotNull] Firmware firmware) { Save(filePath, firmware, EncryptionType.None); }
public void OnFirmwareLoaded(Firmware firmware) { m_firmware = firmware; Block1ImageRadioButton.Enabled = true; Block1ImageRadioButton.Checked = true; Block2ImageRadioButton.Enabled = m_firmware.Block2Images.Any(); Block2ImageListBox.Fill(m_firmware.Block2Images.Values.Select(x => new ImagedItem<FirmwareImageMetadata>(x, x.Index, string.Format("0x{0:X2}", x.Index))), true); Block1ImageListBox.Fill(m_firmware.Block1Images.Values.Select(x => new ImagedItem<FirmwareImageMetadata>(x, x.Index, string.Format("0x{0:X2}", x.Index))), true); }
public void OnFirmwareLoaded(Firmware firmware) { m_firmware = firmware; m_suitablePatches = m_patchManager.LoadPatchesForFirmware(firmware.Definition).OrderBy(x => x.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.FileName, patch.Version, patch.IsApplied ? "Yes" : "No", patch.IsCompatible ? "Yes" : "No" }) { Tag = patch }; })); ReloadPatchesButton.Enabled = true; if (m_configuration.CheckForApplicationUpdates) { bool updatesAlreadyChecked; m_checkedFirmwares.TryGetValue(firmware.Definition.Name, out updatesAlreadyChecked); if (!updatesAlreadyChecked) { m_checkedFirmwares[firmware.Definition.Name] = true; CheckForUpdatesWithUserInteraction(false); } } }
public void OnFirmwareLoaded(Firmware firmware) { m_firmware = firmware; m_suitableResourcePacks = m_allResourcePacks.Where(x => x.SuitableDefinitions.Contains(m_firmware.Definition.Name)).OrderBy(x => x.Name); ResourcePackListView.Fill(m_suitableResourcePacks.Select(resourcePack => new ListViewItem(new[] { resourcePack.Name, resourcePack.FileName, resourcePack.Version }) { Tag = resourcePack })); ImportResourcePackButton.Enabled = true; ReloadResourcePacksButton.Enabled = true; }