private void ROMOpenButton_Click(object sender, RoutedEventArgs e) { OpenFileDialog od = new OpenFileDialog { Multiselect = false, Title = Utils.GetResource("ROMOpen"), Filter = Utils.GetNDSFilter(), }; if (od.ShowDialog() == System.Windows.Forms.DialogResult.OK) { LoadedROM = ROMUtils.LoadROM(od.FileName); if (LoadedROM == null) { ShowNotification("The selected file is not a valid Nintendo DS ROM."); return; } if (!LoadedROM.IsMKDS()) { ShowNotification("The selected file is not a valid Mario Kart DS ROM."); LoadedROM = null; return; } Title = Utils.GetResource("program") + " - " + Path.GetFileName(od.FileName); ShowNotification("MKDS ROM loaded: " + Path.GetFileName(od.FileName)); ROMPath = od.FileName; AssetsCard.IsEnabled = true; KartsCard.IsEnabled = true; TexturesCard.IsEnabled = true; SoundCard.IsEnabled = true; TextsCard.IsEnabled = true; } }
protected override void OnClosing(CancelEventArgs e) { if (LoadedROM != null) { if (assets != null) { assets.Close(); if (assets.IsVisible) { e.Cancel = true; return; } } if (sound != null) { sound.Close(); if (sound.IsVisible) { e.Cancel = true; return; } } if (texts != null) { texts.Close(); if (texts.IsVisible) { e.Cancel = true; return; } } var res = System.Windows.MessageBox.Show("Would you like to save the edited changes?", "Edited changes", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning); if (res == MessageBoxResult.Cancel) { e.Cancel = true; return; } if (res == MessageBoxResult.Yes) { var data = LoadedROM.Write(); SaveFileDialog sf = new SaveFileDialog { Filter = Utils.GetNDSFilter(), Title = Utils.GetResource("ROMSave"), }; if (sf.ShowDialog() == System.Windows.Forms.DialogResult.OK) { File.WriteAllBytes(sf.FileName, data); } } } base.OnClosing(e); }
private void SoundButton_Click(object sender, RoutedEventArgs e) { if (sound == null) { sound = new SoundWindow { Owner = this }; sound.Closing += new CancelEventHandler((object s, CancelEventArgs e2) => { Focus(); sound = null; }); sound.Load(new SDAT(ROMUtils.GetFile("sound_data.sdat", LoadedROM.ToFileSystem()))); sound.Show(); } else { sound.Focus(); } }