/// <summary> /// Import the specified Zip file into the SoundManager sound scheme /// </summary> /// <param name="zipfile">Input Zip file</param> public static void Import(string zipfile) { using (ZipFile zip = ZipFile.Read(zipfile)) { foreach (SoundEvent soundEvent in SoundEvent.GetAll()) { if (TryExtract(zip, soundEvent.FileName, SoundEvent.DataDirectory) || TryExtract(zip, soundEvent.LegacyFileName, SoundEvent.DataDirectory, soundEvent.FileName)) { SoundScheme.Update(soundEvent, soundEvent.FilePath); } else { SoundScheme.Remove(soundEvent); } } SchemeMeta.ResetAll(); if (!TryExtract(zip, Path.GetFileName(SchemeMeta.SchemeImageFilePath), SoundEvent.DataDirectory)) { TryExtract(zip, "visuel.bmp", SoundEvent.DataDirectory, Path.GetFileName(SchemeMeta.SchemeImageFilePath)); } if (!TryExtract(zip, Path.GetFileName(SchemeMeta.SchemeInfoFilePath), SoundEvent.DataDirectory)) { TryExtract(zip, "infos.ini", SoundEvent.DataDirectory, Path.GetFileName(SchemeMeta.SchemeInfoFilePath)); } SchemeMeta.ReloadFromDisk(); SoundScheme.Apply(SoundScheme.GetSchemeSoundManager(), Settings.MissingSoundUseDefault); } }
/// <summary> /// Replace the sound file associated with the specified sound event /// </summary> private void replaceSoundEvent(SoundEvent soundEvent, string soundFile) { try { SoundScheme.Update(soundEvent, soundFile); soundContextMenu_Play_Click(this, EventArgs.Empty); SoundScheme.Apply(SoundScheme.GetSchemeSoundManager(), Settings.MissingSoundUseDefault); } catch (Exception loadException) { MessageBox.Show( Translations.Get("sound_load_failed_text") + '\n' + loadException.Message, Translations.Get("sound_load_failed_title"), MessageBoxButtons.OK, MessageBoxIcon.Error ); } }