Example #1
0
        private void keyPressBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            SoundSystem.SoundMode selectedMode;

            switch (keyPressBox.SelectedIndex)
            {
            case 0:
                selectedMode = SoundSystem.SoundMode.Stack;
                break;

            case 1:
                selectedMode = SoundSystem.SoundMode.Interrupt;
                break;

            case 2:
                selectedMode = SoundSystem.SoundMode.StartStop;
                break;

            case 3:
                selectedMode = SoundSystem.SoundMode.Loop;
                break;

            default:
                selectedMode = SoundSystem.SoundMode.Interrupt;
                break;
            }

            if (Config.CurrentConfig.InputMode != selectedMode)
            {
                SoundSystem.KillAllSounds();
                Config.CurrentConfig.InputMode = selectedMode;
            }
        }
Example #2
0
 private void playbackCheckBox_CheckedChanged(object sender, EventArgs e)
 {
     if (Config.CurrentConfig.SoundPlaybackEnabled != playbackCheckBox.Checked)
     {
         SoundSystem.KillAllSounds();
         Config.CurrentConfig.SoundPlaybackEnabled = playbackCheckBox.Checked;
     }
 }
Example #3
0
        //EventHandler for choosing a device in DeviceBox
        private void SetOutputDeviceNumber(object o, EventArgs e)
        {
            ComboBox cb = (ComboBox)o;

            if (Config.CurrentConfig.CurrentOutputDevice != cb.SelectedIndex)
            {
                Config.CurrentConfig.CurrentOutputDevice = cb.SelectedIndex;
                SoundSystem.resetListener();
                SoundSystem.KillAllSounds();
            }
        }
Example #4
0
        public static void MoveHome(string newHome)
        {
            newHome = newHome + "\\";

            if (!newHome.Contains("SoundMachine"))
            {
                newHome = newHome + "SoundMachine\\";
            }

            SoundSystem.KillAllSounds();
            Microsoft.VisualBasic.FileIO.FileSystem.CopyDirectory(Config.WorkingDir, newHome, true);
            Config.WorkingDir = newHome;

            RegistryKey WorkingDirectory = Registry.CurrentUser.CreateSubKey("SoundMachine");

            WorkingDirectory.SetValue("WorkingDirectory", newHome);
        }
Example #5
0
        public void ToggleSystemEnabled(Button btn)
        {
            if (btn == null)
            {
                btn = (Button)Controls.Find("btnToggleSystem", false).First();
            }

            KeyListener._listenerEnabled = !KeyListener._listenerEnabled;
            btn.Text      = KeyListener._listenerEnabled == true ? "Sound Enabled" : "Sound Muted";
            btn.BackColor = KeyListener._listenerEnabled == true ? Color.Green : Color.PaleVioletRed;
            if (KeyListener._listenerEnabled == false)
            {
                SoundSystem.KillAllSounds();
                if (Config.CurrentConfig.MuteInputWithSoundSystem)
                {
                    SoundSystem.InputDisabled = true;
                }
            }
            else
            {
                SoundSystem.InputDisabled = false;
            }
            //ToggleInputDevices(_systemEnabled);
        }
Example #6
0
        public static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            int vkCode = Marshal.ReadInt32(lParam);

            if (!_listenerEnabled && !changeBinding && vkCode != Config.CurrentConfig.ToggleSystemBinding)
            {
                return(CallNextHookEx(_hookID, nCode, wParam, lParam));
            }

            if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN)
            {
                if (changeBinding)
                {
                    if (SetBindingForm._currentForm.BindingType == KeyBinding.ToggleOverlay)
                    {
                        Config.CurrentConfig.ToggleOverlayBinding = vkCode;
                    }
                    else if (SetBindingForm._currentForm.BindingType == KeyBinding.ToggleProfile)
                    {
                        Config.CurrentConfig.ToggleProfileBinding = vkCode;
                    }
                    else if (SetBindingForm._currentForm.BindingType == KeyBinding.ToggleSystem)
                    {
                        Config.CurrentConfig.ToggleSystemBinding = vkCode;
                    }
                    else if (SetBindingForm._currentForm.BindingType == KeyBinding.ToggleMode)
                    {
                        Config.CurrentConfig.ToggleModeBinding = vkCode;
                    }
                    else if (SetBindingForm._currentForm.BindingType == KeyBinding.Record)
                    {
                        Config.CurrentConfig.RecordBinding = vkCode;
                    }
                    else
                    {
                        for (int i = 0; i < SoundProfile.CurrentSoundProfile.Bindings.Length; i++)
                        {
                            int tempCode = SoundProfile.CurrentSoundProfile.Bindings[i];
                            if (tempCode == vkCode && SetBindingForm._currentForm.CurrentButton != i)
                            {
                                SoundProfile.CurrentSoundProfile.Bindings[i] = 0;
                                SetBindingForm._currentForm.RemovedBinding   = i;
                                break;
                            }
                            SoundProfile.CurrentSoundProfile.Bindings[SetBindingForm._currentForm.CurrentButton] = vkCode;
                            SoundProfile.CurrentSoundProfile.SaveSoundProfile();
                        }
                    } //Set new binding
                    SetBindingForm._currentForm.NewBindingSet = true;
                    SetBindingForm._currentForm.Close();
                    return((System.IntPtr) 1);
                }
                else
                {
                    if (vkCode == Config.CurrentConfig.ToggleOverlayBinding)
                    {
                        if (Overlay._currentOverlay.Visible)
                        {
                            Overlay._currentOverlay.Hide();
                        }
                        else
                        {
                            Overlay._currentOverlay.Show();
                        }
                        return((System.IntPtr) 1);
                    }
                    else if (vkCode == Config.CurrentConfig.ToggleProfileBinding)
                    {
                        SoundProfile.Next();
                        return((System.IntPtr) 1);
                    }
                    else if (vkCode == Config.CurrentConfig.ToggleSystemBinding)
                    {
                        MainForm._currentForm.ToggleSystemEnabled(null);
                        Overlay._currentOverlay.UpdateStatusColor();
                        return((System.IntPtr) 1);
                    }
                    else if (vkCode == Config.CurrentConfig.ToggleModeBinding)
                    {
                        SoundSystem.KillAllSounds();
                        SoundSystem.SwitchSoundMode();
                        if (SettingsForm._currentForm != null)
                        {
                            SettingsForm._currentForm.SetKeyPressBoxSelectedIndex();
                        }
                        return((System.IntPtr) 1);
                    }
                    else if (vkCode == Config.CurrentConfig.RecordBinding) //Control button on keyboard
                    {
                        isRecording = true;                                //Enables recording
                    }
                    else if (!isRecording)
                    {
                        if (SoundSystem.PlaySound(Utilities.ConvertKeyCodeToButtonId(vkCode)))
                        {
                            if (Config.CurrentConfig.InterruptKeys)
                            {
                                return((System.IntPtr) 1);
                            }
                        }
                    }
                    else
                    {
                        if (SoundSystem.RecordSound(Utilities.ConvertKeyCodeToButtonId(vkCode)))
                        {
                            if (Config.CurrentConfig.InterruptKeys)
                            {
                                return((System.IntPtr) 1);
                            }
                        }
                    }
                }
            }
            else if (nCode >= 0 && wParam == (IntPtr)WM_KEYUP)
            {
                if (vkCode == Config.CurrentConfig.RecordBinding) //Control button on keyboard
                {
                    isRecording = false;
                    SoundSystem.StopRecording(); //if ctrl is released stop all recording
                }
            }

            return(CallNextHookEx(_hookID, nCode, wParam, lParam));
        }