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); }
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); } }
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())); }
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(); } }
public VolumeUI(VolumeSettings KeySettings) : this() { Settings = KeySettings; }
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(); }
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; }
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; } }
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()); }