diff --git a/AutoUpdater.NET/AutoUpdater.cs b/AutoUpdater.NET/AutoUpdater.cs index 50c57bc5..c620353f 100644 --- a/AutoUpdater.NET/AutoUpdater.cs +++ b/AutoUpdater.NET/AutoUpdater.cs @@ -1,6 +1,7 @@ using System; using System.ComponentModel; using System.Diagnostics; +using System.Drawing; using System.Globalization; using System.IO; using System.Net; @@ -149,6 +150,11 @@ public static class AutoUpdater /// public static string HttpUserAgent; + /// + /// Set this to change the icon shown on updater dialog. + /// + public static Bitmap Icon; + /// /// If you are using a zip file as an update file then you can set this value to path where your app is installed. This /// is only necessary when your installation directory differs from your executable path. @@ -224,14 +230,14 @@ public static class AutoUpdater public static bool Synchronous = false; /// - /// Set if you want the default update form to have a different size. + /// Modify TopMost property of all dialogs. /// - public static Size? UpdateFormSize = null; + public static bool TopMost = false; /// - /// Set this to modify TopMost property of all dialogs. + /// Set this if you want the default update form to have a different size. /// - public static bool TopMost = false; + public static Size? UpdateFormSize = null; /// /// Set this to any of the available modes to change behaviour of the Mandatory flag. diff --git a/AutoUpdater.NET/DownloadUpdateDialog.cs b/AutoUpdater.NET/DownloadUpdateDialog.cs index 5ec41c40..2507b2fc 100644 --- a/AutoUpdater.NET/DownloadUpdateDialog.cs +++ b/AutoUpdater.NET/DownloadUpdateDialog.cs @@ -2,6 +2,7 @@ using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; +using System.Drawing; using System.Globalization; using System.IO; using System.Linq; @@ -28,6 +29,11 @@ public DownloadUpdateDialog(UpdateInfoEventArgs args) InitializeComponent(); TopMost = AutoUpdater.TopMost; + if (AutoUpdater.Icon != null) + { + Icon = Icon.FromHandle(AutoUpdater.Icon.GetHicon()); + } + _args = args; if (AutoUpdater.Mandatory && AutoUpdater.UpdateMode == Mode.ForcedDownload) diff --git a/AutoUpdater.NET/Resources/clock_go1.png b/AutoUpdater.NET/Resources/clock_go1.png deleted file mode 100644 index ae4c9d97..00000000 Binary files a/AutoUpdater.NET/Resources/clock_go1.png and /dev/null differ diff --git a/AutoUpdater.NET/Resources/download1.png b/AutoUpdater.NET/Resources/download1.png deleted file mode 100644 index e3e03772..00000000 Binary files a/AutoUpdater.NET/Resources/download1.png and /dev/null differ diff --git a/AutoUpdater.NET/UpdateForm.cs b/AutoUpdater.NET/UpdateForm.cs index 1d0bdc77..7da349f5 100644 --- a/AutoUpdater.NET/UpdateForm.cs +++ b/AutoUpdater.NET/UpdateForm.cs @@ -21,6 +21,13 @@ public UpdateForm(UpdateInfoEventArgs args) InitializeComponent(); InitializeBrowserControl(); TopMost = AutoUpdater.TopMost; + + if (AutoUpdater.Icon != null) + { + pictureBoxIcon.Image = AutoUpdater.Icon; + Icon = Icon.FromHandle(AutoUpdater.Icon.GetHicon()); + } + buttonSkip.Visible = AutoUpdater.ShowSkipButton; buttonRemindLater.Visible = AutoUpdater.ShowRemindLaterButton; var resources = new ComponentResourceManager(typeof(UpdateForm)); diff --git a/AutoUpdaterTest/AutoUpdaterTest.csproj b/AutoUpdaterTest/AutoUpdaterTest.csproj index d5b76dea..7cef3fa1 100644 --- a/AutoUpdaterTest/AutoUpdaterTest.csproj +++ b/AutoUpdaterTest/AutoUpdaterTest.csproj @@ -17,4 +17,23 @@ + + + + + + + True + True + Resource.resx + + + + + + ResXFileCodeGenerator + Resource.Designer.cs + + + diff --git a/AutoUpdaterTest/MainWindow.xaml b/AutoUpdaterTest/MainWindow.xaml index 4bd223d2..f4c8e8da 100644 --- a/AutoUpdaterTest/MainWindow.xaml +++ b/AutoUpdaterTest/MainWindow.xaml @@ -5,7 +5,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" Topmost="True" - Title="MainWindow" Height="200" Width="400" ResizeMode="NoResize"> + Title="MainWindow" Height="200" Width="400" ResizeMode="NoResize" Icon="/Resources/icon.png"> diff --git a/AutoUpdaterTest/MainWindow.xaml.cs b/AutoUpdaterTest/MainWindow.xaml.cs index a8bac535..4e3e35ff 100644 --- a/AutoUpdaterTest/MainWindow.xaml.cs +++ b/AutoUpdaterTest/MainWindow.xaml.cs @@ -193,10 +193,13 @@ private void ButtonCheckForUpdate_Click(object sender, RoutedEventArgs e) // Uncomment following line to set this window as owner of the all dialogs initiated by AutoUpdater. AutoUpdater.SetOwner(this); - + // Uncomment following line to set TopMost to true for all updater dialogs. It is necessary to do this if TopMost is set to true in your form or window. AutoUpdater.TopMost = true; + // Uncomment following line to change the Icon shown on the updater dialog. + AutoUpdater.Icon = Resource.Icon; + AutoUpdater.Start("https://rbsoft.org/updates/AutoUpdaterTest.xml"); } } \ No newline at end of file diff --git a/AutoUpdaterTest/Resource.Designer.cs b/AutoUpdaterTest/Resource.Designer.cs new file mode 100644 index 00000000..3b31b77f --- /dev/null +++ b/AutoUpdaterTest/Resource.Designer.cs @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AutoUpdaterTest { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resource { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resource() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AutoUpdaterTest.Resource", typeof(Resource).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Icon { + get { + object obj = ResourceManager.GetObject("Icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/AutoUpdaterTest/Resource.resx b/AutoUpdaterTest/Resource.resx new file mode 100644 index 00000000..bf39e012 --- /dev/null +++ b/AutoUpdaterTest/Resource.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + + Resources\icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b03f5f7f11d50a3a + + + \ No newline at end of file diff --git a/AutoUpdaterTest/Resources/icon.png b/AutoUpdaterTest/Resources/icon.png new file mode 100644 index 00000000..2fe5971d Binary files /dev/null and b/AutoUpdaterTest/Resources/icon.png differ diff --git a/README.md b/README.md index 700d6191..3d4f7916 100644 --- a/README.md +++ b/README.md @@ -325,6 +325,15 @@ You can specify the size of the update form by using below code. AutoUpdater.UpdateFormSize = new System.Drawing.Size(800, 600); ```` +### Change Icon of the UpdateForm + +You can change the icon of the update form by using below code. It assumes that you have an image resource named Icon in +your project. Size of icon file should be 64x64. + +````csharp +AutoUpdater.Icon = Resources.Icon; +```` + ### Set the owner Form / Window To ensure the dialogs showed by the auto updater are visible and always focussed correctly related to an application @@ -337,7 +346,8 @@ AutoUpdater.SetOwner(yourMainFormOrWpfWindow); ### Set the TopMost property of all updater dialogs -To ensure that the dialogs displayed by the auto updater are always on top, you can set the "TopMost" to true, as demonstrated in the code snippet below. +To ensure that the dialogs displayed by the auto updater are always on top, you can set the "TopMost" to true, as +demonstrated in the code snippet below. ````csharp AutoUpdater.TopMost = true;