From fdb8440f68c914ea64a27ef0e8af4d7159e9528b Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 19 Apr 2016 22:33:08 +0200 Subject: [PATCH] Fixed stuff --- DEIFR/ImageDownloader.cs | 31 ++++++++++++++++++++++++++++++- DEIFR/Program.cs | 13 +++++++++---- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/DEIFR/ImageDownloader.cs b/DEIFR/ImageDownloader.cs index f0e8df6..a3b026b 100644 --- a/DEIFR/ImageDownloader.cs +++ b/DEIFR/ImageDownloader.cs @@ -144,10 +144,39 @@ namespace DEIFR File.Delete(file); } } + if (Program.Auto) + { + Stop = true; + Program.Form.Invoke(new Action(delegate + { + Program.Form.Close(); + })); + return true; + } + Finished = true; } return true; } - public static bool Stop { get; set; } + private static bool stop = false; + public static bool Stop + { + get + { + return stop; + } + set + { + stop = value; + if (Finished) + { + Program.Form.Invoke(new Action(delegate + { + Program.Form.Close(); + })); + } + } + } + private static bool Finished = false; } } diff --git a/DEIFR/Program.cs b/DEIFR/Program.cs index 88a96bc..6b300d2 100644 --- a/DEIFR/Program.cs +++ b/DEIFR/Program.cs @@ -14,6 +14,7 @@ namespace DEIFR public static ProgressBar Progress; public static Form1 Form; public static ProgressBar AllProgress; + public static bool Auto = false; /// /// The main entry point for the application. @@ -49,10 +50,14 @@ namespace DEIFR } else MaxImages = 50; - if (args.Length == 0) - Application.Run(Form = new Form1()); - else if (args[0].ToLower() != "silent") - Console.WriteLine("Error: Unknown parameter(s). Use \"silent\" to open in background, otherwise don't give any parameters to show settings."); + if (args.Length > 0) + { + if (args[0].ToLower() != "silent") + Console.WriteLine("Error: Unknown parameter(s). Use \"silent\" to open in background, otherwise don't give any parameters to show settings."); + else + Auto = true; + } + Application.Run(Form = new Form1()); List sw = new List(); sw.Add("maximages=" + MaxImages); sw.Add("keepimages=" + KeepImages);