Exemple #1
0
        //key pressed
        public static void DeckKeyPressed(object sender, OpenMacroBoard.SDK.KeyEventArgs e)
        {
            var profilesButton = 2;
            var clockButton    = 0;
            var monitorButton  = 4;
            var exitButton     = 7;

            if (isMiniDeck == true)
            {
                profilesButton = 1;
                monitorButton  = 2;
                exitButton     = 4;
            }

            try
            {
                if (e.Key == profilesButton)
                {
                    if (e.IsDown == true)
                    {
                        int currentprofileNumber = int.Parse(Regex.Match(SettingsSDMonitor.currentProfile, @"\d+").Value);
                        int nextProfile;

                        if (currentprofileNumber != 3)
                        {
                            nextProfile = currentprofileNumber + 1;
                        }

                        else
                        {
                            nextProfile = 1;
                        }

                        string nextProfileString = "Profile " + nextProfile.ToString();
                        SharedSettings.config.Write("selectedProfile", nextProfileString, "Current_Profile");
                        RestartApp();
                    }
                }

                if (e.Key == clockButton)
                {
                    if (e.IsDown == true)
                    {
                        //write State to config file then start MonitorState
                        SharedSettings.config.Write("seletedState", "2", "Current_State");
                        //restart to show new state
                        RestartApp();
                    }
                }

                if (e.Key == monitorButton)
                {
                    if (e.IsDown == true)
                    {
                        //write State to config file then start MonitorState
                        SharedSettings.config.Write("seletedState", "1", "Current_State");
                        //restart to show new state
                        RestartApp();
                    }
                }

                if (e.Key == exitButton)
                {
                    if (e.IsDown == true)
                    {
                        if (isMiniDeck)
                        {
                            ImageManager.exitflag = true;
                            ohmComputer.Close();
                            ImageManager.deck.ShowLogo();

                            //close StreamDeckMonitor
                            ExitApp();
                        }

                        else
                        {
                            //clear display for clean exit
                            ImageManager.exitflag = true;
                            ohmComputer.Close();
                            ImageManager.deck.ClearKeys();
                            System.Threading.Thread.Sleep(1000);
                            ImageManager.deck.ShowLogo();

                            //close StreamDeckMonitor
                            ExitApp();
                        }
                    }
                }
            }

            catch (Exception)
            {
                ExitApp();
            }
        }
        private void ButtonClicked(object sender, OpenMacroBoard.SDK.KeyEventArgs e)
        {
            if (e.IsDown)
            {
                return;
            }
            if (this._currentButtons.Length < e.Key)
            {
                return;
            }

            // there is some action, so stop the timer
            this.StopBackTimer();

            if (this._buttonClickSound != null)
            {
                this._buttonClickSound.controls.currentPosition = 0;
                this._buttonClickSound.controls.play();
            }

            StreamDeckButton button = null;

            button = this._currentButtons[e.Key];

            // on button click I want to remove the notification
            if (this._currentNotifications.ContainsKey(button.Name.ToLower()))
            {
                // clean up the notifications
                Notifications notification = new Notifications();
                notification.ClearNotifications(this._currentNotifications[button.Name.ToLower()]);

                // remove it from our notification list so we don't recount it.
                this._currentNotifications.Remove(button.Name.ToLower());

                // redraw the button, hopefully without the notification
                this.AddButton(e.Key, button);
            }

            // button actions! Let's do some cool things
            switch (button.Action)
            {
            case StreamDeckButtonAction.OpenProgram:
                this.OpenTarget(button.Target);
                break;

            case StreamDeckButtonAction.KeyPress:
                this.PressKeys(button.KeyPresses);
                break;

            case StreamDeckButtonAction.Folder:
                this.OpenFolder(e.Key);
                break;

            case StreamDeckButtonAction.BackButton:
                this.BackFolder();
                break;

            case StreamDeckButtonAction.ClearNotifications:
                this.ClearNotifications();
                break;
            }

            // I want a timer to reset after a button has been clicked.
            if (this._currentLevel > 0)
            {
                this.StartBackTimer();
            }
        }