public static void SaveWallpaperMetaData(LivelyInfo info, string saveDirectory) //used to create livelyinfo.json file { //return; JsonSerializer serializer = new JsonSerializer { Formatting = Formatting.Indented, NullValueHandling = NullValueHandling.Include }; /* * if (String.IsNullOrWhiteSpace(info.AppVersion)) * info.AppVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); */ try { using (StreamWriter sw = new StreamWriter(saveDirectory + "\\LivelyInfo.json")) using (JsonWriter writer = new JsonTextWriter(sw)) { serializer.Serialize(writer, info); } } catch (Exception e) { Logger.Error(e.ToString()); } }
private void GenerateLivelyInfo(WallpaperLayout wpLayout) { LivelyInfo tmpInfo = new LivelyInfo() { IsAbsolutePath = true, //absolute filepath, wp files will be located outside of lively folder. FileName = wpLayout.FilePath, Title = textboxTitle.Text, Desc = textboxDesc.Text, Contact = textboxContact.Text, Author = textboxAuthor.Text, Arguments = wpLayout.Arguments, Type = wpLayout.Type, Thumbnail = "lively_t.jpg", Preview = "lively_p.gif" }; /* * if (SaveData.config.PreviewGIF.CaptureGif) * { * tmpInfo.Preview = "lively_p.gif"; * } * else * { * tmpInfo.Preview = null; * } */ SaveData.SaveWallpaperMetaData(tmpInfo, saveDirectory); }
public LivelyInfo(LivelyInfo info) { AppVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); Title = info.Title; Thumbnail = info.Thumbnail; Preview = info.Preview; Type = info.Type; FileName = info.FileName; Desc = info.Desc; Author = info.Author; Contact = info.Contact; License = info.License; Arguments = info.Arguments; }
/// <summary> /// Load Livelinfo.json file. /// </summary> /// <param name="directory"></param> /// <returns>true - success, false - failure</returns> public static bool LoadWallpaperMetaData(string directory) { try { using (StreamReader file = File.OpenText(directory + "\\LivelyInfo.json")) { JsonSerializer serializer = new JsonSerializer(); info = (LivelyInfo)serializer.Deserialize(file, typeof(LivelyInfo)); } return(true); } catch (IOException e1) { Logger.Error("Error trying to read livelyinfo file from disc:- " + directory + "\n" + e1.ToString()); return(false); } catch (Exception e2) { Logger.Error("Corrupted livelinfo file, skipping wallpaper:- " + directory + "\n" + e2.ToString()); return(false); } }