public void ModifyAudioHotkey(int hotkeyId, string newName = "", string newKey = "", string newFiles = "", float newVolume = -1, int newStartingTime = -1, string newAudioDevice = "") { IHotkey hk = FindHotkeyById(hotkeyId); CheckIfProperHotkeyType(typeof(AudioHotkey), hk); AudioHotkey hotkey = (AudioHotkey)hk; if (newName != "") { hotkey.Name = newName; } if (newKey != "") { ModifyHotkey(hotkeyId, newKey); } if (newFiles != "") { hotkey.Files = newFiles; } if (newVolume != -1) { hotkey.Volume = newVolume / 100; } if (newStartingTime != -1) { hotkey.StartingTime = newStartingTime; } if (newAudioDevice != "") { hotkey.AudioDevice = new Guid(newAudioDevice); } }
private XElement SaveAudioHotkeyToXml(AudioHotkey hotkey, bool useRelativePaths) { XElement xmlHotkey = new XElement("AudioHotkey", new XElement("Name", hotkey.Name), new XElement("Key", hotkey.Key.FullKeyString)); XElement files; if (useRelativePaths) { string relativeFiles = ""; foreach (string file in hotkey.Files.Split('*')) { relativeFiles += Path.GetFileName(file) + "*"; } relativeFiles = relativeFiles.Substring(0, relativeFiles.Length - 1); files = new XElement("Files", relativeFiles); } else { files = new XElement("Files", hotkey.Files); } xmlHotkey.Add(files, new XElement("Device", hotkey.AudioDevice), new XElement("TimeStart", hotkey.StartingTime), new XElement("Volume", hotkey.Volume)); return(xmlHotkey); }
public int AddNewAudioHotkey(string key, string files, float volume, Guid audioDevice, int startingTime = 0, string name = "") { KeyAndModifiers fullKey = CreateAndValidateFullKey(key); AudioHotkey hk = new AudioHotkey(fullKey, audioDevice, files, volume, startingTime, name); CheckHotkeyResult(hk.Register(mainFrm), key); hotkeysList.Add(hk); return(hk.Id); }