private void Application_Startup(object sender, StartupEventArgs e) { this.RootVisual = new MainPage(); try { HtmlElement feat_list = HtmlPage.Document.GetElementById("feat_list"); if (feat_list != null) { feat_list.SetProperty("innerHTML", PatchControl.BuildPatchMatrix()); } } catch (Exception) { }; }
private void ExportCFile_Click(object sender, EventArgs e) { // Create an instance of the open file dialog box. SaveFileDialog ofd = new SaveFileDialog(); ofd.Title = "Select the file to write the C patch code into.."; // Set filter options and filter index. ofd.Filter = "Binary Files (.c)|*.c|All Files (*.*)|*.*"; ofd.FilterIndex = 1; // Call the ShowDialog method to show the dialog box. var userClickedOK = ofd.ShowDialog(); if (userClickedOK == DialogResult.OK) { PatchControl.ExportToC(ofd.FileName); } }
private void PatchFileButton_Click(object sender, EventArgs e) { // Create an instance of the open file dialog box. OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Title = "Select Nikon firmware .bin file to patch"; // Set filter options and filter index. openFileDialog1.Filter = "Binary Files (.bin)|*.bin|All Files (*.*)|*.*"; openFileDialog1.FilterIndex = 1; openFileDialog1.Multiselect = false; // Call the ShowDialog method to show the dialog box. var userClickedOK = openFileDialog1.ShowDialog(); // Process input if the user clicked OK. if (userClickedOK == DialogResult.OK) { //SendEvent("TryFile", openFileDialog1.File.Name); var ext = Path.GetExtension(openFileDialog1.FileName).ToLower(); if (ext == ".dmg") { MessageBox.Show("Please open the DMG file and select the .BIN file inside"); return; } if (ext == ".exe") { MessageBox.Show("Please open the .EXE file and select the .BIN file inside"); return; } if (ext != ".bin") { MessageBox.Show("The files to be a Nikon Firmware .BIN file"); return; } Clear(); // Open the selected file to read. System.IO.Stream fileStream = File.OpenRead(openFileDialog1.FileName); //SendEvent("OpenFile", openFileDialog1.File.Name); if (fileStream.Length > (48 * 1024 * 1024)) { fileStream.Close(); return; } byte[] data = new byte[fileStream.Length]; if (data == null) { fileStream.Close(); return; } fileStream.Read(data, 0, (int)fileStream.Length); fileStream.Close(); // Test in valid firm = PatchControl.FirmwareMatch(data, PatchLevel.DevOnly); if (firm != null) { tFirmwareName.Text = firm.Model; tFirmwareVersion.Text = firm.Version; firm.ModelVersion = $"{firm.Model}_{firm.Version}"; if (firm.Patches.Count == 0) { tFeature.Text = "No Patches presently exist for this 'Model/Firmware Version'"; } else { var text = firm.TestPatch(); if (text == "") { lstFeatures.DataSource = firm.Patches; lstFeatures.DisplayMember = "DispalyString"; PatchSet.SetListBox(lstFeatures); tFeature.Text = ""; } else { // hash matched, but patches did not match tFeature.Text = "A sub-patch failed to map to this 'Model/Firmware Version' - Please Report " + text; } } foreach (var p in firm.Patches) { p.PropertyChanged += PatchSetChanged; } } else { tFeature.Text = "No matching 'Model/Firmware Versions' were found"; } } }