-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from alexhauser/installer_localization
Installer localization
- Loading branch information
Showing
13 changed files
with
506 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 36 additions & 15 deletions
51
SQRLPlatformAwareInstaller/ViewModels/InstallationCompleteViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,72 @@ | ||
using Avalonia; | ||
using ReactiveUI; | ||
using System; | ||
using System.Collections.Generic; | ||
using ReactiveUI; | ||
using System.Diagnostics; | ||
using System.Text; | ||
|
||
namespace SQRLPlatformAwareInstaller.ViewModels | ||
{ | ||
/// <summary> | ||
/// A view model representing the final confirmation screen | ||
/// of the SQRL installer. | ||
/// </summary> | ||
public class InstallationCompleteViewModel: ViewModelBase | ||
{ | ||
private string installPath = ""; | ||
private string _installPath = ""; | ||
private bool _launchOnFinish = true; | ||
|
||
|
||
private bool _LaunchOnFinish = true; | ||
/// <summary> | ||
/// Gets or sets whether the SQRL client should be launched | ||
/// when the dialog is closed using the "finish" button. | ||
/// </summary> | ||
public bool LaunchOnFinish | ||
{ | ||
get { return _LaunchOnFinish; } | ||
set { this.RaiseAndSetIfChanged(ref _LaunchOnFinish, value); } | ||
get { return _launchOnFinish; } | ||
set { this.RaiseAndSetIfChanged(ref _launchOnFinish, value); } | ||
|
||
} | ||
|
||
/// <summary> | ||
/// Creates a new instance and initializes things. | ||
/// </summary> | ||
public InstallationCompleteViewModel() | ||
{ | ||
this.Title = "SQRL Client Installer - Installation Complete"; | ||
Init(); | ||
} | ||
|
||
public InstallationCompleteViewModel(string installPath) | ||
{ | ||
this.installPath = installPath; | ||
this.Title = "SQRL Client Installer - Installation Complete"; | ||
this._installPath = installPath; | ||
Init(); | ||
} | ||
|
||
/// <summary> | ||
/// Performs some common initialization like setting the dialog title etc. | ||
/// </summary> | ||
private void Init() | ||
{ | ||
this.Title = _loc.GetLocalizationValue("TitleInstallationCompleteDialog"); | ||
} | ||
|
||
/// <summary> | ||
/// Launches the SQRL client (if selected) and exits the installer. | ||
/// </summary> | ||
public void Finish() | ||
{ | ||
if(this.LaunchOnFinish) | ||
{ | ||
LaunchSQRL(this.installPath); | ||
LaunchSQRL(this._installPath); | ||
} | ||
System.Environment.Exit(0); | ||
} | ||
|
||
/// <summary> | ||
/// Launches the freshly installed SQRL client app. | ||
/// </summary> | ||
/// <param name="installPath"></param> | ||
private void LaunchSQRL(string installPath) | ||
{ | ||
var process = new Process(); | ||
process.StartInfo.FileName = installPath; | ||
process.StartInfo.UseShellExecute = true; | ||
process.Start(); | ||
|
||
} | ||
} | ||
} |
71 changes: 0 additions & 71 deletions
71
SQRLPlatformAwareInstaller/ViewModels/MainInstalViewModel.cs
This file was deleted.
Oops, something went wrong.
91 changes: 91 additions & 0 deletions
91
SQRLPlatformAwareInstaller/ViewModels/MainInstallViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using Avalonia.Media.Imaging; | ||
using ReactiveUI; | ||
using Serilog; | ||
|
||
namespace SQRLPlatformAwareInstaller.ViewModels | ||
{ | ||
/// <summary> | ||
/// A view model representing the main installer screen. | ||
/// </summary> | ||
public class MainInstallViewModel: ViewModelBase | ||
{ | ||
private Bitmap _platformImg; | ||
|
||
/// <summary> | ||
/// An image representing the current OS platform. | ||
/// </summary> | ||
public Bitmap PlatformImg | ||
{ | ||
get | ||
{ | ||
return _platformImg; | ||
} | ||
set { this.RaiseAndSetIfChanged(ref _platformImg, value); } | ||
} | ||
|
||
/// <summary> | ||
/// A string representing the current OS platform. | ||
/// </summary> | ||
public string Platform | ||
{ | ||
get | ||
{ | ||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
return "Windows"; | ||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) | ||
return "MacOSX"; | ||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) | ||
return "Linux"; | ||
else | ||
return ""; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Creates a new instance, sets the window title and | ||
/// starts the platform detection. | ||
/// </summary> | ||
public MainInstallViewModel() | ||
{ | ||
Log.Information("Installer main screen launched"); | ||
|
||
this.Title = _loc.GetLocalizationValue("TitleMainInstall"); | ||
DetectPlatform(); | ||
Log.Information($"Detected platform: {Platform}"); | ||
} | ||
|
||
/// <summary> | ||
/// Detects the OS platform and sets some UI elements accordingly. | ||
/// </summary> | ||
public void DetectPlatform() | ||
{ | ||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
this.PlatformImg = new Bitmap(_assets.Open(new Uri("resm:SQRLPlatformAwareInstaller.Assets.windows.png"))); | ||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) | ||
this.PlatformImg = new Bitmap(_assets.Open(new Uri("resm:SQRLPlatformAwareInstaller.Assets.mac.png"))); | ||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) | ||
this.PlatformImg = new Bitmap(_assets.Open(new Uri("resm:SQRLPlatformAwareInstaller.Assets.linux.png"))); | ||
else | ||
this.PlatformImg = new Bitmap(_assets.Open(new Uri("resm:SQRLPlatformAwareInstaller.Assets.unknown.png"))); | ||
} | ||
|
||
/// <summary> | ||
/// Moves on to the version selection screen. | ||
/// </summary> | ||
public void Next() | ||
{ | ||
((MainWindowViewModel)_mainWindow.DataContext).Content = | ||
new VersionSelectorViewModel(); | ||
} | ||
|
||
/// <summary> | ||
/// Exits the application. | ||
/// </summary> | ||
public void Cancel() | ||
{ | ||
Environment.Exit(0); | ||
} | ||
} | ||
} |
Oops, something went wrong.