Exemplo n.º 1
0
        /// <summary>
        /// Registers all of the hotkeys declared at the beginning of the class automatically on startup
        /// Loads the config file and assigns keys with existing audio
        /// </summary>
        /// <param name="sender">Object sender</param>
        /// <param name="e">Event args</param>
        private void Form1_Load(object sender, EventArgs e)
        {
            // register the keys on load
            for (int i = 1; i <= 9; i++)
            {
                _console.WriteLine("Trying to register CTRL+ALT+" + i);
                if (Hotkeys[i].Register())
                {
                    _console.WriteLine("Hotkey registered.");
                }
                else
                {
                    _console.WriteLine("Hotkey failed to register :(");
                }
            }

            // load the config file and assign any keys with existing audio
        }
Exemplo n.º 2
0
        /// <summary>
        /// Check if the appropriate audio devices are installed, enabled, and set up for use
        /// </summary>
        public static void CheckSetupAudio()
        {
            // check if the VAC is installed
            bool virtualAudioInstalled = CheckInstalled();

            try
            {
                // install it if not
                if (!virtualAudioInstalled)
                {
                    var result = MessageBox.Show(@"A virtual audio cable must be installed to continue. Please follow the prompts on the following screens.", @"Install Virtual Audio", MessageBoxButtons.OKCancel);
                    _console.WriteLine("VAC not installed, promting for installation.");
                    if (result == DialogResult.OK)
                    {
                        // create a process to launch the installer based on the operating system type
                        _console.WriteLine("Launching VAC installer");
                        ProcessStartInfo start = new ProcessStartInfo
                        {
                            FileName = Path.Combine(Environment.CurrentDirectory, Environment.Is64BitOperatingSystem ?
                                                    @"../../Resources/VBCABLE_Driver_Pack43/VBCABLE_Setup_x64.exe" :
                                                    @"../../Resources/VBCABLE_Driver_Pack43/VBCABLE_Setup.exe"),
                            Verb = "runas"
                        };
                        int exitCode;

                        // launch the external installer, pausing the soundboard app until the installer exits
                        using (Process proc = Process.Start(start))
                        {
                            proc.WaitForExit();
                            exitCode = proc.ExitCode;
                        }

                        // double check installation was sucessfull
                        virtualAudioInstalled = CheckInstalled();

                        // failure
                        if (!virtualAudioInstalled)
                        {
                            throw new Exception();
                        }
                    }
                    else
                    {
                        MessageBox.Show(@"The virtual audio cable must be installed, the Soundboard cannot continue.");
                        _console.WriteLine("User aborted installation of VAC, exiting.");
                        Application.Exit();
                    }
                }
            }
            catch (Exception e)
            {
                _console.WriteLine("VAC installer failed with exception: \n\n" + e.Message);
                MessageBox.Show(@"The virtual audio cable installation appears to have failed and the Soundboard cannot continue. If you are receiving this message in error, try rebooting your machine before launching the Soundboard again. Or, try manually installing the virtual audio cable from http://bit.ly/1puZds5", @"Error", MessageBoxButtons.OK);
                Environment.Exit(1);
            }

            // if we get to this point, the VAC is installed or a previous installtion was found
            _console.WriteLine("VAC installation found, continuing with audio device setup");


            // set up audio devices
            SetupAudioDevices();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Determines if there is audio to be played, and plays it through the speakers/headphones and microphone
 /// </summary>
 /// <param name="_keyId">A number 1 - 9 denoting which key was pressed</param>
 public void PlayAudio(int keyId)
 {
     if (HasAudio())
     {
         // play the audio locally, maybe using System.Media.SoundPlayer
         // pipe the audio into the microphone
         System.Media.SoundPlayer player = new System.Media.SoundPlayer();
         player.SoundLocation = audioPath;
         player.Load();
         player.Play();
         _console.WriteLine("Audio played locally");
     }
     else
     {
         _console.WriteLine("Hotkey " + keyId + " has no audio assigned.");
         assignAudio(keyId);
         // get an audio file using OpenFileDialog
         // copy audio file to AppData
         // assign new path to this.audioPath
         // add this new mapping to a config file
         // rename the appropriate label to the audio file name
     }
 }