The program now prevents closing if it's still downloading an image
This commit is contained in:
parent
a811d376dc
commit
1c4e88b6a5
3 changed files with 21 additions and 1 deletions
|
@ -19,6 +19,16 @@ namespace DEIFR
|
||||||
checkBox1.Checked = Program.KeepImages;
|
checkBox1.Checked = Program.KeepImages;
|
||||||
Program.Progress = progressBar1;
|
Program.Progress = progressBar1;
|
||||||
Program.AllProgress = progressBar2;
|
Program.AllProgress = progressBar2;
|
||||||
|
this.FormClosing += Form1_FormClosing;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
if (!ImageDownloader.Stop)
|
||||||
|
{
|
||||||
|
ImageDownloader.Stop = true;
|
||||||
|
e.Cancel = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkBox1_CheckedChanged(object sender, EventArgs e)
|
private void checkBox1_CheckedChanged(object sender, EventArgs e)
|
||||||
|
|
|
@ -96,6 +96,14 @@ namespace DEIFR
|
||||||
|
|
||||||
private static bool Next()
|
private static bool Next()
|
||||||
{
|
{
|
||||||
|
if (Stop)
|
||||||
|
{
|
||||||
|
Program.Form.Invoke(new Action(delegate
|
||||||
|
{
|
||||||
|
Program.Form.Close();
|
||||||
|
}));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (enumerator.MoveNext())
|
if (enumerator.MoveNext())
|
||||||
{
|
{
|
||||||
JToken result = enumerator.Current;
|
JToken result = enumerator.Current;
|
||||||
|
@ -113,7 +121,6 @@ namespace DEIFR
|
||||||
else
|
else
|
||||||
return false; //Otherwise we don't know what is there
|
return false; //Otherwise we don't know what is there
|
||||||
}
|
}
|
||||||
//Image.FromStream(respstr).Save(i + "." + s.Split('/').Last().Split('.')[1]);
|
|
||||||
string path = id + "." + s.Split('/').Last().Split('.')[1].Split('?')[0]; //?: FB and similar sites
|
string path = id + "." + s.Split('/').Last().Split('.')[1].Split('?')[0]; //?: FB and similar sites
|
||||||
using (WebClient client = new WebClient())
|
using (WebClient client = new WebClient())
|
||||||
{
|
{
|
||||||
|
@ -140,5 +147,7 @@ namespace DEIFR
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool Stop { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ namespace DEIFR
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||||
|
|
||||||
if (File.Exists("DEIFRSettings.ini"))
|
if (File.Exists("DEIFRSettings.ini"))
|
||||||
{
|
{
|
||||||
string[] ss = File.ReadAllLines("DEIFRSettings.ini");
|
string[] ss = File.ReadAllLines("DEIFRSettings.ini");
|
||||||
|
|
Loading…
Reference in a new issue