Added: load file from command line switch

This commit is contained in:
Ray 2021-10-24 02:33:53 +01:00
parent adbba78414
commit f26734cb27
5 changed files with 53 additions and 11 deletions

View File

@ -12,9 +12,9 @@
<Company>Hi, I'm Ray</Company>
<Product>Fizzy Launcher</Product>
<Copyright>Ray Lam</Copyright>
<AssemblyVersion>0.2.3.006</AssemblyVersion>
<FileVersion>0.2.3.006</FileVersion>
<Version>0.2.3.006</Version>
<AssemblyVersion>0.2.3.009</AssemblyVersion>
<FileVersion>0.2.3.009</FileVersion>
<Version>0.2.3.009</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

7
MainForm.Designer.cs generated
View File

@ -284,7 +284,7 @@ namespace FizzyLauncher
this.aboutToolStripMenuItem1.Text = "&About";
this.aboutToolStripMenuItem1.Click += new System.EventHandler(this.aboutToolStripMenuItem1_Click);
//
// panel1
// tileContainer1
//
this.tileContainer1.AutoScroll = true;
this.tileContainer1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
@ -292,15 +292,14 @@ namespace FizzyLauncher
this.tileContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tileContainer1.Location = new System.Drawing.Point(0, 24);
this.tileContainer1.Margin = new System.Windows.Forms.Padding(0);
this.tileContainer1.Name = "panel1";
this.tileContainer1.Name = "tileContainer1";
this.tileContainer1.Padding = new System.Windows.Forms.Padding(10, 10, 10, 20);
this.tileContainer1.Size = new System.Drawing.Size(633, 376);
this.tileContainer1.TabIndex = 3;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(250)))), ((int)(((byte)(250)))), ((int)(((byte)(250)))));
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.ClientSize = new System.Drawing.Size(633, 400);

View File

@ -50,6 +50,8 @@ namespace FizzyLauncher
{
base.OnLoad(e);
this.AutoScaleMode = AutoScaleMode.None;
ThreadControl.SetVisible(this, false);
ThreadControl.SetSize(this, this.MinimumSize);
}
@ -60,8 +62,13 @@ namespace FizzyLauncher
ThreadControl.SetVisible(this, false);
string jsonfigFilename = Path.ChangeExtension(Application.ExecutablePath, "jsonfig");
if (File.Exists(jsonfigFilename))
string[] commandLineArgs = Environment.GetCommandLineArgs();
string jsonfigFilename = null;
if (string.IsNullOrWhiteSpace(jsonfigFilename)) jsonfigFilename = parseOpenFile_FromCMD(commandLineArgs);
if (string.IsNullOrWhiteSpace(jsonfigFilename)) jsonfigFilename = Path.ChangeExtension(Application.ExecutablePath, "jsonfig");
if (!string.IsNullOrWhiteSpace(jsonfigFilename) && File.Exists(jsonfigFilename))
{
await loadFile(jsonfigFilename);
}
@ -236,6 +243,42 @@ namespace FizzyLauncher
}
}
protected string parseOpenFile_FromCMD(string[] args)
{
if (args.Length <= 1)
{
return null;
}
int i = 1;
while (true)
{
if (i > (args.Length - 1))
{
break;
}
switch (args[i].Trim().ToLower())
{
case "-o":
case "-open":
if ((i + 1) > (args.Length - 1)) break;
string openFilename = args[(i + 1)];
if (string.IsNullOrWhiteSpace(openFilename)) break;
if (!File.Exists(openFilename)) break;
return openFilename;
i++;
break;
}
i++;
}
return null;
}
protected void newSession()
{

View File

@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "Fizzy Launcher"
#define MyAppVersion "0.2.3.006"
#define MyAppVersion "0.2.3.009"
#define MyAppPublisher "Hi, I'm Ray"
#define MyAppURL "https://www.hiimray.co.uk/software-fizzy-launcher"
#define MyAppExeName "fizzylauncher.exe"

View File

@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "Fizzy Launcher"
#define MyAppVersion "0.2.3.006"
#define MyAppVersion "0.2.3.009"
#define MyAppPublisher "Hi, I'm Ray"
#define MyAppURL "https://www.hiimray.co.uk/software-fizzy-launcher"
#define MyAppExeName "fizzylauncher.exe"