Skip to content

Commit

Permalink
Prompt before closing the app if an action (upload, loading albums or…
Browse files Browse the repository at this point in the history
… loging in) is currently in progress.
  • Loading branch information
ivanz committed Sep 20, 2011
1 parent 6d70ab2 commit 39610c1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
9 changes: 8 additions & 1 deletion PicasaUploader/UI/Controls/WizardActionBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public partial class WizardActionBar : UserControl
{
private const string Next_Button_String = "Next";
private Wizard _wizard;
private bool _actionExecuting = false;

/// <summary>
/// Do not use this constructor it's only here for the WinForms designer surface
Expand All @@ -29,6 +30,11 @@ public WizardActionBar(Wizard wizard) : this()
Wizard = wizard;
}

public bool IsActionInProgress
{
get { return _actionExecuting; }
}

[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Wizard Wizard
Expand Down Expand Up @@ -101,7 +107,7 @@ private void UpdateButtons()
public void OnActionCompleted(object sender, SuccessEventArgs args)
{
this.Enabled = true;

this._actionExecuting = false;
if (args.Success)
Wizard.Next();
}
Expand All @@ -122,6 +128,7 @@ private void OnInitializationComplete(object sender, EventArgs args)
private void OnActionStarting(object sender, EventArgs args)
{
this.Enabled = false;
_actionExecuting = true;
}

private void GoPrevious()
Expand Down
11 changes: 11 additions & 0 deletions PicasaUploader/UI/PicasaUploader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,16 @@ private void aboutButton_Click(object sender, EventArgs e)
{
AboutDialog.ShowDialog();
}

protected override void OnClosing(CancelEventArgs e)
{
if (wizardActionBar.IsActionInProgress) {
if (MessageBox.Show(this, "An action is currently in progress. Are you sure you want to quit?", "Are you sure?", MessageBoxButtons.YesNo) == DialogResult.No) {
e.Cancel = true;
}
}

base.OnClosing(e);
}
}
}
2 changes: 0 additions & 2 deletions PicasaUploader/Utilities/ImageScaler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.IO;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;

namespace PicasaUploader
{
Expand Down

0 comments on commit 39610c1

Please sign in to comment.