Beispiel #1
0
        //public static List<WallpaperLayout> wallpapers = new List<WallpaperLayout>();

        public static void SaveWallpaperLayout()
        {
            WallpaperLayoutList tmp = new WallpaperLayoutList
            {
                Layouts = SetupDesktop.wallpapers
            };

            JsonSerializer serializer = new JsonSerializer
            {
                Formatting = Formatting.Indented,
                //serializer.Converters.Add(new JavaScriptDateTimeConverter());
                NullValueHandling = NullValueHandling.Include
            };

            /*
             * if (String.IsNullOrWhiteSpace(tmp.AppVersion))
             *  tmp.AppVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
             */
            try
            {
                using (StreamWriter sw = new StreamWriter(App.pathData + "\\SaveData\\lively_layout.json"))
                    using (JsonWriter writer = new JsonTextWriter(sw))
                    {
                        serializer.Serialize(writer, tmp);
                    }
            }
            catch (Exception e)
            {
                Logger.Error(e.ToString());
            }
        }
Beispiel #2
0
        public static void LoadWallpaperLayout()
        {
            if (!File.Exists(App.pathData + "\\SaveData\\lively_layout.json"))
            {
                //SaveWallpaperLayout()
                return;
            }

            try
            {
                // deserialize JSON directly from a file
                using (StreamReader file = File.OpenText(App.pathData + "\\SaveData\\lively_layout.json"))
                {
                    JsonSerializer      serializer = new JsonSerializer();
                    WallpaperLayoutList tmp        = (WallpaperLayoutList)serializer.Deserialize(file, typeof(WallpaperLayoutList));
                    SetupDesktop.wallpapers = tmp.Layouts;
                }
            }
            catch (Exception e)
            {
                SetupDesktop.wallpapers.Clear();
                Logger.Error(e.ToString());
            }
        }