Permalink
Browse files

Added option to toggle an application items check status by clicking …

…on the application title in the list. Refactored 'Checked' to be 'CheckedByDefault' in several places, to more accurately represent the data being manipulated. Also added a Toggled() event to the ApplicationListItem, so that the application can detect when a user has toggled the status of an ApplicationListItem.
  • Loading branch information...
1 parent f08b627 commit 1e49d313a33f50d94de481db0502759026bbbd45 @wyldphyre wyldphyre committed Jan 28, 2007
View
1 Changelog.txt
@@ -1,3 +1,4 @@
+- Application item check status can now be toggled by clicking the title of the application in the list. Also refactored 'Checked' to be 'CheckedByDefault'. (Craig Reynolds)
- Added reset button to applications preferences dialog. (Craig Reynolds)
- Add feedback dialog.
- Refactor 80% of strings to resources.
View
9 Properties/Resources.Designer.cs
@@ -220,6 +220,15 @@ internal class Resources {
}
}
+ /// <summary>
+ /// Looks up a localized string similar to CheckedByDefault.
+ /// </summary>
+ internal static string CheckedByDefault {
+ get {
+ return ResourceManager.GetString("CheckedByDefault", resourceCulture);
+ }
+ }
+
internal static System.Drawing.Bitmap close {
get {
object obj = ResourceManager.GetObject("close", resourceCulture);
View
4 Properties/Resources.resx
@@ -592,6 +592,7 @@ The terms "reproduce," "reproduction" and "distribution" have the same meaning h
</data>
<data name="Checked" xml:space="preserve">
<value>Checked</value>
+ <comment>Legacy. Replaced by CheckedByDefault</comment>
</data>
<data name="AppListXmlUnknown" xml:space="preserve">
<value>Unrecognized application option</value>
@@ -692,4 +693,7 @@ The terms "reproduce," "reproduction" and "distribution" have the same meaning h
kSO/rNlXxbx+51o8pG8mBtQjDPvOFblYpzcdCfXZ/gAKmYl1lexrIwAAAABJRU5ErkJggg==
</value>
</data>
+ <data name="CheckedByDefault" xml:space="preserve">
+ <value>CheckedByDefault</value>
+ </data>
</root>
View
6 src/ApplicationDialog.cs
@@ -43,7 +43,7 @@ public ApplicationDialog(ApplicationItem item)
this.SilentInstall = item.Options.SilentInstall;
this.InstallerArguments = item.Options.InstallerArguments;
this.Comment = item.Comment;
- this.Checked = item.Options.Checked ;
+ this.CheckedByDefault = item.Options.CheckedByDefault;
this.InstallationRoot = item.Options.InstallationRoot;
// if no app specific installation root, default to applist.installationroot.
@@ -156,7 +156,7 @@ public string Comment
this.appCommentBox.Text = value;
}
}
- public bool Checked
+ public bool CheckedByDefault
{
get
{
@@ -247,7 +247,7 @@ public void ModifyApplicationItemFromDialog(ApplicationItem item)
item.Options.DownloadLatestVersion = this.DownloadLatestVersion;
item.Options.SilentInstall = this.SilentInstall;
item.Options.InstallerArguments = this.InstallerArguments;
- item.Options.Checked = this.Checked;
+ item.Options.CheckedByDefault = this.CheckedByDefault;
item.DetectVersion();
View
22 src/ApplicationItemOptions.cs
@@ -74,6 +74,18 @@ public static ApplicationItemOptions FromXml(XmlReader reader)
}
}
else if (reader.Name == Resources.Checked)
+ {//Legacy. Replaced by CheckedByDefault
+ bool value = true;
+ try
+ {
+ value = bool.Parse(reader.ReadString());
+ }
+ catch (Exception)
+ {
+ }
+ options.CheckedByDefault = value;
+ }
+ else if (reader.Name == Resources.CheckedByDefault)
{
bool value = true;
try
@@ -83,7 +95,7 @@ public static ApplicationItemOptions FromXml(XmlReader reader)
catch (Exception)
{
}
- options.Checked = value;
+ options.CheckedByDefault = value;
}
else
options.XmlErrors.Add(String.Format("{0}: \"{1}\"", Resources.AppListXmlUnknown, reader.Name));
@@ -103,7 +115,7 @@ public void WriteXml(XmlWriter writer)
// Only write if there is an option set. This could be more elegant.
if ((InstallerArguments != null && InstallerArguments.Length > 0) ||
(PostInstallScript != null && PostInstallScript.Length > 0) ||
- this.SilentInstall || this.DownloadLatestVersion || !this.Checked)
+ this.SilentInstall || this.DownloadLatestVersion || !this.CheckedByDefault)
{
writer.WriteStartElement(Resources.Options);
@@ -123,8 +135,8 @@ public void WriteXml(XmlWriter writer)
if (s.Length > 0)
writer.WriteElementString(Resources.AlternateFileUrl, s);
}
- if (Checked == false)
- writer.WriteElementString(Resources.Checked, Resources.BooleanFalse);
+ if (CheckedByDefault == false)
+ writer.WriteElementString(Resources.CheckedByDefault, Resources.BooleanFalse);
writer.WriteEndElement();
}
@@ -136,7 +148,7 @@ public void WriteXml(XmlWriter writer)
/// </summary>
private bool checkEnabled = true;
- public bool Checked
+ public bool CheckedByDefault
{
get { return checkEnabled; }
set { checkEnabled = value; }
View
36 src/ApplicationListItem.cs
@@ -72,6 +72,8 @@ public ApplicationItem ApplicationItem
}
#endregion
+ public event ToggleEventHandler Toggled;
+
#region Construction
// This should never get called, it's just for the designer
private ApplicationListItem()
@@ -98,9 +100,8 @@ public ApplicationListItem(ApplicationItem application)
downloader.ProgressChanged += new DownloadProgressHandler(downloader_ProgressChanged);
downloader.DownloadComplete += new EventHandler(downloader_DownloadComplete);
- this.Checked = this.ApplicationItem.Options.Checked;
-
- // this.labelName.MouseClick += new MouseEventHandler(ClickHandler);
+ this.Checked = this.ApplicationItem.Options.CheckedByDefault;
+ this.labelName.MouseClick += new MouseEventHandler(labelName_MouseClick);
}
/// <summary>
@@ -132,6 +133,14 @@ private void AddErrorBoxes()
}
#endregion
+ void labelName_MouseClick(object sender, MouseEventArgs e)
+ {
+ checkboxEnabled.Checked = !checkboxEnabled.Checked;
+
+ if (Toggled != null)
+ Toggled(this, new ToggleEventArgs(this.checkboxEnabled.Checked));
+ }
+
private void SetState(InstallState state)
{
this.state = state;
@@ -328,4 +337,25 @@ private static long InKilobytes(long bytes)
return (bytes < 1000) ? 0 : bytes / 1000;
}
}
+
+ /// <summary>
+ /// Provides event arguments for the Toggled event on an ApplicationListItem
+ /// </summary>
+ public class ToggleEventArgs : EventArgs
+ {
+ private bool active;
+
+ public ToggleEventArgs(bool active)
+ {
+ this.active = active;
+ }
+
+ public bool Active
+ {
+ get { return active; }
+ set { active = value; }
+ }
+ }
+
+ public delegate void ToggleEventHandler(Object sender, ToggleEventArgs e);
}

0 comments on commit 1e49d31

Please sign in to comment.