Beispiel #1
0
        public MainForm()
        {
            InitializeComponent();

            var tooltip = new ToolTip();

            tooltip.SetToolTip(btnReloadDevices, "Refresh sound devices");
            tooltip.SetToolTip(btnReloadWindows, "Reload windows");

            loadSoundDevices();
            loadWindows();

            XMLSettings.LoadSoundboardSettingsXML();

            if (cbPlaybackDevices.Items.Contains(XMLSettings.soundboardSettings.LastPlaybackDevice))
            {
                cbPlaybackDevices.SelectedItem = XMLSettings.soundboardSettings.LastPlaybackDevice;
            }

            if (cbLoopbackDevices.Items.Contains(XMLSettings.soundboardSettings.LastLoopbackDevice))
            {
                cbLoopbackDevices.SelectedItem = XMLSettings.soundboardSettings.LastLoopbackDevice;
            }

            //add events after settings have been loaded
            cbPlaybackDevices.SelectedIndexChanged += cbPlaybackDevices_SelectedIndexChanged;
            cbLoopbackDevices.SelectedIndexChanged += cbLoopbackDevices_SelectedIndexChanged;
        }
Beispiel #2
0
        public MainForm()
        {
            InitializeComponent();

            var tooltip = new ToolTip();

            tooltip.SetToolTip(btnReloadDevices, "Refresh sound devices");
            tooltip.SetToolTip(btnReloadWindows, "Reload windows");
            tooltip.SetToolTip(cbPlaybackDevices1, PLAYBACK1_TOOLTIP);
            tooltip.SetToolTip(cbPlaybackDevices2, PLAYBACK2_TOOLTIP);
            tooltip.SetToolTip(cbLoopbackDevices, LOOPBACK_TOOLTIP);
            tooltip.SetToolTip(lblPlayback1, PLAYBACK1_TOOLTIP);
            tooltip.SetToolTip(lblPlayback2, PLAYBACK2_TOOLTIP);
            tooltip.SetToolTip(lblLoopback, LOOPBACK_TOOLTIP);
            tooltip.SetToolTip(vsSoundVolume, SOUND_VOLUME_TOOLTIP);
            tooltip.SetToolTip(nSoundVolume, SOUND_VOLUME_TOOLTIP);

            XMLSettings.LoadSoundboardSettingsXML();

            //Disable change events for elements that would trigger settings changes and unnecessarily write to settings.xml
            DisableCheckboxChangeEvents();
            DisableSoundVolumeChangeEvents();

            loadSoundDevices(false); //false argument keeps device change events disabled

            Helper.getWindows(cbWindows);
            Helper.selectWindow(cbWindows, XMLSettings.soundboardSettings.AutoPushToTalkWindow);

            if (XMLSettings.soundboardSettings.StartMinimised)
            {
                this.WindowState = FormWindowState.Minimized;

                if (XMLSettings.soundboardSettings.MinimiseToTray)
                {
                    this.HideFormToTray();
                }
            }

            Helper.setStartup(XMLSettings.soundboardSettings.StartWithWindows);

            cbEnableHotkeys.Checked  = XMLSettings.soundboardSettings.EnableHotkeys;
            cbEnableLoopback.Checked = XMLSettings.soundboardSettings.EnableLoopback;

            soundVolume          = XMLSettings.soundboardSettings.SoundVolume;
            vsSoundVolume.Volume = soundVolume;
            nSoundVolume.Value   = Helper.linearVolumeToInteger(vsSoundVolume.Volume); //needed because change events are still disabled

            pushToTalkKey = XMLSettings.soundboardSettings.AutoPushToTalkKey;

            tbPushToTalkKey.Text = pushToTalkKey.ToString() == "None" ? "" : pushToTalkKey.ToString();

            cbEnablePushToTalk.Checked = XMLSettings.soundboardSettings.EnableAutoPushToTalk;
            tbPushToTalkKey.Enabled    = !cbEnablePushToTalk.Checked;
            clearHotkey.Enabled        = !cbEnablePushToTalk.Checked;

            if (File.Exists(XMLSettings.soundboardSettings.LastXMLFile))
            {
                //loadXMLFile() returns true if error occurred
                if (loadXMLFile(XMLSettings.soundboardSettings.LastXMLFile))
                {
                    XMLSettings.soundboardSettings.LastXMLFile = "";
                    XMLSettings.SaveSoundboardSettingsXML();
                }
            }

            //Add events after settings have been loaded
            EnableCheckboxChangeEvents();
            EnableSoundVolumeChangeEvents();
            EnableDeviceChangeEvents();

            mainTimer.Enabled = cbEnableHotkeys.Checked;
            initAudioPlaybackEngine1();
            initAudioPlaybackEngine2();
            restartLoopback();

            //When sound stops, fire event which lets go of push-to-talk key.
            playbackEngine1.AllInputEnded += OnAllInputEnded;
            //Don't need to stop holding the push-to-talk key when engine2 stops playing, that's just our in-ear echo.
        }