private void SaveColors() { string favColors = JsonConvert.SerializeObject(FavColors.ToArray()); Properties.Settings.Default.FavColors = favColors; Properties.Settings.Default.Save(); }
internal void RemoveColor(HSV color) { if (FavColors.Remove(color)) { SaveColors(); } }
public void AddColor(HSV color) { if (!FavColors.Contains(color)) { FavColors.Add(color); SaveColors(); } }
public void LoadLibrary(bool isInDesignMode) { // Properties.Settings.Default.Reset(); if (isInDesignMode) { Scenes.Add(DesignerHelpers.GetScene(5, false, true)); Scenes.Add(DesignerHelpers.GetScene(5, true, false)); Scenes.Add(DesignerHelpers.GetScene(5, false, false)); FavColors.Add(new HSV(1, 1, 1)); FavColors.Add(new HSV(.3, .8, 1)); } else { try { string scenes = Properties.Settings.Default.Scenes; var array = JsonConvert.DeserializeObject <StateSet[]>(scenes); foreach (var s in array ?? Array.Empty <StateSet>()) { Scenes.Add(s); } } catch (Exception) { } var favColors = JsonConvert.DeserializeObject <HSV[]>(Properties.Settings.Default.FavColors); foreach (var c in favColors ?? Array.Empty <HSV>()) { FavColors.Add(c); } if (FavColors.Count == 0) { FavColors.Add(new HSV(1, 1, 1)); FavColors.Add(new HSV(.3, .8, 1)); SaveLibrary(); } App.Current.Exit += (s, e) => SaveLibrary(); } }