Compare commits

...

2 Commits

8 changed files with 78 additions and 36 deletions

28
MainForm.Designer.cs generated
View File

@ -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
//

View File

@ -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<AppOptions>(filename);
var result = GenericResult.Create();
switch (Path.GetExtension(filename?.ToLower()?.Trim() ?? string.Empty))
{
case ".json":
case ".jsonfig":
this.CurrentSession = RyzStudio.Text.Json.JsonSerialiser.DeserialiseFile<AppOptions>(filename);
break;
case ".jsnx":
this.CurrentSession = await RyzStudio.IO.Compression.ZFile.ReadFile<AppOptions>(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;
});
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -14,7 +14,7 @@
<Copyright>Ray Lam</Copyright>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<Version>0.3.2.017</Version>
<Version>0.3.3.038</Version>
<EnableNETAnalyzers>False</EnableNETAnalyzers>
<PlatformTarget>x64</PlatformTarget>
<PackageIcon>icon-128.png</PackageIcon>
@ -78,8 +78,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="RyzStudio" Version="8.1.2.244" />
<PackageReference Include="RyzStudio.Windows.Forms" Version="8.1.3.36" />
<PackageReference Include="RyzStudio" Version="8.1.2.249" />
<PackageReference Include="RyzStudio.Windows.Forms" Version="8.1.3.87" />
</ItemGroup>
<ItemGroup>

View File

@ -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)