diff --git a/.gitignore b/.gitignore index 6ec33288..2acd405a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,46 @@ +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results [Dd]ebug* +[Dd]ebugPublic/ [Rr]elease* +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Visual C++ cache files +ipch/ +*.aps *.ncb -*.suo -*.sdf *.opensdf *.VC.opendb *.VC.db +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + *.tss *.vcproj.*.user *.vcxproj.user @@ -17,3 +52,8 @@ translations/*.mo 3rdparty/expat/win32/bin 3rdparty/expat/win32/tmp packages + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user diff --git a/3rdparty/wxWidgets b/3rdparty/wxWidgets index fc4cfd4b..def0cd59 160000 --- a/3rdparty/wxWidgets +++ b/3rdparty/wxWidgets @@ -1 +1 @@ -Subproject commit fc4cfd4b9b2369d131f7f7b87f3598a4238effbe +Subproject commit def0cd59eaed2b1318ee55a14023834ff301761c diff --git a/WinSparkle-2013.sln b/WinSparkle-2013.sln index 3d101576..a99c81c2 100644 --- a/WinSparkle-2013.sln +++ b/WinSparkle-2013.sln @@ -5,8 +5,8 @@ VisualStudioVersion = 12.0.40629.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinSparkle", "WinSparkle-2013.vcxproj", "{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}" ProjectSection(ProjectDependencies) = postProject - {47B228CB-24FE-5250-B1FC-DFC81D3E69DF} = {47B228CB-24FE-5250-B1FC-DFC81D3E69DF} {499A5238-5AAC-5FD3-8902-819D787108A5} = {499A5238-5AAC-5FD3-8902-819D787108A5} + {47B228CB-24FE-5250-B1FC-DFC81D3E69DF} = {47B228CB-24FE-5250-B1FC-DFC81D3E69DF} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinSparkle_expat", "3rdparty\expat-2013.vcxproj", "{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}" @@ -25,46 +25,81 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{5D6786 packages.config = packages.config EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinSparkleDotNet", "WinSparkleDotNet.csproj", "{2DF76B81-DEEC-4E73-9150-CF10519EE75B}" + ProjectSection(ProjectDependencies) = postProject + {524CCCF2-61EA-5B64-A1D9-FF5497027B5F} = {524CCCF2-61EA-5B64-A1D9-FF5497027B5F} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Win32 = Release|Win32 Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|Win32.ActiveCfg = Debug|Win32 {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|Win32.Build.0 = Debug|Win32 {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|x64.ActiveCfg = Debug|x64 {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|x64.Build.0 = Debug|x64 + {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|x86.ActiveCfg = Debug|Win32 + {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|x86.Build.0 = Debug|Win32 {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|Win32.ActiveCfg = Release|Win32 {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|Win32.Build.0 = Release|Win32 {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|x64.ActiveCfg = Release|x64 {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|x64.Build.0 = Release|x64 + {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|x86.ActiveCfg = Release|Win32 + {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|x86.Build.0 = Release|Win32 {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|Win32.ActiveCfg = Debug|Win32 {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|Win32.Build.0 = Debug|Win32 {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|x64.ActiveCfg = Debug|x64 {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|x64.Build.0 = Debug|x64 + {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|x86.ActiveCfg = Debug|Win32 + {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|x86.Build.0 = Debug|Win32 {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|Win32.ActiveCfg = Release|Win32 {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|Win32.Build.0 = Release|Win32 {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|x64.ActiveCfg = Release|x64 {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|x64.Build.0 = Release|x64 + {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|x86.ActiveCfg = Release|Win32 + {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|x86.Build.0 = Release|Win32 {499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|Win32.ActiveCfg = Debug|Win32 {499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|Win32.Build.0 = Debug|Win32 {499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|x64.ActiveCfg = Debug|x64 {499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|x64.Build.0 = Debug|x64 + {499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|x86.ActiveCfg = Debug|Win32 + {499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|x86.Build.0 = Debug|Win32 {499A5238-5AAC-5FD3-8902-819D787108A5}.Release|Win32.ActiveCfg = Release|Win32 {499A5238-5AAC-5FD3-8902-819D787108A5}.Release|Win32.Build.0 = Release|Win32 {499A5238-5AAC-5FD3-8902-819D787108A5}.Release|x64.ActiveCfg = Release|x64 {499A5238-5AAC-5FD3-8902-819D787108A5}.Release|x64.Build.0 = Release|x64 + {499A5238-5AAC-5FD3-8902-819D787108A5}.Release|x86.ActiveCfg = Release|Win32 + {499A5238-5AAC-5FD3-8902-819D787108A5}.Release|x86.Build.0 = Release|Win32 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|Win32.ActiveCfg = Debug|Win32 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|Win32.Build.0 = Debug|Win32 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|x64.ActiveCfg = Debug|x64 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|x64.Build.0 = Debug|x64 + {AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|x86.ActiveCfg = Debug|Win32 + {AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|x86.Build.0 = Debug|Win32 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|Win32.ActiveCfg = Release|Win32 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|Win32.Build.0 = Release|Win32 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|x64.ActiveCfg = Release|x64 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|x64.Build.0 = Release|x64 + {AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|x86.ActiveCfg = Release|Win32 + {AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|x86.Build.0 = Release|Win32 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Debug|Win32.ActiveCfg = Debug|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Debug|Win32.Build.0 = Debug|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Debug|x64.ActiveCfg = Debug|x64 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Debug|x64.Build.0 = Debug|x64 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Debug|x86.ActiveCfg = Debug|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Debug|x86.Build.0 = Debug|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Release|Win32.ActiveCfg = Release|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Release|Win32.Build.0 = Release|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Release|x64.ActiveCfg = Release|x64 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Release|x64.Build.0 = Release|x64 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Release|x86.ActiveCfg = Release|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/WinSparkle-2015.sln b/WinSparkle-2015.sln index 9355b02c..9bf3b7ac 100644 --- a/WinSparkle-2015.sln +++ b/WinSparkle-2015.sln @@ -5,8 +5,8 @@ VisualStudioVersion = 14.0.25123.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinSparkle", "WinSparkle-2015.vcxproj", "{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}" ProjectSection(ProjectDependencies) = postProject - {47B228CB-24FE-5250-B1FC-DFC81D3E69DF} = {47B228CB-24FE-5250-B1FC-DFC81D3E69DF} {499A5238-5AAC-5FD3-8902-819D787108A5} = {499A5238-5AAC-5FD3-8902-819D787108A5} + {47B228CB-24FE-5250-B1FC-DFC81D3E69DF} = {47B228CB-24FE-5250-B1FC-DFC81D3E69DF} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinSparkle_expat", "3rdparty\expat-2015.vcxproj", "{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}" @@ -20,6 +20,15 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_psdk", "examples\ex EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dependencies", "dependencies", "{2C4E4846-FF11-55AD-AFD1-BC1F3AF74724}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{5D678636-E84E-405E-9899-F2AB26A9D005}" + ProjectSection(SolutionItems) = preProject + .nuget\packages.config = .nuget\packages.config + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinSparkleDotNet", "WinSparkleDotNet.csproj", "{2DF76B81-DEEC-4E73-9150-CF10519EE75B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example_dotnet", "examples\example_dotnet.csproj", "{0F71C954-39A8-4E0D-8677-2FE662B85ED3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -60,6 +69,22 @@ Global {AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|Win32.Build.0 = Release|Win32 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|x64.ActiveCfg = Release|x64 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|x64.Build.0 = Release|x64 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Debug|Win32.ActiveCfg = Debug|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Debug|Win32.Build.0 = Debug|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Debug|x64.ActiveCfg = Debug|x64 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Debug|x64.Build.0 = Debug|x64 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Release|Win32.ActiveCfg = Release|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Release|Win32.Build.0 = Release|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Release|x64.ActiveCfg = Release|x64 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Release|x64.Build.0 = Release|x64 + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Debug|Win32.ActiveCfg = Debug|Any CPU + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Debug|Win32.Build.0 = Debug|Any CPU + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Debug|x64.ActiveCfg = Debug|Any CPU + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Debug|x64.Build.0 = Debug|Any CPU + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Release|Win32.ActiveCfg = Release|Any CPU + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Release|Win32.Build.0 = Release|Any CPU + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Release|x64.ActiveCfg = Release|Any CPU + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/WinSparkleDotNet.csproj b/WinSparkleDotNet.csproj new file mode 100644 index 00000000..2259e294 --- /dev/null +++ b/WinSparkleDotNet.csproj @@ -0,0 +1,66 @@ + + + + + Debug + AnyCPU + {2DF76B81-DEEC-4E73-9150-CF10519EE75B} + Library + src\WinSparkleDotNet\Properties + WinSparkleDotNet + WinSparkleDotNet + v2.0 + 512 + + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + false + false + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + false + + + x64 + bin\x64\Debug\ + TRACE;DEBUG + + + x64 + bin\x64\Release\ + false + true + TRACE + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/example_dotnet.csproj b/examples/example_dotnet.csproj new file mode 100644 index 00000000..0b9adbc9 --- /dev/null +++ b/examples/example_dotnet.csproj @@ -0,0 +1,116 @@ + + + + + Debug + AnyCPU + {0F71C954-39A8-4E0D-8677-2FE662B85ED3} + WinExe + Properties + example_dotnet + example_dotnet + v2.0 + 512 + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + Form + + + WinSparkleDemoForm.cs + + + + + WinSparkleDemoForm.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + + + {2df76b81-deec-4e73-9150-cf10519ee75b} + WinSparkleDotNet + + + + + \ No newline at end of file diff --git a/examples/example_dotnet/App.config b/examples/example_dotnet/App.config new file mode 100644 index 00000000..343984d0 --- /dev/null +++ b/examples/example_dotnet/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/examples/example_dotnet/Program.cs b/examples/example_dotnet/Program.cs new file mode 100644 index 00000000..0b625894 --- /dev/null +++ b/examples/example_dotnet/Program.cs @@ -0,0 +1,19 @@ +using System; +using System.Windows.Forms; + +namespace example_dotnet +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new WinSparkleDemoForm()); + } + } +} diff --git a/examples/example_dotnet/Properties/AssemblyInfo.cs b/examples/example_dotnet/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..fd3039ec --- /dev/null +++ b/examples/example_dotnet/Properties/AssemblyInfo.cs @@ -0,0 +1,39 @@ +using System.Reflection; +using System.Runtime.InteropServices; +using WinSparkleDotNet; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("example_dotnet")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("example_dotnet")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("02dcd2bc-3299-4259-8f6f-a4da2dab3ee7")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] + +//WinSparkle AppCastURL +[assembly: AppCastUrl("http://winsparkle.org/example/appcast.xml")] \ No newline at end of file diff --git a/examples/example_dotnet/Properties/Resources.Designer.cs b/examples/example_dotnet/Properties/Resources.Designer.cs new file mode 100644 index 00000000..b04981d2 --- /dev/null +++ b/examples/example_dotnet/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34209 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace example_dotnet.Properties { + 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", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// 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("example_dotnet.Properties.Resources", typeof(Resources).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; + } + } + } +} diff --git a/examples/example_dotnet/Properties/Resources.resx b/examples/example_dotnet/Properties/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/examples/example_dotnet/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/examples/example_dotnet/Properties/Settings.Designer.cs b/examples/example_dotnet/Properties/Settings.Designer.cs new file mode 100644 index 00000000..54adf70c --- /dev/null +++ b/examples/example_dotnet/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34209 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace example_dotnet.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/examples/example_dotnet/Properties/Settings.settings b/examples/example_dotnet/Properties/Settings.settings new file mode 100644 index 00000000..39645652 --- /dev/null +++ b/examples/example_dotnet/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/examples/example_dotnet/WinSparkleDemoForm.Designer.cs b/examples/example_dotnet/WinSparkleDemoForm.Designer.cs new file mode 100644 index 00000000..a6e6f789 --- /dev/null +++ b/examples/example_dotnet/WinSparkleDemoForm.Designer.cs @@ -0,0 +1,213 @@ +namespace example_dotnet +{ + partial class WinSparkleDemoForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btn_checkUpdate = new System.Windows.Forms.Button(); + this.gp_infos = new System.Windows.Forms.GroupBox(); + this.lbl_appCastUrl = new System.Windows.Forms.Label(); + this.llbl_appCastUrl = new System.Windows.Forms.LinkLabel(); + this.ckb_autoCheckUpdate = new System.Windows.Forms.CheckBox(); + this.lbl_autoCheckUpdate = new System.Windows.Forms.Label(); + this.txtb_updateInterval = new System.Windows.Forms.TextBox(); + this.lbl_updateInterval = new System.Windows.Forms.Label(); + this.txtb_lastChecked = new System.Windows.Forms.TextBox(); + this.lbl_lastChecked = new System.Windows.Forms.Label(); + this.btn_close = new System.Windows.Forms.Button(); + this.btn_checkUpdateAndInstall = new System.Windows.Forms.Button(); + this.btn_checkUpdateNoUI = new System.Windows.Forms.Button(); + this.gp_infos.SuspendLayout(); + this.SuspendLayout(); + // + // btn_checkUpdate + // + this.btn_checkUpdate.Location = new System.Drawing.Point(285, 132); + this.btn_checkUpdate.Name = "btn_checkUpdate"; + this.btn_checkUpdate.Size = new System.Drawing.Size(128, 23); + this.btn_checkUpdate.TabIndex = 0; + this.btn_checkUpdate.Text = "Check Update"; + this.btn_checkUpdate.UseVisualStyleBackColor = true; + this.btn_checkUpdate.Click += new System.EventHandler(this.btn_checkUpdate_Click); + // + // gp_infos + // + this.gp_infos.Controls.Add(this.lbl_appCastUrl); + this.gp_infos.Controls.Add(this.llbl_appCastUrl); + this.gp_infos.Controls.Add(this.ckb_autoCheckUpdate); + this.gp_infos.Controls.Add(this.lbl_autoCheckUpdate); + this.gp_infos.Controls.Add(this.txtb_updateInterval); + this.gp_infos.Controls.Add(this.lbl_updateInterval); + this.gp_infos.Controls.Add(this.txtb_lastChecked); + this.gp_infos.Controls.Add(this.lbl_lastChecked); + this.gp_infos.Location = new System.Drawing.Point(12, 12); + this.gp_infos.Name = "gp_infos"; + this.gp_infos.Size = new System.Drawing.Size(267, 201); + this.gp_infos.TabIndex = 1; + this.gp_infos.TabStop = false; + this.gp_infos.Text = "Infos"; + // + // lbl_appCastUrl + // + this.lbl_appCastUrl.AutoSize = true; + this.lbl_appCastUrl.Location = new System.Drawing.Point(6, 108); + this.lbl_appCastUrl.Name = "lbl_appCastUrl"; + this.lbl_appCastUrl.Size = new System.Drawing.Size(67, 13); + this.lbl_appCastUrl.TabIndex = 8; + this.lbl_appCastUrl.Text = "appcast Url :"; + // + // llbl_appCastUrl + // + this.llbl_appCastUrl.AutoSize = true; + this.llbl_appCastUrl.Location = new System.Drawing.Point(6, 130); + this.llbl_appCastUrl.Name = "llbl_appCastUrl"; + this.llbl_appCastUrl.Size = new System.Drawing.Size(78, 13); + this.llbl_appCastUrl.TabIndex = 7; + this.llbl_appCastUrl.TabStop = true; + this.llbl_appCastUrl.Text = "APPCASTURL"; + // + // ckb_autoCheckUpdate + // + this.ckb_autoCheckUpdate.AutoSize = true; + this.ckb_autoCheckUpdate.Enabled = false; + this.ckb_autoCheckUpdate.Location = new System.Drawing.Point(106, 84); + this.ckb_autoCheckUpdate.Name = "ckb_autoCheckUpdate"; + this.ckb_autoCheckUpdate.Size = new System.Drawing.Size(15, 14); + this.ckb_autoCheckUpdate.TabIndex = 5; + this.ckb_autoCheckUpdate.UseVisualStyleBackColor = true; + // + // lbl_autoCheckUpdate + // + this.lbl_autoCheckUpdate.AutoSize = true; + this.lbl_autoCheckUpdate.Location = new System.Drawing.Point(6, 85); + this.lbl_autoCheckUpdate.Name = "lbl_autoCheckUpdate"; + this.lbl_autoCheckUpdate.Size = new System.Drawing.Size(94, 13); + this.lbl_autoCheckUpdate.TabIndex = 4; + this.lbl_autoCheckUpdate.Text = "Automatic Check :"; + // + // txtb_updateInterval + // + this.txtb_updateInterval.Location = new System.Drawing.Point(90, 58); + this.txtb_updateInterval.Name = "txtb_updateInterval"; + this.txtb_updateInterval.ReadOnly = true; + this.txtb_updateInterval.Size = new System.Drawing.Size(171, 20); + this.txtb_updateInterval.TabIndex = 3; + // + // lbl_updateInterval + // + this.lbl_updateInterval.AutoSize = true; + this.lbl_updateInterval.Location = new System.Drawing.Point(6, 61); + this.lbl_updateInterval.Name = "lbl_updateInterval"; + this.lbl_updateInterval.Size = new System.Drawing.Size(86, 13); + this.lbl_updateInterval.TabIndex = 2; + this.lbl_updateInterval.Text = "Update Interval :"; + // + // txtb_lastChecked + // + this.txtb_lastChecked.Location = new System.Drawing.Point(90, 27); + this.txtb_lastChecked.Name = "txtb_lastChecked"; + this.txtb_lastChecked.ReadOnly = true; + this.txtb_lastChecked.Size = new System.Drawing.Size(171, 20); + this.txtb_lastChecked.TabIndex = 1; + // + // lbl_lastChecked + // + this.lbl_lastChecked.AutoSize = true; + this.lbl_lastChecked.Location = new System.Drawing.Point(6, 30); + this.lbl_lastChecked.Name = "lbl_lastChecked"; + this.lbl_lastChecked.Size = new System.Drawing.Size(78, 13); + this.lbl_lastChecked.TabIndex = 0; + this.lbl_lastChecked.Text = "Last checked :"; + // + // btn_close + // + this.btn_close.Location = new System.Drawing.Point(419, 190); + this.btn_close.Name = "btn_close"; + this.btn_close.Size = new System.Drawing.Size(132, 23); + this.btn_close.TabIndex = 2; + this.btn_close.Text = "Close"; + this.btn_close.UseVisualStyleBackColor = true; + this.btn_close.Click += new System.EventHandler(this.btn_close_Click); + // + // btn_checkUpdateAndInstall + // + this.btn_checkUpdateAndInstall.Location = new System.Drawing.Point(285, 161); + this.btn_checkUpdateAndInstall.Name = "btn_checkUpdateAndInstall"; + this.btn_checkUpdateAndInstall.Size = new System.Drawing.Size(266, 23); + this.btn_checkUpdateAndInstall.TabIndex = 3; + this.btn_checkUpdateAndInstall.Text = "Check Update and Install"; + this.btn_checkUpdateAndInstall.UseVisualStyleBackColor = true; + this.btn_checkUpdateAndInstall.Click += new System.EventHandler(this.btn_checkUpdateAndInstall_Click); + // + // btn_checkUpdateNoUI + // + this.btn_checkUpdateNoUI.Location = new System.Drawing.Point(419, 132); + this.btn_checkUpdateNoUI.Name = "btn_checkUpdateNoUI"; + this.btn_checkUpdateNoUI.Size = new System.Drawing.Size(132, 23); + this.btn_checkUpdateNoUI.TabIndex = 4; + this.btn_checkUpdateNoUI.Text = "Check Update no UI"; + this.btn_checkUpdateNoUI.UseVisualStyleBackColor = true; + this.btn_checkUpdateNoUI.Click += new System.EventHandler(this.btn_checkUpdateNoUI_Click); + // + // WinSparkleDemoForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(563, 225); + this.Controls.Add(this.btn_checkUpdateNoUI); + this.Controls.Add(this.btn_checkUpdateAndInstall); + this.Controls.Add(this.btn_close); + this.Controls.Add(this.gp_infos); + this.Controls.Add(this.btn_checkUpdate); + this.Name = "WinSparkleDemoForm"; + this.Text = "WinSparkle - DotNet - Example"; + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form_FormClosed); + this.Load += new System.EventHandler(this.Form_Load); + this.gp_infos.ResumeLayout(false); + this.gp_infos.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button btn_checkUpdate; + private System.Windows.Forms.GroupBox gp_infos; + private System.Windows.Forms.Label lbl_lastChecked; + private System.Windows.Forms.TextBox txtb_lastChecked; + private System.Windows.Forms.TextBox txtb_updateInterval; + private System.Windows.Forms.Label lbl_updateInterval; + private System.Windows.Forms.Label lbl_autoCheckUpdate; + private System.Windows.Forms.CheckBox ckb_autoCheckUpdate; + private System.Windows.Forms.Label lbl_appCastUrl; + private System.Windows.Forms.LinkLabel llbl_appCastUrl; + private System.Windows.Forms.Button btn_close; + private System.Windows.Forms.Button btn_checkUpdateAndInstall; + private System.Windows.Forms.Button btn_checkUpdateNoUI; + } +} + diff --git a/examples/example_dotnet/WinSparkleDemoForm.cs b/examples/example_dotnet/WinSparkleDemoForm.cs new file mode 100644 index 00000000..19ee4cb4 --- /dev/null +++ b/examples/example_dotnet/WinSparkleDemoForm.cs @@ -0,0 +1,90 @@ +using System; +using System.Windows.Forms; +using WinSparkleDotNet; + +namespace example_dotnet +{ + public partial class WinSparkleDemoForm : Form + { + private readonly WinSparkleNet _sparkleNet; + + public WinSparkleDemoForm() + { + InitializeComponent(); + try + { + _sparkleNet = new WinSparkleNet(); + } + catch (Exception ex) + { + MessageBox.Show(@"Error was : "+ex, @"Error during SparkleNet instantiation", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + //Callback + _sparkleNet.SetErrorCallback(this.ErrorCallback); + _sparkleNet.SetShutdownRequestCallback(this.ShutDownRequestCallback); + //Init + _sparkleNet.Initialize(); + _sparkleNet.CheckForUpdate(); + } + + private void Form_FormClosed(object sender, FormClosedEventArgs e) + { + _sparkleNet.Cleanup(); + } + + private void Form_Load(object sender, System.EventArgs e) + { + txtb_lastChecked.Text = _sparkleNet.LastCheckTime.ToString("dd'/'MM'/'yyyy HH:mm:ss"); + txtb_updateInterval.Text = _sparkleNet.UpdateInterval.Seconds.ToString(); + ckb_autoCheckUpdate.Checked = _sparkleNet.AutomaticCheckForUpdates; + llbl_appCastUrl.Text = _sparkleNet.AppCastUrl; + } + + private void btn_checkUpdate_Click(object sender, System.EventArgs e) + { + _sparkleNet.CheckForUpdate(); + } + + private void btn_checkUpdateNoUI_Click(object sender, EventArgs e) + { + _sparkleNet.CheckForUpdate(false); + } + + private void btn_checkUpdateAndInstall_Click(object sender, EventArgs e) + { + _sparkleNet.CheckForUpdate(true, true); + } + + private void btn_close_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void ErrorCallback() + { + try + { + MessageBox.Show(@"Callback called if WinSparkle get an error.", @"ErrorCallback", + MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ShutDownRequestCallback() + { + try + { + this.BeginInvoke(new MethodInvoker(this.Close)); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/examples/example_dotnet/WinSparkleDemoForm.resx b/examples/example_dotnet/WinSparkleDemoForm.resx new file mode 100644 index 00000000..8e3068fe --- /dev/null +++ b/examples/example_dotnet/WinSparkleDemoForm.resx @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/examples/examples-2013.sln b/examples/examples-2013.sln index bcf29cd7..b9265e9e 100644 --- a/examples/examples-2013.sln +++ b/examples/examples-2013.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 +VisualStudioVersion = 12.0.40629.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_psdk", "example_psdk-2013.vcxproj", "{AFBD6C55-82AB-5746-BABD-D254BE893418}" ProjectSection(ProjectDependencies) = postProject @@ -20,46 +20,102 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinSparkle_wx", "..\3rdpart EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Additional Dependencies", "Additional Dependencies", "{32F8CF2B-4EB9-5BC9-B3B3-A09BB6615135}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example_dotnet", "example_dotnet-2013.csproj", "{0F71C954-39A8-4E0D-8677-2FE662B85ED3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinSparkleDotNet", "..\WinSparkleDotNet-2013.csproj", "{2DF76B81-DEEC-4E73-9150-CF10519EE75B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|Win32.ActiveCfg = Debug|Win32 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|Win32.Build.0 = Debug|Win32 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|x64.ActiveCfg = Debug|x64 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|x64.Build.0 = Debug|x64 + {AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|Any CPU.ActiveCfg = Release|Win32 + {AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|Mixed Platforms.Build.0 = Release|Win32 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|Win32.ActiveCfg = Release|Win32 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|Win32.Build.0 = Release|Win32 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|x64.ActiveCfg = Release|x64 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|x64.Build.0 = Release|x64 + {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|Win32.ActiveCfg = Debug|Win32 {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|Win32.Build.0 = Debug|Win32 {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|x64.ActiveCfg = Debug|x64 {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|x64.Build.0 = Debug|x64 + {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|Any CPU.ActiveCfg = Release|Win32 + {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|Mixed Platforms.Build.0 = Release|Win32 {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|Win32.ActiveCfg = Release|Win32 {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|Win32.Build.0 = Release|Win32 {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|x64.ActiveCfg = Release|x64 {524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|x64.Build.0 = Release|x64 + {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|Win32.ActiveCfg = Debug|Win32 {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|Win32.Build.0 = Debug|Win32 {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|x64.ActiveCfg = Debug|x64 {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|x64.Build.0 = Debug|x64 + {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|Any CPU.ActiveCfg = Release|Win32 + {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|Mixed Platforms.Build.0 = Release|Win32 {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|Win32.ActiveCfg = Release|Win32 {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|Win32.Build.0 = Release|Win32 {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|x64.ActiveCfg = Release|x64 {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|x64.Build.0 = Release|x64 + {499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|Win32.ActiveCfg = Debug|Win32 {499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|Win32.Build.0 = Debug|Win32 {499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|x64.ActiveCfg = Debug|x64 {499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|x64.Build.0 = Debug|x64 + {499A5238-5AAC-5FD3-8902-819D787108A5}.Release|Any CPU.ActiveCfg = Release|Win32 + {499A5238-5AAC-5FD3-8902-819D787108A5}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {499A5238-5AAC-5FD3-8902-819D787108A5}.Release|Mixed Platforms.Build.0 = Release|Win32 {499A5238-5AAC-5FD3-8902-819D787108A5}.Release|Win32.ActiveCfg = Release|Win32 {499A5238-5AAC-5FD3-8902-819D787108A5}.Release|Win32.Build.0 = Release|Win32 {499A5238-5AAC-5FD3-8902-819D787108A5}.Release|x64.ActiveCfg = Release|x64 {499A5238-5AAC-5FD3-8902-819D787108A5}.Release|x64.Build.0 = Release|x64 + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Debug|Win32.ActiveCfg = Debug|Any CPU + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Debug|x64.ActiveCfg = Debug|Any CPU + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Release|Any CPU.Build.0 = Release|Any CPU + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Release|Win32.ActiveCfg = Release|Any CPU + {0F71C954-39A8-4E0D-8677-2FE662B85ED3}.Release|x64.ActiveCfg = Release|Any CPU + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Debug|Any CPU.ActiveCfg = Debug|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Debug|Win32.ActiveCfg = Debug|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Debug|Win32.Build.0 = Debug|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Debug|x64.ActiveCfg = Debug|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Release|Any CPU.ActiveCfg = Release|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Release|Mixed Platforms.Build.0 = Release|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Release|Win32.ActiveCfg = Release|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Release|Win32.Build.0 = Release|x86 + {2DF76B81-DEEC-4E73-9150-CF10519EE75B}.Release|x64.ActiveCfg = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -68,5 +124,6 @@ Global {524CCCF2-61EA-5B64-A1D9-FF5497027B5F} = {32F8CF2B-4EB9-5BC9-B3B3-A09BB6615135} {47B228CB-24FE-5250-B1FC-DFC81D3E69DF} = {32F8CF2B-4EB9-5BC9-B3B3-A09BB6615135} {499A5238-5AAC-5FD3-8902-819D787108A5} = {32F8CF2B-4EB9-5BC9-B3B3-A09BB6615135} + {2DF76B81-DEEC-4E73-9150-CF10519EE75B} = {32F8CF2B-4EB9-5BC9-B3B3-A09BB6615135} EndGlobalSection EndGlobal diff --git a/src/WinSparkleDotNet/Properties/AssemblyInfo.cs b/src/WinSparkleDotNet/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..d1f6f1c6 --- /dev/null +++ b/src/WinSparkleDotNet/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("WinSparkleDotNet")] +[assembly: AssemblyDescription("WinSparkle updates checking library (http://winsparkle.org).")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("winsparkle.org")] +[assembly: AssemblyProduct("WinSparkleDotNet")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("8796d1d7-8a57-43da-832b-4c3455561759")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("0.5.0.0")] +[assembly: AssemblyFileVersion("0.5.0.0")] diff --git a/src/WinSparkleDotNet/WinSparkle.cs b/src/WinSparkleDotNet/WinSparkle.cs new file mode 100644 index 00000000..ab7f837b --- /dev/null +++ b/src/WinSparkleDotNet/WinSparkle.cs @@ -0,0 +1,557 @@ +using System; +using System.Runtime.InteropServices; + +namespace WinSparkleDotNet +{ + /// + /// WinSparkle DLL Wrapper + /// Is a 1-to-1 mapping of the WinSparkle C API with some adjustment. + /// Don't use directly unless you know what you do ! + /// Otherwise use API. + /// + /// + public sealed class WinSparkle + { + /// Get the last check time. + /// + /// The last check time. + /// + /// Can only be called @em before the first call to + public static DateTime LastCheckTime + { + get + { + int time = GetLastCheckTime(); + if (time > 0) + return new System.DateTime(1970, 1, 1).AddSeconds(time); + else + return System.DateTime.MinValue; + } + } + + /// Get or set the update interval. + /// The minimum update interval is 3600 seconds (1 hour). + /// + /// + /// The update interval. + /// + /// Can only be called @em before the first call to + public static TimeSpan UpdateInterval + { + get + { + return TimeSpan.FromSeconds(GetUpdateCheckInterval()); + } + set + { + SetUpdateCheckInterval((int)value.TotalSeconds); + } + } + + /// + /// Get or set a value indicating whether the automatic check for updates. + /// + /// + /// true if automatic check for updates, false if not. + /// + /// Can only be called @em before the first call to + public static bool AutomaticCheckForUpdates + { + get + { + return GetAutomaticCheckForUpdates() != 0; + } + set + { + SetAutomaticCheckForUpdates(value ? 1 : 0); + } + } + +#region DLLWrapping + /// + /// + /// Starts WinSparkle. + /// + /// + /// If WinSparkle is configured to check for updates on startup, proceeds + /// to perform the check. You should only call this function when your app + /// is initialized and shows its main window. + /// + /// + /// + /// This call doesn't block and returns almost immediately. If an + /// update is available, the respective UI is shown later from a separate + /// thread. + /// + /// + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_init", CallingConvention = CallingConvention.Cdecl)] + public static extern void Initialize(); + + /// Cleans up after WinSparkle. + /// Should be called by the app when it's shutting down. Cancels any + /// pending Sparkle operations and shuts down its helper threads. + /// + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_cleanup", CallingConvention = CallingConvention.Cdecl)] + public static extern void Cleanup(); + + /// + /// + /// Sets UI language from its ISO code. + /// + /// + /// + /// This function must be called before + /// + /// ISO 639 language code with an optional ISO 3116 country + /// code, e.g. "fr", "pt-PT", "pt-BR" or "pt_BR" + /// + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_set_lang", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetLanguage( + [param: MarshalAs(UnmanagedType.AnsiBStr)] string lang + ); + + /// + /// + /// Sets URL for the app's appcast. + /// + /// + /// If this function isn't called by the app, the URL is obtained from + /// Windows resource named "FeedURL" of type "APPCAST". + /// + /// + /// + /// Can only be called @em before the first call to + /// + /// URL of the appcast. + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_set_appcast_url", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetAppcastUrl( + [param: MarshalAs(UnmanagedType.AnsiBStr)] string url + ); + + /// + /// + /// Sets application metadata. + /// + /// + /// Normally, these are taken from VERSIONINFO/StringFileInfo resources, + /// but if your application doesn't use them for some reason, using this + /// function is an alternative. + /// + /// + /// + /// + /// + /// and are used to determine + /// the location of WinSparkle settings in registry. + /// + /// + /// Can only be called @em before the first call to + /// + /// + /// + /// Company name of the vendor. + /// Application name. This is both shown to the user + /// and used in HTTP User-Agent header. + /// Version of the app, as string (e.g. "1.2" or "1.2rc1"). + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_set_app_details", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetAppDetails( + [param: MarshalAs(UnmanagedType.LPWStr)] string companyName, + [param: MarshalAs(UnmanagedType.LPWStr)] string appName, + [param: MarshalAs(UnmanagedType.LPWStr)] string appVersion + ); + + /// + /// + /// Sets application build version number. + /// + /// + /// This is the internal version number that is not normally shown to the user. + /// It can be used for finer granularity that official release versions, e.g. for + /// interim builds. + /// + /// + /// If this function is called, then the provided *build* number is used for comparing + /// versions; it is compared to the "version" attribute in the appcast and corresponds + /// to OS X Sparkle's CFBundleVersion handling. If used, then the appcast must + /// also contain the "shortVersionString" attribute with human-readable display + /// version string. The version passed to win_sparkle_set_app_details() + /// corresponds to this and is used for display. + /// + /// + /// + /// + /// + /// Can only be called @em before the first call to + /// + /// + /// + /// The version number. + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_set_app_build_version", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetAppBuildVersion( + [param: MarshalAs(UnmanagedType.LPWStr)] string buildVersion + ); + + /// + /// + /// Set the registry path where settings will be stored. + /// + /// + /// Normally, these are stored in "HKCU\Software\<company_name>\<app_name>\WinSparkle" + /// but if your application needs to store the data elsewhere for + /// some reason, using this function is an alternative. + /// + /// + /// Note that @a path is relative to HKCU/HKLM root and the root is not part of it. + /// + /// + /// + /// + /// SetRegistryPath(@"Software\My App\Updates"); + /// + /// + /// + /// + /// Can only be called @em before the first call to + /// + /// + /// + /// Registry path where settings will be stored. + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_set_registry_path", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetRegistryPath( + [param: MarshalAs(UnmanagedType.LPWStr)] string path + ); + + /// + /// + /// Sets whether updates are checked automatically or only through a manual call. + /// + /// + /// If disabled, win_sparkle_check_update_with_ui() must be used explicitly. + /// + /// + /// + /// + /// + /// Can only be called @em before the first call to + /// + /// + /// + /// 1 to have updates checked automatically, 0 otherwise. + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_set_automatic_check_for_updates", CallingConvention = CallingConvention.Cdecl)] + private static extern void SetAutomaticCheckForUpdates( + [param: MarshalAs(UnmanagedType.I4)] int enableAutomaticUpdates + ); + + /// + /// + /// Gets the automatic update checking state + /// + /// + /// Defaults to 0 when not yet configured (as happens on first start). + /// + /// + /// + /// + /// + /// Can only be called @em before the first call to + /// + /// + /// + /// 1 if updates are set to be checked automatically, 0 otherwise + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_get_automatic_check_for_updates", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I4)] + private static extern int GetAutomaticCheckForUpdates(); + + /// + /// + /// Sets the automatic update interval. + /// + /// + /// + /// + /// + /// Can only be called @em before the first call to + /// + /// + /// + /// The interval in seconds between checks for updates. + /// The minimum update interval is 3600 seconds (1 hour). + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_set_update_check_interval", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] + private static extern void SetUpdateCheckInterval( + [param: MarshalAs(UnmanagedType.I4)] int intervalSeconds + ); + + /// + /// + /// Gets the automatic update interval in seconds. + /// + /// + /// Default value is one day. + /// + /// + /// + /// + /// + /// Can only be called @em before the first call to + /// + /// + /// + /// The update check interval in seconds. + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_get_update_check_interval", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I4)] + private static extern int GetUpdateCheckInterval(); + + /// + /// + /// Gets the time for the last update check. + /// + /// + /// Default value is -1, indicating that the update check has never run. + /// + /// + /// + /// + /// + /// Can only be called @em before the first call to + /// + /// + /// + /// The last check time internal. + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_get_last_check_time", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I4)] + private static extern int GetLastCheckTime(); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void ErrorCallback(); + + /// + /// + /// Set callback to be called when the updater encounters an error. + /// + /// + /// The callback. + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_set_error_callback", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetErrorCallback( + [param: MarshalAs(UnmanagedType.FunctionPtr)] ErrorCallback callback + ); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate bool CanShutdownCallback(); + + /// + /// + /// Set callback for querying the application if it can be closed. + /// + /// + /// This callback will be called to ask the host if it's ready to shut down, + /// before attempting to launch the installer. The callback returns TRUE if + /// the host application can be safely shut down or FALSE if not (e.g. because + /// the user has unsaved documents). + /// + /// + /// + /// + /// + /// Can only be called @em before the first call to + /// + /// + /// There's no guarantee about the thread from which the callback is called, + /// except that it certainly *won't* be called from the app's main thread. + /// Make sure the callback is thread-safe. + /// + /// + /// + /// The callback. + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_set_can_shutdown_callback", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetCanShutdownCallback( + [param: MarshalAs(UnmanagedType.FunctionPtr)] CanShutdownCallback callback + ); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void ShutdownRequestCallback(); + + /// + /// + /// Set callback for shutting down the application. + /// + /// + /// This callback will be called to ask the host to shut down immediately after + /// launching the installer. Its implementation should gracefully terminate the + /// application. + /// + /// + /// It will only be called if the call to the callback set with + /// win_sparkle_set_can_shutdown_callback() returns TRUE. + /// + /// + /// + /// + /// + /// Can only be called @em before the first call to + /// + /// + /// There's no guarantee about the thread from which the callback is called, + /// except that it certainly *won't* be called from the app's main thread. + /// Make sure the callback is thread-safe. + /// + /// + /// + /// The callback. + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_set_shutdown_request_callback", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetShutdownRequestCallback( + [param:MarshalAs(UnmanagedType.FunctionPtr)] ShutdownRequestCallback callback + ); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void DidFindUpdateCallback(); + + /// + /// + /// Set callback to be called when the updater did find an update. + /// + /// + /// This is useful in combination with + /// as it allows you to perform + /// some action after WinSparkle checks for updates. + /// + /// + /// The callback. + /// + /// + /// + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_set_did_find_update_callback", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetDidFindUpdateCallback( + [param: MarshalAs(UnmanagedType.FunctionPtr)] DidFindUpdateCallback callback + ); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void DidNotFindUpdateCallback(); + + /// + /// + /// Set callback to be called when the updater did not find an update. + /// + /// + /// This is useful in combination with + /// as it allows you to perform + /// some action after WinSparkle checks for updates. + /// + /// + /// The callback. + /// + /// + /// + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_set_did_not_find_update_callback", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetDidNotFindUpdateCallback( + [param: MarshalAs(UnmanagedType.FunctionPtr)] DidNotFindUpdateCallback callback + ); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void UpdateCancelledCallback(); + + /// + /// + /// Set callback to be called when the user cancels a download. + /// + /// + /// This is useful in combination with + /// as it allows you to perform + /// some action when the installation is interrupted. + /// + /// + /// The callback. + /// + /// + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_set_update_cancelled_callback", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetUpdateCancelledCallback( + [param: MarshalAs(UnmanagedType.FunctionPtr)] UpdateCancelledCallback callback + ); + + /// + /// + /// Checks if an update is available, showing progress UI to the user. + /// + /// + /// Normally, WinSparkle checks for updates on startup and only shows its UI + /// when it finds an update. If the application disables this behavior, it + /// can hook this function to "Check for updates..." menu item.. + /// + /// + /// When called, background thread is started to check for updates. A small + /// window is shown to let the user know the progress. If no update is found, + /// the user is told so. If there is an update, the usual "update available" + /// window is shown. + /// + /// + /// This function returns immediately. + /// + /// + /// + /// + /// + /// Because this function is intended for manual, user-initiated checks + /// for updates, it ignores "Skip this version" even if the user checked + /// it previously. + /// + /// + /// + /// + /// + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_check_update_with_ui", CallingConvention = CallingConvention.Cdecl)] + public static extern void CheckUpdateWithUI(); + + /// + /// + /// Checks if an update is available, showing progress UI to the user and + /// immediately installing the update if one is available. + /// + /// + /// This is useful for the case when users should almost always use the + /// newest version of your software.When called, WinSparkle will check for + /// updates showing a progress UI to the user. If an update is found the update + /// prompt will be skipped and the update will be installed immediately. + /// + /// + /// + /// + /// + /// If your application expects to do something after checking for updates you + /// may wish to use win_sparkle_set_did_not_find_update_callback() and + /// win_sparkle_set_update_cancelled_callback(). + /// + /// + /// + /// + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_check_update_with_ui_and_install", CallingConvention = CallingConvention.Cdecl)] + public static extern void CheckUpdateWithUIandInstall(); + + /// + /// + /// Checks if an update is available. + /// + /// + /// No progress UI is shown to the user when checking. If an update is + /// available, the usual "update available" window is shown; this function + /// is *not* completely UI-less. + /// + /// + /// Use with caution, it usually makes more sense to use the automatic update + /// checks on interval option or manual check with visible UI. + /// + /// + /// This function returns immediately. + /// + /// + /// + /// + /// + /// This function respects "Skip this version" choice by the user. + /// + /// + /// + /// + [DllImport("WinSparkle.dll", EntryPoint = "win_sparkle_check_update_without_ui", CallingConvention = CallingConvention.Cdecl)] + public static extern void CheckUpdateWithoutUI(); +#endregion + } +} diff --git a/src/WinSparkleDotNet/WinSparkleAttribute.cs b/src/WinSparkleDotNet/WinSparkleAttribute.cs new file mode 100644 index 00000000..10a703a5 --- /dev/null +++ b/src/WinSparkleDotNet/WinSparkleAttribute.cs @@ -0,0 +1,31 @@ +using System; + +namespace WinSparkleDotNet +{ + /// + /// WinSparkleNet custom assembly attribut for storing App Cast URL. + /// + /// + /// [assembly: AppCastUrl("http://winsparkle.org/example/appcast.xml")] + /// + /// + /// + [AttributeUsage(AttributeTargets.Assembly)] + public sealed class AppCastUrlAttribute : Attribute + { + private string _appCastURL; + + public AppCastUrlAttribute(string appCastUrl) + { + _appCastURL = appCastUrl; + } + + /// + /// Gets the App Cast URL from the assembly. + /// + public string AppCastUrl + { + get { return _appCastURL; } + } + } +} diff --git a/src/WinSparkleDotNet/WinSparkleNet.cs b/src/WinSparkleDotNet/WinSparkleNet.cs new file mode 100644 index 00000000..b7648bde --- /dev/null +++ b/src/WinSparkleDotNet/WinSparkleNet.cs @@ -0,0 +1,254 @@ +using System; +using System.Diagnostics; +using System.Reflection; + +namespace WinSparkleDotNet +{ + /// + /// WinSparkle native C# API. + /// + public sealed class WinSparkleNet + { + /// + /// Gets AssemblyName.Name of assembly. + /// + /// + public string Name { get; private set; } + /// + /// Gets AssemblyCompanyAttribute.Company of assembly. + /// + /// + public string Company { get; private set; } + private string _version; + /// + /// Gets or sets the major, minor, build, and revision numbers of the assembly. + /// + /// + public string Version + { + get { return _version; } + set + { + Debug.Assert(!_initialized, "Can't set Version after initialization!"); + _version = value; + WinSparkle.SetAppBuildVersion(value); + } + } + private string _appCastUrl; + /// + /// Gets AppCastUrlAttribute.AppCastUrl of assembly. + /// + /// + public string AppCastUrl + { + get { return _appCastUrl; } + set + { + Debug.Assert(!_initialized, "Can't set AppCastUrl after initialization!"); + _appCastUrl = value; + WinSparkle.SetAppcastUrl(value); + } + } + /// + /// Gets assembly of the process executable in the default application domain. + /// + /// + public Assembly Assembly { get; private set; } + + private bool _initialized = false; + + /// + /// Load data from (Entry) Assembly. + /// + /// + /// + /// + public WinSparkleNet() + { + try + { + Assembly = Assembly.GetEntryAssembly(); + Name = Assembly.GetName().Name; + Company = ((AssemblyCompanyAttribute)Assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0]).Company; + Version = Assembly.GetName().Version.ToString(); + AppCastUrl = ((AppCastUrlAttribute)Assembly.GetCustomAttributes(typeof(AppCastUrlAttribute), false)[0]).AppCastUrl; + } + catch (Exception ex) + { + throw ex; + } + } + + /// + /// Starts WinSparkle, with data get from Assembly. + /// + /// + public void Initialize() + { + WinSparkle.SetAppcastUrl(AppCastUrl); + WinSparkle.SetAppDetails(Company, Name, Version); + WinSparkle.Initialize(); + _initialized = true; + } + + /// + /// Checks if an update is available. + /// + /// With progress UI (default : yes) + /// Installing the update if one is available (default : false) + public void CheckForUpdate(bool withUi = true, bool install = false) + { + if (withUi) + { + if(!install) + WinSparkle.CheckUpdateWithUI(); + else + WinSparkle.CheckUpdateWithUIandInstall(); + } + else + { + WinSparkle.CheckUpdateWithoutUI(); + } + } + + /// + /// Cleans up after WinSparkle. + /// + /// + public void Cleanup() + { + WinSparkle.Cleanup(); + } + + /// + /// Sets UI language from its ISO code. + /// + /// + /// ISO 639 language code with an optional ISO 3116 country + /// code + /// + public void SetLanguage(string language) + { + Debug.Assert(!_initialized, "Can't set Language after initialization!"); + WinSparkle.SetLanguage(language); + } + + /// + /// Set the registry path where settings will be stored. + /// + /// + /// + public void SetRegistryPath(string path) + { + Debug.Assert(!_initialized, "Can't set RegistryPath after initialization!"); + WinSparkle.SetRegistryPath(path); + } + + /// + /// Get the last check time. + /// + /// + public DateTime LastCheckTime + { + get { return WinSparkle.LastCheckTime; } + } + + /// + /// Get or set the update interval. + /// The minimum update interval is 3600 seconds (1 hour). + /// + /// + public TimeSpan UpdateInterval + { + get { return WinSparkle.UpdateInterval; } + set + { + Debug.Assert(!_initialized, "Can't set UpdateInterval after initialization!"); + WinSparkle.UpdateInterval = value; + } + } + + /// + /// Get or set a value indicating whether the automatic check for updates. + /// + /// + public bool AutomaticCheckForUpdates + { + get { return WinSparkle.AutomaticCheckForUpdates; } + set + { + Debug.Assert(!_initialized, "Can't set AutomaticCheckForUpdates after initialization!"); + WinSparkle.AutomaticCheckForUpdates = value; + } + } + + #region Callback + /// + /// Set callback to be called when the updater encounters an error. + /// + /// + /// + public void SetErrorCallback(WinSparkle.ErrorCallback callback) + { + Debug.Assert(!_initialized, "Can't set callback after initialization!"); + WinSparkle.SetErrorCallback(callback); + } + + /// + /// Set callback for querying the application if it can be closed. + /// + /// + /// + public void SetCanShutdownCallback(WinSparkle.CanShutdownCallback callback) + { + Debug.Assert(!_initialized, "Can't set callback after initialization!"); + WinSparkle.SetCanShutdownCallback(callback); + } + + /// + /// Set callback for shutting down the application. + /// + /// + /// + public void SetShutdownRequestCallback(WinSparkle.ShutdownRequestCallback callback) + { + Debug.Assert(!_initialized, "Can't set callback after initialization!"); + WinSparkle.SetShutdownRequestCallback(callback); + } + + /// + /// Set callback to be called when the updater did find an update. + /// + /// + /// + public void SetDidFindUpdateCallback(WinSparkle.DidFindUpdateCallback callback) + { + Debug.Assert(!_initialized, "Can't set callback after initialization!"); + WinSparkle.SetDidFindUpdateCallback(callback); + } + + /// + /// Set callback to be called when the updater did not find an update. + /// + /// + /// + public void SetDidNotFindUpdateCallback(WinSparkle.DidNotFindUpdateCallback callback) + { + Debug.Assert(!_initialized, "Can't set callback after initialization!"); + WinSparkle.SetDidNotFindUpdateCallback(callback); + } + + /// + /// Set callback to be called when the user cancels a download. + /// + /// + /// + public void SetUpdateCancelledCallback(WinSparkle.UpdateCancelledCallback callback) + { + Debug.Assert(!_initialized, "Can't set callback after initialization!"); + WinSparkle.SetUpdateCancelledCallback(callback); + } + #endregion + + } +}