Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added reset button to application preferences dialog. Button is only …

…active when contents of dialog doesn't match the defaults.
  • Loading branch information...
commit 33525d6c04597a5fd8d7041067006991a059ac06 1 parent f5ff2d2
@wyldphyre wyldphyre authored
View
1  Changelog.txt
@@ -1,3 +1,4 @@
+- Added reset button to applications preferences dialog. (Craig Reynolds)
- Add feedback dialog.
- Refactor 80% of strings to resources.
- Prototype uninstall functionality.
View
8 src/Preferences.cs
@@ -77,6 +77,14 @@ public static Configuration AppConfigSettings
}
/// <summary>
+ /// The loaded application default settings
+ /// </summary>
+ public static Dictionary<string, string> Defaults
+ {
+ get { return defaults; }
+ }
+
+ /// <summary>
/// Preferred location to search for alternate downloads.
/// </summary>
public static string AlternateDownloadLocation
View
15 src/PreferencesDialog.Designer.cs
@@ -49,6 +49,7 @@ private void InitializeComponent()
this.extractToButton = new System.Windows.Forms.Button();
this.extractTo = new System.Windows.Forms.TextBox();
this.extractToDialog = new System.Windows.Forms.FolderBrowserDialog();
+ this.resetButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// okButton
@@ -90,6 +91,7 @@ private void InitializeComponent()
this.downloadTo.Name = "downloadTo";
this.downloadTo.Size = new System.Drawing.Size(259, 20);
this.downloadTo.TabIndex = 3;
+ this.downloadTo.TextChanged += new System.EventHandler(this.downloadTo_TextChanged);
//
// downloadToButton
//
@@ -130,6 +132,17 @@ private void InitializeComponent()
this.extractTo.Name = "extractTo";
this.extractTo.Size = new System.Drawing.Size(259, 20);
this.extractTo.TabIndex = 6;
+ this.extractTo.TextChanged += new System.EventHandler(this.extractTo_TextChanged);
+ //
+ // resetButton
+ //
+ this.resetButton.Location = new System.Drawing.Point(15, 127);
+ this.resetButton.Name = "resetButton";
+ this.resetButton.Size = new System.Drawing.Size(75, 23);
+ this.resetButton.TabIndex = 10;
+ this.resetButton.Text = "Reset";
+ this.resetButton.UseVisualStyleBackColor = true;
+ this.resetButton.Click += new System.EventHandler(this.resetButton_Click);
//
// PreferencesDialog
//
@@ -138,6 +151,7 @@ private void InitializeComponent()
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.cancelButton;
this.ClientSize = new System.Drawing.Size(367, 162);
+ this.Controls.Add(this.resetButton);
this.Controls.Add(this.extractToButton);
this.Controls.Add(this.extractTo);
this.Controls.Add(this.label2);
@@ -173,5 +187,6 @@ private void InitializeComponent()
private System.Windows.Forms.Button extractToButton;
private System.Windows.Forms.TextBox extractTo;
private System.Windows.Forms.FolderBrowserDialog extractToDialog;
+ private System.Windows.Forms.Button resetButton;
}
}
View
32 src/PreferencesDialog.cs
@@ -17,6 +17,8 @@
using System.Text;
using System.Windows.Forms;
+using InstallPad.Properties;
+
namespace InstallPad
{
public partial class PreferencesDialog : Form
@@ -24,6 +26,8 @@ public partial class PreferencesDialog : Form
// Could bind the controls to a preference value... meh.
// http://msdn2.microsoft.com/en-us/library/system.windows.forms.binding.aspx
+ private Dictionary<string, string> defaults = null;
+
public PreferencesDialog()
{
InitializeComponent();
@@ -44,7 +48,9 @@ private void SavePreferences()
private void PreferencesDialog_Load(object sender, EventArgs e)
{
-
+ //populate defaults to avoid regenerating them each time they are referenced.
+ defaults = InstallPadApp.Preferences.Defaults;
+
this.downloadTo.Text = InstallPadApp.Preferences.DownloadTo;
this.extractTo.Text = InstallPadApp.Preferences.InstallationRoot;
}
@@ -74,5 +80,29 @@ private void okButton_Click(object sender, EventArgs e)
this.DialogResult = DialogResult.OK;
this.Close();
}
+
+ private void resetButton_Click(object sender, EventArgs e)
+ {
+ extractTo.Text = InstallPadApp.Preferences.Defaults[Resources.InstallationRoot];
+ downloadTo.Text = InstallPadApp.Preferences.Defaults[Resources.DownloadTo];
+ }
+
+ public override void Refresh()
+ {
+ base.Refresh();
+
+ resetButton.Enabled = (extractTo.Text != defaults[Resources.InstallationRoot]) ||
+ (downloadTo.Text != defaults[Resources.DownloadTo]);
+ }
+
+ private void extractTo_TextChanged(object sender, EventArgs e)
+ {
+ Refresh();
+ }
+
+ private void downloadTo_TextChanged(object sender, EventArgs e)
+ {
+ Refresh();
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.