Skip to content

Commit

Permalink
Removed CurrentCulture field.
Browse files Browse the repository at this point in the history
  • Loading branch information
ravibpatel committed Nov 16, 2017
1 parent 1659809 commit f726215
Show file tree
Hide file tree
Showing 16 changed files with 122 additions and 120 deletions.
49 changes: 9 additions & 40 deletions AutoUpdater.NET/AutoUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@ public static class AutoUpdater
/// Opens the download url in default browser if true. Very usefull if you have portable application.
/// </summary>
public static bool OpenDownloadPage;

/// <summary>
/// Sets the current culture of the auto update notification window. Set this value if your application supports
/// functionalty to change the languge of the application.
/// </summary>
public static CultureInfo CurrentCulture;

/// <summary>
/// If this is true users can see the skip button.
Expand Down Expand Up @@ -117,11 +111,6 @@ public static class AutoUpdater
/// </summary>
public static RemindLaterFormat RemindLaterTimeSpan = RemindLaterFormat.Days;

/// <summary>
/// Make process DPI aware so the forms will scale properly on High DPI display. This option affects whole process so it will make your application forms DPI aware too. You should only set this to true if you are calling this from unmanaged application.
/// </summary>
public static bool SetProcessDPIAwareness = false;

/// <summary>
/// A delegate type to handle how to exit the application after update is downloaded.
/// </summary>
Expand Down Expand Up @@ -174,11 +163,6 @@ public static void Start(String appCast, Assembly myAssembly = null)
{
Running = true;

if (CurrentCulture == null)
{
CurrentCulture = CultureInfo.CurrentCulture;
}

AppCastURL = appCast;

IsWinFormsApplication = Application.MessageLoop;
Expand Down Expand Up @@ -214,15 +198,18 @@ private static void BackgroundWorkerOnRunWorkerCompleted(object sender, RunWorke
{
if (args.IsUpdateAvailable)
{
Application.EnableVisualStyles();
if (!IsWinFormsApplication)
{
Application.EnableVisualStyles();
}
if (Thread.CurrentThread.GetApartmentState().Equals(ApartmentState.STA))
{
ShowUpdateForm();
}
else
{
Thread thread = new Thread(ShowUpdateForm);
thread.CurrentCulture = thread.CurrentUICulture = CurrentCulture;
thread.CurrentCulture = thread.CurrentUICulture = CultureInfo.CurrentCulture;
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
}
Expand Down Expand Up @@ -371,8 +358,11 @@ private static void BackgroundWorkerDoWork(object sender, DoWorkEventArgs e)

if (args.CurrentVersion == null || string.IsNullOrEmpty(args.DownloadURL))
{
Debug.WriteLine("AppCast file has incorrect data.");
webResponse.Close();
if (ReportErrors)
{
throw new InvalidDataException();
}
return;
}

Expand Down Expand Up @@ -553,27 +543,6 @@ public static bool DownloadUpdate()
}
return false;
}

internal static void UseSystemFont(Form form)
{
form.Font = SystemFonts.MessageBoxFont;
SetFont(form.Controls);
}

private static void SetFont(IEnumerable controls)
{
foreach (Control control in controls)
{
var font = new Font(SystemFonts.MessageBoxFont.FontFamily, control.Font.SizeInPoints, control.Font.Style,
GraphicsUnit.Point);
control.Font = font;
if (control.HasChildren)
{
SetFont(control.Controls);
}
}
}

}

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion AutoUpdater.NET/DownloadUpdateDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ internal partial class DownloadUpdateDialog : Form
public DownloadUpdateDialog(string downloadURL)
{
InitializeComponent();
AutoUpdater.UseSystemFont(this);

_downloadURL = downloadURL;
}
Expand Down
6 changes: 3 additions & 3 deletions AutoUpdater.NET/DownloadUpdateDialog.resx
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@
<value>2</value>
</data>
<data name="progressBar.Location" type="System.Drawing.Point, System.Drawing">
<value>84, 45</value>
<value>81, 45</value>
</data>
<data name="progressBar.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 4, 4, 4</value>
</data>
<data name="progressBar.Size" type="System.Drawing.Size, System.Drawing">
<value>316, 26</value>
<value>319, 26</value>
</data>
<data name="progressBar.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
Expand All @@ -178,7 +178,7 @@
<value>Segoe UI, 9pt</value>
</data>
<data name="labelInformation.Location" type="System.Drawing.Point, System.Drawing">
<value>81, 26</value>
<value>78, 14</value>
</data>
<data name="labelInformation.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 0, 4, 0</value>
Expand Down
2 changes: 0 additions & 2 deletions AutoUpdater.NET/RemindLaterForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ internal partial class RemindLaterForm : Form

public RemindLaterForm()
{
AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
InitializeComponent();
AutoUpdater.UseSystemFont(this);
}

private void RemindLaterFormLoad(object sender, EventArgs e)
Expand Down
Binary file modified AutoUpdater.NET/Resources/ZipExtractor.exe
Binary file not shown.
15 changes: 0 additions & 15 deletions AutoUpdater.NET/UpdateForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,9 @@ internal partial class UpdateForm : Form
{
private bool HideReleaseNotes { get; set; }

[DllImport("shcore.dll")]
internal static extern int SetProcessDpiAwareness(Process_DPI_Awareness value);

internal enum Process_DPI_Awareness
{
Process_DPI_Unaware = 0,
Process_System_DPI_Aware = 1,
Process_Per_Monitor_DPI_Aware = 2
}

public UpdateForm()
{
if (AutoUpdater.SetProcessDPIAwareness)
{
SetProcessDpiAwareness(Process_DPI_Awareness.Process_System_DPI_Aware);
}
InitializeComponent();
AutoUpdater.UseSystemFont(this);
UseLatestIE();
buttonSkip.Visible = AutoUpdater.ShowSkipButton;
buttonRemindLater.Visible = AutoUpdater.ShowRemindLaterButton;
Expand Down
4 changes: 4 additions & 0 deletions AutoUpdaterTest/AutoUpdaterTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
Expand Down Expand Up @@ -67,6 +70,7 @@
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="app.manifest" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
Expand Down
14 changes: 8 additions & 6 deletions AutoUpdaterTest/FormMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions AutoUpdaterTest/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ public FormMain()

private void FormMain_Load(object sender, EventArgs e)
{
AutoUpdater.SetProcessDPIAwareness = true;
//Uncomment below lines to handle parsing logic of non XML AppCast file.

//AutoUpdater.Start("http://rbsoft.org/updates/AutoUpdaterTest.json");
//AutoUpdater.ParseUpdateInfoEvent += AutoUpdaterOnParseUpdateInfoEvent;

//Uncomment below line to see russian version

//AutoUpdater.CurrentCulture = CultureInfo.CreateSpecificCulture("ru");
//Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("ru");

//If you want to open download page when user click on download button uncomment below line.

Expand Down
4 changes: 2 additions & 2 deletions AutoUpdaterTest/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
// 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.4.3.0")]
[assembly: AssemblyFileVersion("1.4.3.0")]
[assembly: AssemblyVersion("1.4.4.0")]
[assembly: AssemblyFileVersion("1.4.4.0")]
[assembly: NeutralResourcesLanguageAttribute("en")]
75 changes: 75 additions & 0 deletions AutoUpdaterTest/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on and is
is designed to work with. Uncomment the appropriate elements and Windows will
automatically selected the most compatible environment. -->

<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->

<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->

<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->

<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->

<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->

</application>
</compatibility>

<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->

<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>

<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->

</assembly>
3 changes: 1 addition & 2 deletions AutoUpdaterTestWPF/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Globalization;
using System.Reflection;
using System.Threading;
using System.Timers;
using System.Windows;
using System.Windows.Threading;
using AutoUpdaterDotNET;
Expand All @@ -19,7 +18,7 @@ public MainWindow()
InitializeComponent();
Assembly assembly = Assembly.GetEntryAssembly();
LabelVersion.Content = $"Current Version : {assembly.GetName().Version}";
AutoUpdater.CurrentCulture = new CultureInfo("fr-FR");
Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("fr");
AutoUpdater.LetUserSelectRemindLater = true;
AutoUpdater.RemindLaterTimeSpan = RemindLaterFormat.Minutes;
AutoUpdater.RemindLaterAt = 1;
Expand Down
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ Start method of AutoUpdater class takes URL of the XML file you uploaded to serv
AutoUpdater.Start should be called from UI thread.

## Configuration Options
### Change Language

You can change of language of the update dialog by adding following line with the above code. If you don't do this it will use current culture of your application.

````csharp
AutoUpdater.CurrentCulture = CultureInfo.CreateSpecificCulture("ru");
````

In above example AutoUpdater.NET will show update dialog in russian language.

### Disable Skip Button

If you don't want to show Skip button on Update form then just add following line with above code.
Expand Down
Loading

0 comments on commit f726215

Please sign in to comment.