private bool SetLayoutHotkeys(LayoutHotkeysWrapper layoutHotkeys) { Logger.LogTrace(); MainWindowSettingsModel.LayoutHotkeys.CleanUp(); foreach (var wrapper in layoutHotkeys.LayoutHotkeys) { MainWindowSettingsModel.LayoutHotkeys.SelectKey(wrapper.Key.ToString(CultureInfo.CurrentCulture), wrapper.LayoutId); } return(true); }
public void SerializeLayoutHotkeys() { LayoutHotkeysWrapper hotkeys = new LayoutHotkeysWrapper { }; hotkeys.LayoutHotkeys = new List <LayoutHotkeyWrapper>(); foreach (var pair in MainWindowSettingsModel.LayoutHotkeys.SelectedKeys) { if (!string.IsNullOrEmpty(pair.Value)) { try { LayoutHotkeyWrapper wrapper = new LayoutHotkeyWrapper { Key = int.Parse(pair.Key, CultureInfo.CurrentCulture), LayoutId = pair.Value, }; hotkeys.LayoutHotkeys.Add(wrapper); } catch (Exception ex) { Logger.LogError("Serialize quick layout keys error", ex); } } } try { string jsonString = JsonSerializer.Serialize(hotkeys, _options); _fileSystem.File.WriteAllText(FancyZonesLayoutHotkeysFile, jsonString); } catch (Exception ex) { Logger.LogError("Serialize layout hotkeys error", ex); App.ShowExceptionMessageBox(Properties.Resources.Error_Applying_Layout, ex); } }