Added: command line support

This commit is contained in:
Ray 2021-09-29 16:49:09 +01:00
parent dbdc654268
commit 90473e092d
3 changed files with 55 additions and 7 deletions

View File

@ -85,7 +85,13 @@ namespace FizzyLauncher
InvalidateAppSession();
newToolStripMenuItem_Click(null, null);
string[] commandLineArgs = Environment.GetCommandLineArgs();
bool hasCommands = await LoadCommandLine(commandLineArgs);
if (!hasCommands)
{
newToolStripMenuItem_Click(null, null);
}
}
protected async override void OnClosing(CancelEventArgs e)
@ -936,6 +942,48 @@ namespace FizzyLauncher
});
}
protected async Task<bool> LoadCommandLine(string[] args)
{
bool rs = false;
if (args.Length > 1)
{
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;
await LoadFile(openFilename);
//LoadBookmarksForm loadFileForm = new LoadBookmarksForm(this, openFilename);
//loadFileForm.ShowDialog();
rs = true;
i++;
break;
}
i++;
}
}
return rs;
}
protected async Task<Result> LoadFile(string filename)
{
return await Task.Run(() =>

View File

@ -23,8 +23,8 @@ DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
; Remove the following line to run in administrative install mode (install for all users.)
PrivilegesRequired=lowest
OutputDir=L:\gitlab-hiimray\fizzy-launcher\bin
OutputBaseFilename=fizzy-launcher-64
OutputDir=L:\gitlab-hiimray\bookmark-manager-r4\bin
OutputBaseFilename=bookmark-manager-64
Compression=lzma
SolidCompression=yes
WizardStyle=modern
@ -36,7 +36,7 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "L:\gitlab-hiimray\fizzy-launcher\bin\Release\64\fizzylauncher.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "L:\gitlab-hiimray\bookmark-manager-r4\bin\Release\64\bookmarkmanager.exe"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]

View File

@ -23,8 +23,8 @@ DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
; Remove the following line to run in administrative install mode (install for all users.)
PrivilegesRequired=lowest
OutputDir=L:\gitlab-hiimray\fizzy-launcher\bin
OutputBaseFilename=fizzy-launcher-86
OutputDir=L:\gitlab-hiimray\bookmark-manager-r4\bin
OutputBaseFilename=bookmark-manager-86
Compression=lzma
SolidCompression=yes
WizardStyle=modern
@ -36,7 +36,7 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "L:\gitlab-hiimray\fizzy-launcher\bin\Release\86\fizzylauncher.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "L:\gitlab-hiimray\bookmark-manager-r4\bin\Release\86\bookmarkmanager.exe"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]