Exemple #1
0
        private string GetDescription(VolumeSettings Settings)
        {
            if (Settings == null)
            {
                return(LocalizationProvider.Instance.GetTextValue("CorePlugins.Volume.Name"));
            }

            // Create string to store final output description
            string strOutput = "";

            // Build output string
            switch (Settings.Method)
            {
            case 0:
                strOutput = LocalizationProvider.Instance.GetTextValue("CorePlugins.Volume.Increase") + Settings.Percent + " %";
                break;

            case 1:
                strOutput = LocalizationProvider.Instance.GetTextValue("CorePlugins.Volume.Decrease") + Settings.Percent + " %";
                break;

            case 2:
                strOutput = LocalizationProvider.Instance.GetTextValue("CorePlugins.Volume.Mute");
                break;
            }

            return(strOutput);
        }
Exemple #2
0
        public string Serialize()
        {
            if (_GUI != null)
            {
                _settings = _GUI.Settings;
            }

            if (_settings == null)
            {
                _settings = new VolumeSettings();
            }

            return(PluginHelper.SerializeSettings(_settings));
        }
Exemple #3
0
        private bool AdjustVolume(VolumeSettings settings)
        {
            if (settings == null)
            {
                return(false);
            }

            try
            {
                InputSimulator simulator = new InputSimulator();
                int            t         = settings.Percent / 2;

                switch ((Method)settings.Method)
                {
                case Method.VolumeUp:
                    for (int i = 0; i < t; i++)
                    {
                        simulator.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.VOLUME_UP);
                    }
                    break;

                case Method.VolumeDown:
                    for (int i = 0; i < t; i++)
                    {
                        simulator.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.VOLUME_DOWN);
                    }
                    break;

                case Method.Mute:
                    simulator.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.VOLUME_MUTE);
                    break;
                }

                return(true);
            }
            catch
            {
                //MessageBox.Show("Could not change volume settings.", "Volume Change Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
Exemple #4
0
        private bool AdjustVolume(VolumeSettings settings)
        {
            if (settings == null)
            {
                return(false);
            }

            try
            {
                InputSimulator simulator = new InputSimulator();
                int            t         = settings.Percent / 2;

                switch ((Method)settings.Method)
                {
                case Method.VolumeUp:
                    for (int i = 0; i < t; i++)
                    {
                        simulator.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.VOLUME_UP);
                    }
                    break;

                case Method.VolumeDown:
                    for (int i = 0; i < t; i++)
                    {
                        simulator.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.VOLUME_DOWN);
                    }
                    break;

                case Method.Mute:
                    simulator.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.VOLUME_MUTE);
                    break;
                }

                return(true);
            }
            catch
            {
                int t = settings.Percent / 2;

                switch ((Method)settings.Method)
                {
                case Method.VolumeUp:
                    var volumeUpKey = new KeyboardKey(Keys.VolumeUp);
                    for (int i = 0; i < t; i++)
                    {
                        volumeUpKey.Press();
                        Thread.Sleep(3);
                        volumeUpKey.Release();
                    }
                    break;

                case Method.VolumeDown:
                    var volumeDownKey = new KeyboardKey(Keys.VolumeDown);
                    for (int i = 0; i < t; i++)
                    {
                        volumeDownKey.Press();
                        Thread.Sleep(3);
                        volumeDownKey.Release();
                    }
                    break;

                case Method.Mute:
                    var muteKey = new KeyboardKey(Keys.VolumeMute);
                    muteKey.PressAndRelease();
                    break;
                }
                return(false);
            }
        }