Command line support (right-click on file menu)

This commit is contained in:
Samuel Tulach 2020-05-12 12:40:12 +02:00
parent c8a8b4c44a
commit c0b089cc71
27 changed files with 13053 additions and 3 deletions

Binary file not shown.

View File

@ -72,6 +72,7 @@
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "VirusTotal Uploder";
this.Load += new System.EventHandler(this.MainForm_Load);
this.Shown += new System.EventHandler(this.MainForm_Shown);
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.MainForm_DragDrop);
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.MainForm_DragEnter);
this.ResumeLayout(false);

View File

@ -3,7 +3,9 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
@ -20,6 +22,9 @@ namespace uploader
private void MainForm_Load(object sender, EventArgs e)
{
// Set working directory to exe location because of language files
Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
var settings = Settings.LoadSettings();
if (!string.IsNullOrEmpty(settings.Language))
{
@ -52,7 +57,21 @@ namespace uploader
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (var file in files)
{
var uploadForm = new UploadForm(this, settings, file);
var uploadForm = new UploadForm(this, settings, true, file);
uploadForm.Show();
this.Hide();
}
}
private void MainForm_Shown(object sender, EventArgs e)
{
var settings = Settings.LoadSettings();
var args = Environment.GetCommandLineArgs();
if (args.Length == 2)
{
var file = args[1]; // Second argument because .NET puts program filename to the first
var uploadForm = new UploadForm(this, settings, false, file);
uploadForm.Show();
this.Hide();
}

View File

@ -18,17 +18,19 @@ namespace uploader
{
public partial class UploadForm : DarkForm
{
private readonly bool _reopen;
private readonly string _fileName;
private readonly MainForm _mainForm;
private readonly Settings _settings;
private Thread _uploadThread;
private RestClient _client;
public UploadForm(MainForm mainForm, Settings settings, string fileName)
public UploadForm(MainForm mainForm, Settings settings, bool reopen, string fileName)
{
_fileName = fileName;
_mainForm = mainForm;
_settings = settings;
_reopen = reopen;
InitializeComponent();
}
@ -136,7 +138,14 @@ namespace uploader
private void UploadForm_FormClosing(object sender, FormClosingEventArgs e)
{
_mainForm.Show();
if (_reopen)
{
_mainForm.Show();
}
else
{
_mainForm.Close();
}
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,21 @@
{
"MainForm_DragFile": "Přesuňte soubor zde",
"MainForm_More": "Více",
"SettingsForm_Title": "Nastavení",
"SettingsForm_General": "Obecné nastavení",
"SettingsForm_Key": "API klíč",
"SettingsForm_Get": "Získat API klíč",
"SettingsForm_Language": "Jazyk",
"SettingsForm_Save": "Uložit",
"SettingsForm_Open": "Otevřit soubor nastavení",
"UploadForm_Info": "Informace o souboru",
"UploadForm_Upload": "Nahrát",
"UploadForm_Cancel": "Zrušit",
"Message_Idle": "Nic.",
"Message_Init": "Inicializace...",
"Message_Check": "Kontrola...",
"Message_Upload": "Nahrávání...",
"Message_NoLink": "Zádný odkaz v odpovědi serveru!",
"Message_NoSettings": "Soubor nastavení neexistuje.",
"Message_Saved": "Nastavení uloženo."
}

View File

@ -0,0 +1,21 @@
{
"MainForm_DragFile": "Drag file here",
"MainForm_More": "More",
"SettingsForm_Title": "Settings",
"SettingsForm_General": "General settings",
"SettingsForm_Key": "API key",
"SettingsForm_Get": "Get API key",
"SettingsForm_Language": "Language",
"SettingsForm_Save": "Save",
"SettingsForm_Open": "Open settings file",
"UploadForm_Info": "File information",
"UploadForm_Upload": "Upload",
"UploadForm_Cancel": "Cancel",
"Message_Idle": "Idle.",
"Message_Init": "Initializing...",
"Message_Check": "Checking...",
"Message_Upload": "Uploading...",
"Message_NoLink": "No permalink found in response!",
"Message_NoSettings": "No settings file exists.",
"Message_Saved": "Settings saved."
}

Binary file not shown.

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

Binary file not shown.

View File

@ -0,0 +1 @@
159bfbce617eb7b15aef8131047e568b7e817826

View File

@ -0,0 +1,19 @@
C:\Users\q\Documents\Projects\5-11-2020\VirusUploader\uploader\uploader\build\dbg\uploader.exe.config
C:\Users\q\Documents\Projects\5-11-2020\VirusUploader\uploader\uploader\build\dbg\uploader.exe
C:\Users\q\Documents\Projects\5-11-2020\VirusUploader\uploader\uploader\build\dbg\uploader.pdb
C:\Users\q\Documents\Projects\5-11-2020\VirusUploader\uploader\uploader\build\dbg\DarkUI.dll
C:\Users\q\Documents\Projects\5-11-2020\VirusUploader\uploader\uploader\build\dbg\Newtonsoft.Json.dll
C:\Users\q\Documents\Projects\5-11-2020\VirusUploader\uploader\uploader\build\dbg\RestSharp.dll
C:\Users\q\Documents\Projects\5-11-2020\VirusUploader\uploader\uploader\build\dbg\DarkUI.pdb
C:\Users\q\Documents\Projects\5-11-2020\VirusUploader\uploader\uploader\build\dbg\Newtonsoft.Json.xml
C:\Users\q\Documents\Projects\5-11-2020\VirusUploader\uploader\uploader\build\dbg\RestSharp.xml
C:\Users\q\Documents\Projects\5-11-2020\VirusUploader\uploader\uploader\obj\Debug\uploader.MainForm.resources
C:\Users\q\Documents\Projects\5-11-2020\VirusUploader\uploader\uploader\obj\Debug\uploader.Properties.Resources.resources
C:\Users\q\Documents\Projects\5-11-2020\VirusUploader\uploader\uploader\obj\Debug\uploader.SettingsForm.resources
C:\Users\q\Documents\Projects\5-11-2020\VirusUploader\uploader\uploader\obj\Debug\uploader.UploadForm.resources
C:\Users\q\Documents\Projects\5-11-2020\VirusUploader\uploader\uploader\obj\Debug\uploader.csproj.GenerateResource.cache
C:\Users\q\Documents\Projects\5-11-2020\VirusUploader\uploader\uploader\obj\Debug\uploader.csproj.CoreCompileInputs.cache
C:\Users\q\Documents\Projects\5-11-2020\VirusUploader\uploader\uploader\obj\Debug\uploader.csproj.CopyComplete
C:\Users\q\Documents\Projects\5-11-2020\VirusUploader\uploader\uploader\obj\Debug\uploader.exe
C:\Users\q\Documents\Projects\5-11-2020\VirusUploader\uploader\uploader\obj\Debug\uploader.pdb
C:\Users\q\Documents\Projects\5-11-2020\VirusUploader\uploader\uploader\obj\Debug\uploader.csprojAssemblyReference.cache

Binary file not shown.

Binary file not shown.