diff --git a/MainForm.cs b/MainForm.cs index 1ddb62c..cd9b259 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -277,7 +277,16 @@ namespace FizzyLauncher options.Converters.Add(new JsonPointConverter()); options.Converters.Add(new JsonSizeConverter()); - this.CurrentSession = JsonSerializer.Deserialize(sourceCode, options); + try + { + this.CurrentSession = JsonSerializer.Deserialize(sourceCode, options); + } + catch (Exception exc) + { + MessageBox.Show("Unable to read session", "Load session"); + return; + } + if (this.CurrentSession == null) { this.CurrentSession = new LauncherSession(); @@ -361,9 +370,13 @@ namespace FizzyLauncher this.CurrentSession.Groups.Add(container.Model); } + var options = new JsonSerializerOptions(); + options.Converters.Add(new JsonPointConverter()); + options.Converters.Add(new JsonSizeConverter()); + try { - File.WriteAllText(filename, JsonSerializer.Serialize(this.CurrentSession)); + File.WriteAllText(filename, JsonSerializer.Serialize(this.CurrentSession, options)); if (showNotices) { diff --git a/Models/TileGroupModel.cs b/Models/TileGroupModel.cs index cdf04a6..6f69481 100644 --- a/Models/TileGroupModel.cs +++ b/Models/TileGroupModel.cs @@ -1,14 +1,21 @@ -using System.Collections.Generic; +using FizzyLauncher.Text.Json; +using System.Collections.Generic; using System.Drawing; +using System.Text.Json.Serialization; namespace FizzyLauncher.Models { public class TileGroupModel { public string Title { get; set; } + public bool IsExpanded { get; set; } = false; + public bool IsExclusive { get; set; } = false; + public List Items { get; set; } = new List(); + + [JsonConverter(typeof(JsonSizeConverter))] public Size GridSize { get; set; } = new Size(0, 0); } } \ No newline at end of file diff --git a/Models/TileModel.cs b/Models/TileModel.cs index 72f8411..9e47756 100644 --- a/Models/TileModel.cs +++ b/Models/TileModel.cs @@ -1,21 +1,31 @@ -using System; +using FizzyLauncher.Text.Json; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; +using System.Text.Json.Serialization; namespace FizzyLauncher.Models { public class TileModel { public string Title { get; set; } + public string ProcessFilename { get; set; } + public string ProcessArgument { get; set; } + public string ProcessWorkingDirectory { get; set; } + public ProcessWindowStyle ProcessWindowStyle { get; set; } = ProcessWindowStyle.Normal; + public bool ProcessAsAdmin { get; set; } = false; + + [JsonConverter(typeof(JsonPointConverter))] public Point Position { get; set; } public bool IsGroup { get; set; } = false; + public List Items { get; set; } = new List(); public override string ToString() => this.Title ?? string.Empty;