diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 81edeec..ead3ea7 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -80,9 +80,9 @@ namespace RokettoLaunch panel1 = new System.Windows.Forms.Panel(); tileMenu1 = new System.Windows.Forms.ContextMenuStrip(components); editToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - removeToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); toolStripMenuItem6 = new System.Windows.Forms.ToolStripMenuItem(); toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); + removeToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); contextMenuStrip2.SuspendLayout(); menuStrip1.SuspendLayout(); tileContainerMenu1.SuspendLayout(); @@ -92,12 +92,12 @@ namespace RokettoLaunch // // saveFileDialog1 // - saveFileDialog1.Filter = "Session files|*.jsonfig"; + saveFileDialog1.Filter = "Session files (compressed)|*.jsnx|Session files|*.json;*.jsonfig"; saveFileDialog1.Title = "Choose file to save the session"; // // openFileDialog1 // - openFileDialog1.Filter = "Session files|*.jsonfig"; + openFileDialog1.Filter = "All supported files|*.json;*.jsonfig;*.jsnx|Session files (compressed)|*.jsnx|Session files|*.json;*.jsonfig"; openFileDialog1.Title = "Choose session file"; // // notifyIcon1 @@ -420,33 +420,33 @@ namespace RokettoLaunch // tileMenu1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { editToolStripMenuItem1, toolStripMenuItem6, toolStripSeparator4, removeToolStripMenuItem1 }); tileMenu1.Name = "tileMenu1"; - tileMenu1.Size = new System.Drawing.Size(181, 98); + tileMenu1.Size = new System.Drawing.Size(125, 76); // // editToolStripMenuItem1 // editToolStripMenuItem1.Name = "editToolStripMenuItem1"; - editToolStripMenuItem1.Size = new System.Drawing.Size(180, 22); + editToolStripMenuItem1.Size = new System.Drawing.Size(124, 22); editToolStripMenuItem1.Text = "&Edit"; editToolStripMenuItem1.Click += editToolStripMenuItem1_Click; // - // removeToolStripMenuItem1 - // - removeToolStripMenuItem1.Name = "removeToolStripMenuItem1"; - removeToolStripMenuItem1.Size = new System.Drawing.Size(180, 22); - removeToolStripMenuItem1.Text = "&Remove"; - removeToolStripMenuItem1.Click += removeToolStripMenuItem1_Click; - // // toolStripMenuItem6 // toolStripMenuItem6.Name = "toolStripMenuItem6"; - toolStripMenuItem6.Size = new System.Drawing.Size(180, 22); + toolStripMenuItem6.Size = new System.Drawing.Size(124, 22); toolStripMenuItem6.Text = "&Duplicate"; toolStripMenuItem6.Click += toolStripMenuItem6_Click; // // toolStripSeparator4 // toolStripSeparator4.Name = "toolStripSeparator4"; - toolStripSeparator4.Size = new System.Drawing.Size(177, 6); + toolStripSeparator4.Size = new System.Drawing.Size(121, 6); + // + // removeToolStripMenuItem1 + // + removeToolStripMenuItem1.Name = "removeToolStripMenuItem1"; + removeToolStripMenuItem1.Size = new System.Drawing.Size(124, 22); + removeToolStripMenuItem1.Text = "&Remove"; + removeToolStripMenuItem1.Click += removeToolStripMenuItem1_Click; // // MainForm // diff --git a/MainForm.cs b/MainForm.cs index fbce751..5eb559a 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -5,12 +5,11 @@ using System.IO; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; -using System.Xml.Linq; using RokettoLaunch.Models; +using RyzStudio; using RyzStudio.Windows.Forms; using RyzStudio.Windows.ThemedForms.ButtonTextBox; using RyzStudio.Windows.TileForms; -using static RyzStudio.Windows.ThemedForms.ButtonTextBox.ThKeyCodeTextBox; namespace RokettoLaunch { @@ -26,6 +25,7 @@ namespace RokettoLaunch { InitializeComponent(); + this.AutoScaleMode = AutoScaleMode.None; this.Text = Application.ProductName; _fileSessionManager = new FileSessionManager(); @@ -37,10 +37,7 @@ namespace RokettoLaunch _fileSessionManager.OnClearing += fileSessionManager_OnClearSession; _fileSessionManager.OnFilenameChanged += fileSessionManager_OnFilenameChanged; - //tileContainer1.OnColumnSizeChanged += tileContainer1_OnSizeChanged; notifyIcon1.Text = Application.ProductName; - - this.AutoScaleMode = AutoScaleMode.None; } protected async override void OnShown(EventArgs e) @@ -430,7 +427,22 @@ namespace RokettoLaunch { return await Task.Run(async () => { - this.CurrentSession = RyzStudio.Text.Json.JsonSerialiser.DeserialiseFile(filename); + var result = GenericResult.Create(); + + switch (Path.GetExtension(filename?.ToLower()?.Trim() ?? string.Empty)) + { + case ".json": + case ".jsonfig": + this.CurrentSession = RyzStudio.Text.Json.JsonSerialiser.DeserialiseFile(filename); + break; + case ".jsnx": + this.CurrentSession = await RyzStudio.IO.Compression.ZFile.ReadFile(filename, "Document.json"); + break; + default: + this.CurrentSession = null; + break; + } + if (this.CurrentSession == null) { MessageBox.Show("Unable to read session", "Load session"); @@ -479,7 +491,7 @@ namespace RokettoLaunch return true; } - return await Task.Run(() => + return await Task.Run(async () => { if (_isBusy) { @@ -503,7 +515,31 @@ namespace RokettoLaunch this.CurrentSession.Groups.Add((TileGroupModel)container.Tag); } - var result = RyzStudio.Text.Json.JsonSerialiser.SerialiseFile(filename, this.CurrentSession); + var result = GenericResult.Create(); + + switch (Path.GetExtension(filename?.ToLower()?.Trim() ?? string.Empty)) + { + case ".json": + case ".jsonfig": + result = RyzStudio.Text.Json.JsonSerialiser.SerialiseFile(filename, this.CurrentSession); + break; + case ".jsnx": + try + { + System.IO.File.Delete(filename); + } + catch(Exception) + { + // do nothing + } + + result = await RyzStudio.IO.Compression.ZFile.WriteFile(filename, "Document.json", this.CurrentSession); + break; + default: + result = GenericResult.Fault("Format not supported"); + break; + } + if (result.IsSuccess) { if (showNotices) @@ -513,16 +549,15 @@ namespace RokettoLaunch } else { - MessageBox.Show(result.Message, "Save session"); - - _isBusy = false; - - return false; + if (showNotices) + { + MessageBox.Show(result.Message, "Save session"); + } } _isBusy = false; - return true; + return result.IsSuccess; }); } diff --git a/References/RyzStudio.8.1.2.244.nupkg b/References/RyzStudio.8.1.2.244.nupkg deleted file mode 100644 index e296f09..0000000 Binary files a/References/RyzStudio.8.1.2.244.nupkg and /dev/null differ diff --git a/References/RyzStudio.8.1.2.249.nupkg b/References/RyzStudio.8.1.2.249.nupkg new file mode 100644 index 0000000..0778768 Binary files /dev/null and b/References/RyzStudio.8.1.2.249.nupkg differ diff --git a/References/RyzStudio.Windows.Forms.8.1.3.36.nupkg b/References/RyzStudio.Windows.Forms.8.1.3.36.nupkg deleted file mode 100644 index 7ec7757..0000000 Binary files a/References/RyzStudio.Windows.Forms.8.1.3.36.nupkg and /dev/null differ diff --git a/References/RyzStudio.Windows.Forms.8.1.3.87.nupkg b/References/RyzStudio.Windows.Forms.8.1.3.87.nupkg new file mode 100644 index 0000000..460bbcb Binary files /dev/null and b/References/RyzStudio.Windows.Forms.8.1.3.87.nupkg differ diff --git a/RokettoLaunch.csproj b/RokettoLaunch.csproj index f333389..a8efd28 100644 --- a/RokettoLaunch.csproj +++ b/RokettoLaunch.csproj @@ -14,7 +14,7 @@ Ray Lam 1.0.0.0 1.0.0.0 - 0.3.2.017 + 0.3.3.038 False x64 icon-128.png @@ -78,8 +78,8 @@ - - + + diff --git a/Windows/Forms/TilePanel.cs b/Windows/Forms/TilePanel.cs index 18cdeb7..c8b235b 100644 --- a/Windows/Forms/TilePanel.cs +++ b/Windows/Forms/TilePanel.cs @@ -66,11 +66,7 @@ namespace RokettoLaunch.Windows.Forms { if ((fileList?.Length ?? 0) > 0) { - var model = GetTileModel(fileList[0]); - if (model != null) - { - LoadInfo(model); - } + LoadInfo(fileList[0]); } } } @@ -137,6 +133,17 @@ namespace RokettoLaunch.Windows.Forms toolTip1.SetToolTip(this, this.Title); } + public void LoadInfo(string filename) + { + var model = GetTileModel(filename); + if (model == null) + { + return; + } + + LoadInfo(model); + } + private void Execute(TileModel model) { if (model == null)