Example #1
0
 //Mutes when mute icon clicked.
 private void imgMute_Click(object sender, EventArgs e) => Task.Factory.StartNew(() => HAAPI.Volume_Mute(HAData["attributes"]["is_volume_muted"]));
Example #2
0
        // Handle the Global Keybinds.
        private void _globalHook_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            //Continue only if CTRL wasn't pressed.
            if (e.Modifiers != System.Windows.Forms.Keys.Control)
            {
                switch (e.KeyCode)
                {
                case System.Windows.Forms.Keys.VolumeUp:
                    e.Handled = true;
                    Task.Factory.StartNew(() => HAAPI.Volume_Up());
                    if (Properties.Settings.Default.OSD && this.Opacity == 0)
                    {
                        Task.Factory.StartNew(() => ShowOSD());
                    }
                    break;

                case System.Windows.Forms.Keys.VolumeDown:
                    e.Handled = true;
                    Task.Factory.StartNew(() => HAAPI.Volume_Down());
                    if (Properties.Settings.Default.OSD && this.Opacity == 0)
                    {
                        Task.Factory.StartNew(() => ShowOSD());
                    }
                    break;

                case System.Windows.Forms.Keys.VolumeMute:
                    if (!Properties.Settings.Default.DisableMute)
                    {
                        e.Handled = true;
                        bool state = HAData["attributes"]["is_volume_muted"];
                        Task.Factory.StartNew(() => HAAPI.Volume_Mute(state));
                    }
                    break;

                // Pressing the Pause key without Shift will toggle power, with Shift it changes to the OnInput.
                case System.Windows.Forms.Keys.Pause:
                    e.Handled = true;
                    if (e.Modifiers == System.Windows.Forms.Keys.Shift)
                    {
                        Task.Factory.StartNew(() => HAAPI.Set_Input());
                    }
                    else
                    {
                        Task.Factory.StartNew(() => HAAPI.Power());
                    }
                    break;

                // Pressing the Scroll key without Shift will turn on additional switch, with Shift it turns off additional switch.
                case System.Windows.Forms.Keys.Scroll:
                    e.Handled = true;
                    if (e.Modifiers == System.Windows.Forms.Keys.Shift)
                    {
                        Task.Factory.StartNew(() => HAAPI.Toggle_Switch("turn_off", Properties.Settings.Default.StopSwitch));
                    }
                    else
                    {
                        Task.Factory.StartNew(() => HAAPI.Toggle_Switch("turn_on", Properties.Settings.Default.StartSwitch));
                    }
                    break;

                default:
                    break;
                }
            }
        }