private void loadSongFromFile(string fileName) { this.CurrentSong = SongManager.LoadSong(fileName); if (this.currentSong.Patterns.Count > 0) { if (this.currentSong.PlayOrder.Count > 0) { this.currentPattern = this.currentSong.Patterns[this.currentSong.PlayOrder[0]]; } else { this.currentPattern = this.currentSong.Patterns[0]; } } this.songFileName = fileName; this.bindControls(); if (this.currentSong.Effects.Count > 0) { this.lstFX.ClearSelected(); this.lstFX.SelectedIndex = 0; } checkSawtoothExists(); this.lstInstruments.ClearSelected(); this.lstInstruments.SelectedIndex = 0; }
private Song loadSongFromResources() { Song result = null; using (MemoryStream songStream = new MemoryStream(Properties.Resources.OX)) { result = SongManager.LoadSong(songStream); } return(result); }
public static ArpeggioDefinition Load(string fileName) { Stream objFileStream; FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None); objFileStream = SongManager.GetStream(fileStream); ArpeggioDefinition result = SerializationUtils.Deserialize <ArpeggioDefinition>(objFileStream); objFileStream.Close(); objFileStream.Dispose(); return(result); }
public static Song LoadSong(Stream stream) { Song result = null; using (Stream objFileStream = SongManager.GetStream(stream)) { XmlSerializer formatter = new XmlSerializer(typeof(Song)); result = (Song)formatter.Deserialize(objFileStream); } // Fix para cargar instrumentos de archivos antiguos y que el tema no se // fastidie. foreach (Instrument instrument in result.Instruments) { if (instrument.Volumes != null && instrument.PitchModifiers == null) { instrument.SetVolumeLength(instrument.Volumes.Length); } } foreach (Effect effect in result.Effects) { if (effect.Volumes != null && effect.EnvTypes == null) { effect.SetEffectLength(effect.Volumes.Length); } } if (result.Frequencies == null || result.Frequencies.Length == 0) { result.Frequencies = NoteFileLoader.LoadDefaultNotes(); } if (result.ChipFrequency == 0) { result.ChipFrequency = (int)LibAYEmu.ChipSpeedsByMachine.MSX; } if (!result.DefaultCpcFreqs && !result.DefaultMsxFreqs && !result.CustomFreqs && !result.ParameterizedFreqs) { result.DefaultMsxFreqs = true; result.ParameterValue = result.ChipFrequency; } return(result); }
public static void Import(Song currentSong) { Instruments loadedInstruments = null; OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = WYZTracker.Core.Properties.Resources.INSFilter; if (ofd.ShowDialog() == DialogResult.OK) { XmlSerializer formatter = new XmlSerializer(typeof(Instruments)); Stream objFileStream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.None); try { loadedInstruments = (Instruments)formatter.Deserialize(objFileStream); } catch { try { formatter = new XmlSerializer(typeof(Song)); objFileStream.Seek(0, SeekOrigin.Begin); objFileStream = SongManager.GetStream(objFileStream); loadedInstruments = ((Song)formatter.Deserialize(objFileStream)).Instruments; } catch { loadedInstruments = null; } } objFileStream.Close(); } if (loadedInstruments != null) { foreach (Instrument i in loadedInstruments) { if (i.ID != "R") { i.ID = currentSong.Instruments.GetSafeId().ToString(); currentSong.Instruments.Add(i); } } } }
public static void Import(Song currentSong) { Effects loadedFX = null; OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = WYZTracker.Core.Properties.Resources.FXFilter; if (ofd.ShowDialog() == DialogResult.OK) { XmlSerializer formatter = new XmlSerializer(typeof(Effects)); Stream objFileStream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.None); try { loadedFX = (Effects)formatter.Deserialize(objFileStream); } catch { try { formatter = new XmlSerializer(typeof(Song)); objFileStream.Seek(0, SeekOrigin.Begin); objFileStream = SongManager.GetStream(objFileStream); loadedFX = ((Song)formatter.Deserialize(objFileStream)).Effects; } catch { loadedFX = null; } } objFileStream.Close(); } if (loadedFX != null) { foreach (Effect fx in loadedFX) { fx.ID = currentSong.Effects.GetSafeId(); currentSong.Effects.Add(fx); } } }
private void saveSong(string fileName) { SongManager.SaveSong(this.currentSong, fileName); this.songFileName = fileName; setFocusToEditor(); }
private void cmdOk_Click(object sender, EventArgs e) { string selectedLanguage = cboIdioma.SelectedItem as string; bool continueWithOk = true; bool languageChanged = selectedLanguage != LocalizationManager.GetCurrentCultureName(); if (languageChanged) { System.Windows.Forms.DialogResult result = MessageBox.Show( Properties.Resources.RestartMessage, Properties.Resources.Warning, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); switch (result) { case System.Windows.Forms.DialogResult.Yes: if (string.IsNullOrEmpty(ApplicationState.Instance.FileName)) { this.sfd.Filter = WYZTracker.Properties.Resources.WYZFilter; if (this.sfd.ShowDialog() == DialogResult.OK) { SongManager.SaveSong(ApplicationState.Instance.CurrentSong, this.sfd.FileName); } } else { SongManager.SaveSong(ApplicationState.Instance.CurrentSong, ApplicationState.Instance.FileName); } break; case System.Windows.Forms.DialogResult.Cancel: continueWithOk = false; break; } } if (continueWithOk) { Properties.Settings.Default.CheckFileAssociation = chkCheckFileAssociation.Checked; Properties.Settings.Default.ShowSplash = chkSplash.Checked; Properties.Settings.Default.UseCustomFont = chkDigitalFont.Checked; Properties.Settings.Default.Language = selectedLanguage; Properties.Settings.Default.ColumnWidth = (int)numColWidth.Value; Properties.Settings.Default.FontSize = (int)numFontSize.Value; Properties.Settings.Default.KeyboardLayout = cboKeyboardLayout.SelectedItem as string; //Properties.Settings.Default.SoundBufSize = (int)numBufSize.Value; Properties.Settings.Default.Save(); LocalizationManager.LocalizeApplication(Properties.Settings.Default.Language); VirtualPiano.InitPianoKeys(); //Player.BufferLengthInMs = Properties.Settings.Default.SoundBufSize; if (languageChanged) { Program.Restart(ApplicationState.Instance.FileName); } } this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }