private void OkButton_Click(object sender, EventArgs e) { string fileName; using (var op = new OpenFileDialog { Title = @"Select encrypted or decrypted firmware file ...", Filter = Consts.FirmwareFilter }) { if (op.ShowDialog() != DialogResult.OK) { return; } fileName = op.FileName; } try { var firmware = m_loader.LoadFile(fileName); if (FirmwareLoader.FindByteArray(firmware, Encoding.UTF8.GetBytes(m_connectedDeviceProductId)) == -1) { InfoBox.Show("Selected firmware file is not suitable for the connected device."); return; } m_worker.RunWorkerAsync(firmware); } catch (Exception ex) { InfoBox.Show("An exception occured during firmware update.\n" + ex.Message); } }
private void CreateDiffLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (string.IsNullOrEmpty(Source1TextBox.Text) || string.IsNullOrEmpty(Source2TextBox.Text)) { return; } var file1 = m_loader.LoadFile(Source1TextBox.Text); var file2 = m_loader.LoadFile(Source2TextBox.Text); var definition = m_loader.DetermineDefinition(file1, m_firmwareDefinitions); if (definition != null) { DefinitionComboBox.SelectedItem = definition.Name; } DataTextBox.Text = m_patchManager.CreateDiff(file1, file2); OkButton.Enabled = true; }
private void UpdateFromFileButton_Click(object sender, EventArgs e) { string fileName; using (var op = new OpenFileDialog { Title = @"Select encrypted or decrypted firmware file ...", Filter = Consts.FirmwareFilter }) { if (op.ShowDialog() != DialogResult.OK) { return; } fileName = op.FileName; } UpdateFirmware(() => m_loader.LoadFile(fileName)); }
private void UpdateFromFileButton_Click(object sender, EventArgs e) { var fileName = m_firmwareFile; if (!m_firmwareFileExist) { using (var op = new OpenFileDialog { Title = @"Select encrypted or decrypted firmware file ...", Filter = FileFilters.FirmwareFilter }) { if (op.ShowDialog() != DialogResult.OK) { return; } fileName = op.FileName; } } if (string.IsNullOrEmpty(fileName)) { return; } UpdateFirmware(() => m_loader.LoadFile(fileName)); }