Exemplo n.º 1
0
        private string GetDescription(VolumeSettings Settings)
        {
            if (Settings == null)
            {
                return("Adjust the Windows volume");
            }

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

            // Build output string
            switch (Settings.Method)
            {
            case 0:
                strOutput = "Increase the system volume by " + Settings.Percent.ToString() + "%";
                break;

            case 1:
                strOutput = "Decrease the system volume by " + Settings.Percent.ToString() + "%";
                break;

            case 2:
                strOutput = "Toggle the system mute";
                break;
            }

            return(strOutput);
        }
Exemplo n.º 2
0
        private bool AdjustVolume(VolumeSettings Settings)
        {
            if (Settings == null)
            {
                return(false);
            }

            OperatingSystem osInfo = Environment.OSVersion;

            if (osInfo.Platform != PlatformID.Win32NT)
            {
                return(false);
            }

            CompatibilityMode Mode = osInfo.Version.Major <= 5 ? CompatibilityMode.Compatible : CompatibilityMode.Standard;

            try
            {
                switch ((Method)_Settings.Method)
                {
                case Method.VolumeUp:
                    ChangeVolume(Mode, Method.VolumeUp);
                    break;

                case Method.VolumeDown:
                    ChangeVolume(Mode, Method.VolumeDown);
                    break;

                case Method.Mute:
                    SetMute(Mode);
                    break;
                }

                return(true);
            }
            catch
            {
                MessageBox.Show("Could not change volume settings.", "Volume Change Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
Exemplo n.º 3
0
        public string Serialize()
        {
            _Settings = _GUI.Settings;

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

            // Create json serializer to serialize json file
            DataContractJsonSerializer jSerial = new DataContractJsonSerializer(typeof(VolumeSettings));

            // Open json file
            MemoryStream mStream = new MemoryStream();
            StreamWriter sWrite  = new StreamWriter(mStream);

            // Serialize actions into json file
            jSerial.WriteObject(mStream, _Settings);

            return(Encoding.Default.GetString(mStream.ToArray()));
        }
Exemplo n.º 4
0
        public void Deserialize(string SerializedData)
        {
            // Clear existing settings if nothing was passed in
            if (String.IsNullOrEmpty(SerializedData))
            {
                _Settings = new VolumeSettings();
                return;
            }

            // Create memory stream from serialized data string
            MemoryStream memStream = new MemoryStream(Encoding.Default.GetBytes(SerializedData));

            // Create json serializer to deserialize json file
            DataContractJsonSerializer jSerial = new DataContractJsonSerializer(typeof(VolumeSettings));

            // Deserialize json file into actions list
            _Settings = jSerial.ReadObject(memStream) as VolumeSettings;

            if (_Settings == null)
            {
                _Settings = new VolumeSettings();
            }
        }
Exemplo n.º 5
0
 public VolumeUI(VolumeSettings KeySettings)
     : this()
 {
     Settings = KeySettings;
 }
Exemplo n.º 6
0
        public void Deserialize(string SerializedData)
        {
            // Clear existing settings if nothing was passed in
            if (String.IsNullOrEmpty(SerializedData))
            {
                _Settings = new VolumeSettings();
                return;
            }

            // Create memory stream from serialized data string
            MemoryStream memStream = new MemoryStream(Encoding.Default.GetBytes(SerializedData));

            // Create json serializer to deserialize json file
            DataContractJsonSerializer jSerial = new DataContractJsonSerializer(typeof(VolumeSettings));

            // Deserialize json file into actions list
            _Settings = jSerial.ReadObject(memStream) as VolumeSettings;

            if (_Settings == null)
                _Settings = new VolumeSettings();
        }
Exemplo n.º 7
0
        private string GetDescription(VolumeSettings Settings)
        {
            if (Settings == null)
                return "Adjust the Windows volume";

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

            // Build output string
            switch (Settings.Method)
            {
                case 0:
                    strOutput = "Increase the system volume by " + Settings.Percent.ToString() + "%";
                    break;
                case 1:
                    strOutput = "Decrease the system volume by " + Settings.Percent.ToString() + "%";
                    break;
                case 2:
                    strOutput = "Toggle the system mute";
                    break;
            }

            return strOutput;
        }
Exemplo n.º 8
0
        private bool AdjustVolume(VolumeSettings Settings)
        {
            if (Settings == null)
                return false;

            OperatingSystem osInfo = Environment.OSVersion;

            if (osInfo.Platform != PlatformID.Win32NT)
                return false;

            CompatibilityMode Mode = osInfo.Version.Major <= 5 ? CompatibilityMode.Compatible : CompatibilityMode.Standard;

            try
            {
                switch ((Method)_Settings.Method)
                {
                    case Method.VolumeUp:
                        ChangeVolume(Mode, Method.VolumeUp);
                        break;
                    case Method.VolumeDown:
                        ChangeVolume(Mode, Method.VolumeDown);
                        break;
                    case Method.Mute:
                        SetMute(Mode);
                        break;
                }

                return true;
            }
            catch
            {
                MessageBox.Show("Could not change volume settings.", "Volume Change Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
        }
Exemplo n.º 9
0
        public string Serialize()
        {
            _Settings = _GUI.Settings;

            if (_Settings == null)
                _Settings = new VolumeSettings();

            // Create json serializer to serialize json file
            DataContractJsonSerializer jSerial = new DataContractJsonSerializer(typeof(VolumeSettings));

            // Open json file
            MemoryStream mStream = new MemoryStream();
            StreamWriter sWrite = new StreamWriter(mStream);

            // Serialize actions into json file
            jSerial.WriteObject(mStream, _Settings);

            return Encoding.Default.GetString(mStream.ToArray());
        }
Exemplo n.º 10
0
 public VolumeUI(VolumeSettings KeySettings)
     : this()
 {
     Settings = KeySettings;
 }