Пример #1
0
        //Turns on media_player if not already on and if set to do so in settings.
        void StartupCommands()
        {
            if (Properties.Settings.Default.AutoOn)
            {
                if (HAData["state"] == "off")
                {
                    Task.Factory.StartNew(() => HAAPI.Power());
                }
            }

            if (Properties.Settings.Default.AutoOnSource)
            {
                Task.Factory.StartNew(() => HAAPI.Set_Input(Properties.Settings.Default.OnInput));
            }

            if (!String.IsNullOrEmpty(Properties.Settings.Default.StartSwitch))
            {
                Task.Factory.StartNew(() => HAAPI.Toggle_Switch("turn_on", Properties.Settings.Default.StartSwitch));
            }

            if (!String.IsNullOrEmpty(Properties.Settings.Default.ExtraApplication))
            {
                Process.Start(Properties.Settings.Default.ExtraApplication, Properties.Settings.Default.ExtraApplicationArgs);
            }
        }
Пример #2
0
        //Turns off media_player if not already off and if set to do so in settings.
        void ShutdownCommands()
        {
            if (Properties.Settings.Default.AutoOffSource)
            {
                if (HAData["state"] == "on")
                {
                    Task.Factory.StartNew(() => HAAPI.Set_Input(Properties.Settings.Default.OffInput));
                }
            }

            if (Properties.Settings.Default.AutoOff)
            {
                if (HAData["state"] == "on")
                {
                    Task.Factory.StartNew(() => HAAPI.Power());
                }
            }


            if (!String.IsNullOrEmpty(Properties.Settings.Default.StopSwitch))
            {
                Task.Factory.StartNew(() => HAAPI.Toggle_Switch("turn_off", Properties.Settings.Default.StopSwitch));
            }
        }
Пример #3
0
 //Toggles power when power icon clicked.
 private void imgPower_Click(object sender, EventArgs e) => Task.Factory.StartNew(() => HAAPI.Power());
Пример #4
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;
                }
            }
        }