Beispiel #1
0
        private void SaveColors()
        {
            string favColors = JsonConvert.SerializeObject(FavColors.ToArray());

            Properties.Settings.Default.FavColors = favColors;
            Properties.Settings.Default.Save();
        }
Beispiel #2
0
 internal void RemoveColor(HSV color)
 {
     if (FavColors.Remove(color))
     {
         SaveColors();
     }
 }
Beispiel #3
0
 public void AddColor(HSV color)
 {
     if (!FavColors.Contains(color))
     {
         FavColors.Add(color);
         SaveColors();
     }
 }
Beispiel #4
0
        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();
            }
        }