public SoundProfile(SoundProfile blueprint) { _profileName = blueprint.ProfileName; Sounds = blueprint.Sounds ?? new string[Config.CurrentConfig.MaxSounds]; Texts = blueprint.Texts ?? new string[Config.CurrentConfig.MaxSounds]; if (blueprint.Bindings == null) { Bindings = new int[Config.CurrentConfig.MaxSounds]; AddDefaultBindings(); } else { Bindings = blueprint.Bindings; } if (Config.CurrentConfig.MaxSounds > Sounds.Length) { string[] tempSoundsArray = new string[Config.CurrentConfig.MaxSounds]; string[] tempTextsArray = new string[Config.CurrentConfig.MaxSounds]; int[] tempBindingsArray = new int[Config.CurrentConfig.MaxSounds]; for (int i = 0; i < Sounds.Length; i++) { tempSoundsArray[i] = Sounds[i]; tempTextsArray[i] = Texts[i]; tempBindingsArray[i] = Bindings[i]; } Sounds = tempSoundsArray; Texts = tempTextsArray; Bindings = tempBindingsArray; } _currentSoundProfile = this; }
public SoundProfile(string profileName) { _profileName = profileName; Sounds = new string[Config.CurrentConfig.MaxSounds]; Texts = new string[Config.CurrentConfig.MaxSounds]; Bindings = new int[Config.CurrentConfig.MaxSounds]; AddDefaultBindings(); _currentSoundProfile = this; SaveSoundProfile(); }
public void RenderCanvas() { SoundProfile.LoadSoundProfile(Config.CurrentConfig.Profiles[Config.CurrentConfig.CurrentProfile]); _MAXBUTTONS = Config.CurrentConfig.MaxSounds; _MAXCOLUMNS = 5; _MAXROWS = (int)Math.Ceiling((double)_MAXBUTTONS / _MAXCOLUMNS); _SCREENHEIGHT = (_MAXROWS * (_BUTTONSIZE.Height + _MARGIN)) + _MARGIN * 2; _SCREENWIDTH = (_MAXCOLUMNS * (_BUTTONSIZE.Width + _MARGIN)) + _MARGIN + 20; Size = new Size(_SCREENWIDTH, _SCREENHEIGHT); Controls.Clear(); btnList.Clear(); CreateControls(); CreateButtons(); }
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)); }