Example #1
0
        private void OnGlobalKeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (!loaded || keybindReaderMidi.IsReading)
            {
                return;
            }
            bool isActive = IsActive;
            var  focus    = FocusManager.GetFocusedElement(this);

            if (focus is TextBox || focus is IntSpinner)
            {
                return;
            }
            foreach (Window window in OwnedWindows)
            {
                focus = FocusManager.GetFocusedElement(window);
                if (focus is TextBox || focus is IntSpinner)
                {
                    return;
                }
                if (window.IsActive)
                {
                    isActive = true;
                }
            }

            if (e.KeyCode == Keys.Enter && TerrariaWindowLocator.CheckIfFocused() && Config.DisableMountWhenTalking)
            {
                talking = !talking;
                checkBoxTalking.IsChecked = talking;
            }

            if (Config.HasMidi)
            {
                if (Config.Keybinds.Play.IsDown(e) && (Config.PlaybackNoFocus || isActive || TerrariaWindowLocator.CheckIfFocused()))
                {
                    if (server != null)
                    {
                        HostStartPlay();
                    }
                    else
                    {
                        Play();
                    }
                }
                else if (Config.Keybinds.Pause.IsDown(e) && (Config.PlaybackNoFocus || isActive || TerrariaWindowLocator.CheckIfFocused()))
                {
                    if (server != null)
                    {
                        HostStop();
                    }
                    else
                    {
                        Pause();
                    }
                }
                else if (Config.Keybinds.Stop.IsDown(e))
                {
                    if (server != null)
                    {
                        HostStop();
                    }
                    else
                    {
                        Stop();
                    }
                }
            }
            if (Config.Keybinds.Mount.IsDown(e) && TerrariaWindowLocator.CheckIfFocused() && !talking)
            {
                mounted = !mounted;
                checkBoxMounted.IsChecked = mounted;
            }
            for (int i = 0; i < Config.Midis.Count; i++)
            {
                if (Config.MidiIndex != i && Config.Midis[i].Keybind.IsDown(e) && (Config.PlaybackNoFocus || isActive || TerrariaWindowLocator.CheckIfFocused()))
                {
                    Stop();

                    loaded                  = false;
                    Config.MidiIndex        = i;
                    listMidis.SelectedIndex = i;
                    loaded                  = true;
                    UpdateMidi();
                }
            }
            if (Config.Keybinds.Close.IsDown(e) && (Config.CloseNoFocus || isActive || TerrariaWindowLocator.CheckIfFocused()))
            {
                Close();
            }
        }
Example #2
0
        private void OnGlobalKeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (!loaded || keybindReaderMidi.IsReading)
            {
                return;
            }

            if (Config.HasMidi)
            {
                if (Config.Keybinds.Play.IsDown(e) && (Config.PlaybackNoFocus || IsActive || TerrariaWindowLocator.CheckIfFocused()))
                {
                    if (server != null)
                    {
                        HostStartPlay();
                    }
                    else
                    {
                        Play();
                    }
                }
                else if (Config.Keybinds.Pause.IsDown(e) && (Config.PlaybackNoFocus || IsActive || TerrariaWindowLocator.CheckIfFocused()))
                {
                    if (server != null)
                    {
                        HostStop();
                    }
                    else
                    {
                        Pause();
                    }
                }
                else if (Config.Keybinds.Stop.IsDown(e))
                {
                    if (server != null)
                    {
                        HostStop();
                    }
                    else
                    {
                        Stop();
                    }
                }
            }
            if (Config.Keybinds.Mount.IsDown(e) && TerrariaWindowLocator.CheckIfFocused())
            {
                mounted = !mounted;
                checkBoxMounted.IsChecked = mounted;
            }
            for (int i = 0; i < Config.Midis.Count; i++)
            {
                if (Config.Midis[i].Keybind.IsDown(e) && (Config.PlaybackNoFocus || IsActive || TerrariaWindowLocator.CheckIfFocused()))
                {
                    Stop();

                    loaded                  = false;
                    Config.MidiIndex        = i;
                    listMidis.SelectedIndex = i;
                    loaded                  = true;
                    UpdateMidi();
                }
            }
            if (Config.Keybinds.Close.IsDown(e) && (Config.CloseNoFocus || IsActive || TerrariaWindowLocator.CheckIfFocused()))
            {
                Close();
            }
        }