예제 #1
0
        /// <summary>
        /// Setup will create and apply the SoundManager sound scheme, create data directory
        /// </summary>
        /// <param name="forceResetSounds">Also reset all sounds to their default values</param>
        /// <param name="systemIntegration">Also setup maximum system integration</param>
        public static void Setup(bool forceResetSounds, bool systemIntegration)
        {
            bool createDataDir = !Directory.Exists(DataFolder);

            if (createDataDir)
            {
                Directory.CreateDirectory(DataFolder);
            }

            SoundScheme.Setup();

            if (forceResetSounds || createDataDir)
            {
                foreach (SoundEvent soundEvent in SoundEvent.GetAll())
                {
                    SoundScheme.CopyDefault(soundEvent);
                }
            }

            SoundScheme.Apply(SoundScheme.GetSchemeSoundManager(), true);

            if (systemIntegration)
            {
                SoundArchive.AssocFiles();
                if (BgSoundPlayer.RequiredForThisWindowsVersion)
                {
                    BgSoundPlayer.RegisteredForStartup = true;
                    Process.Start(Application.ExecutablePath, ArgumentBgSoundPlayer);
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Change the File Association setting
 /// </summary>
 private void checkBoxFileAssoc_CheckedChanged(object sender, EventArgs e)
 {
     if (checkBoxFileAssoc.Checked)
     {
         SoundArchive.AssocFiles();
     }
     else
     {
         SoundArchive.UnAssocFiles();
     }
 }
예제 #3
0
 /// <summary>
 /// Import the specified sound archive file
 /// </summary>
 /// <param name="schemePath"></param>
 private void ImportSoundScheme(string schemePath)
 {
     try
     {
         SoundArchive.Import(schemePath);
         RefreshSchemeMetadata();
         soundList.Select();
         soundContextMenu_Play_Click(this, EventArgs.Empty);
     }
     catch (Exception importException)
     {
         MessageBox.Show(
             Translations.Get("scheme_load_failed_text") + '\n' + importException.Message,
             Translations.Get("scheme_load_failed_title"),
             MessageBoxButtons.OK,
             MessageBoxIcon.Error
             );
     }
 }
예제 #4
0
        /// <summary>
        /// Export to a sound archive file
        /// </summary>
        private void buttonExport_Click(object sender, EventArgs e)
        {
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Filter = String.Concat(Translations.Get("browse_scheme_files"), "|*.", SoundArchive.FileExtension);
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    SoundArchive.Export(dlg.FileName);
                }
                catch (Exception exportException)
                {
                    MessageBox.Show(
                        Translations.Get("scheme_export_failed_text") + '\n' + exportException.Message,
                        Translations.Get("scheme_export_failed_title"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error
                        );
                }
            }
        }
예제 #5
0
 /// <summary>
 /// Uninstall will remove application data from the user directory, sound scheme from the registry, and disable all system integration
 /// </summary>
 /// <returns></returns>
 public static void Uninstall()
 {
     if (BgSoundPlayer.RegisteredForStartup)
     {
         BgSoundPlayer.RegisteredForStartup = false;
         foreach (Process process in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Application.ExecutablePath)))
         {
             if (process.Id != Process.GetCurrentProcess().Id)
             {
                 process.Kill();
             }
         }
     }
     SoundArchive.UnAssocFiles();
     SoundScheme.Uninstall();
     if (Directory.Exists(SoundEvent.DataDirectory))
     {
         Directory.Delete(SoundEvent.DataDirectory, true);
     }
     if (Directory.Exists(DataFolder))
     {
         Directory.Delete(DataFolder, true);
     }
 }