From 90473e092dad980dec49e6a75cd13993fef6f018 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 29 Sep 2021 16:49:09 +0100 Subject: [PATCH] Added: command line support --- MainForm.cs | 50 +++++++++++++++++++++++++++++++++++++++++++++++- installer-64.iss | 6 +++--- installer-86.iss | 6 +++--- 3 files changed, 55 insertions(+), 7 deletions(-) diff --git a/MainForm.cs b/MainForm.cs index c47f0a9..9ac27ad 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -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 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 LoadFile(string filename) { return await Task.Run(() => diff --git a/installer-64.iss b/installer-64.iss index 3282b61..11a6a79 100644 --- a/installer-64.iss +++ b/installer-64.iss @@ -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] diff --git a/installer-86.iss b/installer-86.iss index bbab705..ee7e5df 100644 --- a/installer-86.iss +++ b/installer-86.iss @@ -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]