Skip to content

Commit

Permalink
Better form handling for exiting, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
murrty authored Oct 25, 2020
1 parent acc1170 commit 744e801
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions frmDownloader.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void SetItemStatus(string URL, string Status) {
int ItemIndex = ThreadURLs.IndexOf(URL);
lvThreads.Items[ItemIndex].SubItems[0].Text = Status;
}
public bool AddNewThread(string URL) {
public bool AddNewThread(string URL, bool IsHidden = false) {
if (Chans.SupportedChan(URL)) {
if (ThreadURLs.Contains(URL)) {
int ThreadURLIndex = ThreadURLs.IndexOf(URL);
Expand Down Expand Up @@ -103,6 +103,10 @@ public bool AddNewThread(string URL) {
newThread.StartDownload();
ThreadDownloadForms.Add(newThread);
newThread.Show();
if (IsHidden) {
newThread.Hide();
}
newThread.Opacity = 100;
return true;
}
}
Expand Down Expand Up @@ -157,20 +161,22 @@ public bool TryExiting() {
private void frmMain_Load(object sender, EventArgs e) {
if (General.Default.SaveQueueOnExit && !Program.IsDebug) {
string[] ThreadArray = Chans.LoadThreads();
if (ThreadArray.Length > 0) {
if (ThreadArray != null && ThreadArray.Length > 0) {
for (int ThreadArrayIndex = 0; ThreadArrayIndex < ThreadArray.Length; ThreadArrayIndex++) {
AddNewThread(ThreadArray[ThreadArrayIndex]);
AddNewThread(ThreadArray[ThreadArrayIndex], true);
}
}
}
if (General.Default.ShowTrayIcon) {
niTray.Visible = true;
}
niTray.ContextMenu = cmTray;
}
private void frmMain_FormClosing(object sender, FormClosingEventArgs e) {
if (General.Default.MinimizeInsteadOfExiting) {
this.Hide();
niTray.Visible = true;
e.Cancel = true;
return;
}

if (!TryExiting()) {
Expand Down Expand Up @@ -201,7 +207,7 @@ private void cmItems_Popup(object sender, EventArgs e) {
}
}
private void niTray_MouseDoubleClick(object sender, MouseEventArgs e) {
if (this.Visible == false) {
if (!this.Visible) {
this.Show();
this.Activate();
if (!General.Default.ShowTrayIcon) {
Expand Down

0 comments on commit 744e801

Please sign in to comment.