private void LoadPatchToPoke() { try { using (var reader = new EndianReader(File.OpenRead(txtPokePatchFile.Text), Endian.LittleEndian)) { string magic = reader.ReadAscii(4); reader.SeekTo(0); if (magic == "asmp") { // Load into UI reader.Endianness = Endian.BigEndian; currentPatchToPoke = AssemblyPatchLoader.LoadPatch(reader); txtPokePatchAuthor.Text = currentPatchToPoke.Author; txtPokePatchDesc.Text = currentPatchToPoke.Description; txtPokePatchName.Text = currentPatchToPoke.Name; txtPokePatchInternalName.Text = currentPatchToPoke.MapInternalName; //txtPokePatchMapID.Text = currentPatchToPoke.MapID.ToString(CultureInfo.InvariantCulture); // Set Visibility PokePatchControls.Visibility = Visibility.Visible; } else { MetroMessageBox.Show("You can't poke a patch from Alteration/Ascension. Convert it to a Assembly Patch first"); return; } } // Set Screenshot if (currentPatchToPoke.Screenshot == null) { // Set default var source = new Uri(@"/Assembly;component/Metro/Images/super_patcher.png", UriKind.Relative); imgPokePreview.Source = new BitmapImage(source); } else { var image = new BitmapImage(); image.BeginInit(); image.StreamSource = new MemoryStream(currentPatchToPoke.Screenshot); image.EndInit(); imgPokePreview.Source = image; } } catch (Exception ex) { MetroException.Show(ex); } }
public static Form1 form1; // this is set on form load private static Patch LoadPatch(string patchFilePath) { using (var reader = new EndianReader(File.OpenRead(patchFilePath), Endian.LittleEndian)) { string magic = reader.ReadAscii(4); reader.SeekTo(0); if (magic != "asmp") { return(null); } reader.Endianness = Endian.BigEndian; return(AssemblyPatchLoader.LoadPatch(reader)); } }
// Meta Sorting private void LoadPatch(bool isAlteration) { try { using (var reader = new EndianReader(File.OpenRead(txtApplyPatchFile.Text), Endian.LittleEndian)) { string magic = reader.ReadAscii(4); reader.SeekTo(0); if (magic == "asmp") { // Load into UI reader.Endianness = Endian.BigEndian; currentPatch = AssemblyPatchLoader.LoadPatch(reader); txtApplyPatchAuthor.Text = currentPatch.Author; txtApplyPatchDesc.Text = currentPatch.Description; txtApplyPatchName.Text = currentPatch.Name; txtApplyPatchInternalName.Text = currentPatch.MapInternalName; //txtApplyPatchMapID.Text = currentPatch.MapID.ToString(CultureInfo.InvariantCulture); // Set Visibility PatchApplicationPatchExtra.Visibility = currentPatch.CustomBlfContent != null ? Visibility.Visible : Visibility.Collapsed; ApplyPatchControls.Visibility = Visibility.Visible; btnExtractInfo.IsEnabled = true; } else { currentPatch = OldPatchLoader.LoadPatch(reader, isAlteration); txtApplyPatchAuthor.Text = currentPatch.Author; txtApplyPatchDesc.Text = currentPatch.Description; txtApplyPatchName.Text = "Ascension/Alteration Patch"; txtApplyPatchInternalName.Text = "Ascension/Alteration Patch"; ApplyPatchControls.Visibility = Visibility.Visible; PatchApplicationPatchExtra.Visibility = Visibility.Collapsed; btnExtractInfo.IsEnabled = false; } if (currentPatch.OutputName != null) { cacheOutputName = currentPatch.OutputName; } } // Set Screenshot if (currentPatch.Screenshot == null) { // Set default var source = new Uri(@"/Assembly;component/Metro/Images/super_patcher.png", UriKind.Relative); imgApplyPreview.Source = new BitmapImage(source); } else { var image = new BitmapImage(); image.BeginInit(); image.StreamSource = new MemoryStream(currentPatch.Screenshot); image.EndInit(); imgApplyPreview.Source = image; } } catch (Exception ex) { MetroException.Show(ex); } }