From 4ef6d4c12326a880b938281b4c0b03aa0e156c92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Manuel=20Nieto=20S=C3=A1nchez?= Date: Tue, 5 Mar 2019 11:37:22 +0100 Subject: [PATCH] Integrated console in Gui Updater Cleanup --- .../ConsoleDisplayUpdater.cs | 2 +- .../ConsoleMarkdownDisplayer.cs | 2 +- .../Deployer.Lumia.Console.csproj | 12 +++---- .../Options/DisableDualBootCmdOptions.cs | 2 +- .../Options/EnableDualBootCmdOptions.cs | 2 +- .../Options/InstallGpuCmdOptions.cs | 9 ----- .../Options/NonWindowsDeploymentCmdOptions.cs | 2 +- .../Options/WindowsDeploymentCmdOptions.cs | 2 +- Source/Deployer.Lumia.Console/Program.cs | 12 +++---- .../Resources.Designer.cs | 4 +-- Source/Deployer.Lumia.Gui/App.xaml.cs | 36 ++++++++++++++++--- Source/Deployer.Lumia.Gui/AppProperties.cs | 7 ++++ .../Deployer.Lumia.Gui.csproj | 7 +++- Source/Deployer.Lumia.Gui/Locator.cs | 1 - .../ViewModels/AdvancedViewModel.cs | 34 ++---------------- .../Views/MarkdownViewerWindow.xaml | 2 +- .../Views/MarkdownViewerWindow.xaml.cs | 2 +- .../Views/Parts/AdvancedPart.xaml | 22 ------------ .../Properties/SharedAssemblyInfo.cs | 2 +- Source/Deployer.Lumia/IWoaDeployer.cs | 1 - Source/DeployerPlatform | 2 +- 21 files changed, 70 insertions(+), 95 deletions(-) delete mode 100644 Source/Deployer.Lumia.Console/Options/InstallGpuCmdOptions.cs create mode 100644 Source/Deployer.Lumia.Gui/AppProperties.cs diff --git a/Source/Deployer.Lumia.Console/ConsoleDisplayUpdater.cs b/Source/Deployer.Lumia.Console/ConsoleDisplayUpdater.cs index a38f873..1c4e793 100644 --- a/Source/Deployer.Lumia.Console/ConsoleDisplayUpdater.cs +++ b/Source/Deployer.Lumia.Console/ConsoleDisplayUpdater.cs @@ -1,7 +1,7 @@ using System; using System.Linq; -namespace Deployment.Console +namespace Deployer.Lumia.Console { public class ConsoleDisplayUpdater : IDisposable { diff --git a/Source/Deployer.Lumia.Console/ConsoleMarkdownDisplayer.cs b/Source/Deployer.Lumia.Console/ConsoleMarkdownDisplayer.cs index 36b9745..6114539 100644 --- a/Source/Deployer.Lumia.Console/ConsoleMarkdownDisplayer.cs +++ b/Source/Deployer.Lumia.Console/ConsoleMarkdownDisplayer.cs @@ -1,7 +1,7 @@ using System.Threading.Tasks; using Deployer.Tasks; -namespace Deployment.Console +namespace Deployer.Lumia.Console { internal class ConsoleMarkdownDisplayer : IMarkdownDisplayer { diff --git a/Source/Deployer.Lumia.Console/Deployer.Lumia.Console.csproj b/Source/Deployer.Lumia.Console/Deployer.Lumia.Console.csproj index b3f6b94..1814a0b 100644 --- a/Source/Deployer.Lumia.Console/Deployer.Lumia.Console.csproj +++ b/Source/Deployer.Lumia.Console/Deployer.Lumia.Console.csproj @@ -5,9 +5,9 @@ Debug AnyCPU {B29156BB-B183-4B55-BB04-7B9B926EC926} - Exe - Deployment.Console - WoaDeployer + Library + Deployer.Lumia.Console + Deployer.Lumia.Console v4.6.2 512 true @@ -35,8 +35,9 @@ 4 7.1 + - app.manifest + @@ -56,7 +57,6 @@ - True @@ -107,7 +107,7 @@ 3.3.0 - 4.1.2 + 4.1.3 diff --git a/Source/Deployer.Lumia.Console/Options/DisableDualBootCmdOptions.cs b/Source/Deployer.Lumia.Console/Options/DisableDualBootCmdOptions.cs index 09a553a..25ec009 100644 --- a/Source/Deployer.Lumia.Console/Options/DisableDualBootCmdOptions.cs +++ b/Source/Deployer.Lumia.Console/Options/DisableDualBootCmdOptions.cs @@ -1,6 +1,6 @@ using CommandLine; -namespace Deployment.Console.Options +namespace Deployer.Lumia.Console.Options { [Verb("disable-dualboot", HelpText = "Disables Dual Boot")] public class DisableDualBootCmdOptions diff --git a/Source/Deployer.Lumia.Console/Options/EnableDualBootCmdOptions.cs b/Source/Deployer.Lumia.Console/Options/EnableDualBootCmdOptions.cs index fd75b15..584738e 100644 --- a/Source/Deployer.Lumia.Console/Options/EnableDualBootCmdOptions.cs +++ b/Source/Deployer.Lumia.Console/Options/EnableDualBootCmdOptions.cs @@ -1,6 +1,6 @@ using CommandLine; -namespace Deployment.Console.Options +namespace Deployer.Lumia.Console.Options { [Verb("enable-dualboot", HelpText = "Enabled Dual Boot")] public class EnableDualBootCmdOptions diff --git a/Source/Deployer.Lumia.Console/Options/InstallGpuCmdOptions.cs b/Source/Deployer.Lumia.Console/Options/InstallGpuCmdOptions.cs deleted file mode 100644 index c3c6443..0000000 --- a/Source/Deployer.Lumia.Console/Options/InstallGpuCmdOptions.cs +++ /dev/null @@ -1,9 +0,0 @@ -using CommandLine; - -namespace Deployment.Console.Options -{ - [Verb("install-gpu", HelpText = "Installs the GPU drivers")] - public class InstallGpuCmdOptions - { - } -} \ No newline at end of file diff --git a/Source/Deployer.Lumia.Console/Options/NonWindowsDeploymentCmdOptions.cs b/Source/Deployer.Lumia.Console/Options/NonWindowsDeploymentCmdOptions.cs index 6369a6f..6e3eccd 100644 --- a/Source/Deployer.Lumia.Console/Options/NonWindowsDeploymentCmdOptions.cs +++ b/Source/Deployer.Lumia.Console/Options/NonWindowsDeploymentCmdOptions.cs @@ -1,6 +1,6 @@ using CommandLine; -namespace Deployment.Console.Options +namespace Deployer.Lumia.Console.Options { [Verb("execute", HelpText = "Executes a script that doesn't deploy Windows")] public class NonWindowsDeploymentCmdOptions diff --git a/Source/Deployer.Lumia.Console/Options/WindowsDeploymentCmdOptions.cs b/Source/Deployer.Lumia.Console/Options/WindowsDeploymentCmdOptions.cs index 7a45914..90e8787 100644 --- a/Source/Deployer.Lumia.Console/Options/WindowsDeploymentCmdOptions.cs +++ b/Source/Deployer.Lumia.Console/Options/WindowsDeploymentCmdOptions.cs @@ -1,6 +1,6 @@ using CommandLine; -namespace Deployment.Console.Options +namespace Deployer.Lumia.Console.Options { [Verb("deploy", HelpText = "Executes a Windows deployment script")] public class WindowsDeploymentCmdOptions diff --git a/Source/Deployer.Lumia.Console/Program.cs b/Source/Deployer.Lumia.Console/Program.cs index 6efab42..6f4792e 100644 --- a/Source/Deployer.Lumia.Console/Program.cs +++ b/Source/Deployer.Lumia.Console/Program.cs @@ -5,20 +5,18 @@ using System.Threading.Tasks; using ByteSizeLib; using CommandLine; -using Deployer; -using Deployer.Lumia; +using Deployer.Lumia.Console.Options; using Deployer.Lumia.NetFx; using Deployer.Tasks; -using Deployment.Console.Options; using Grace.DependencyInjection; using Serilog; using Serilog.Events; -namespace Deployment.Console +namespace Deployer.Lumia.Console { - internal static class Program + public static class Program { - private static async Task Main(string[] args) + public static async Task Main(string[] args) { ConfigureLogger(); @@ -50,7 +48,6 @@ private static async Task Execute(IEnumerable args, Subject subj .ParseArguments(args); await parserResult @@ -68,7 +65,6 @@ await parserResult }, (EnableDualBootCmdOptions opts) => deployer.ToogleDualBoot(true), (DisableDualBootCmdOptions opts) => deployer.ToogleDualBoot(false), - (InstallGpuCmdOptions opts) => deployer.InstallGpu(), (NonWindowsDeploymentCmdOptions opts) => deployer.Deploy(), HandleErrors); } diff --git a/Source/Deployer.Lumia.Console/Resources.Designer.cs b/Source/Deployer.Lumia.Console/Resources.Designer.cs index 8eb913b..ad8f639 100644 --- a/Source/Deployer.Lumia.Console/Resources.Designer.cs +++ b/Source/Deployer.Lumia.Console/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Deployment.Console { +namespace Deployer.Lumia.Console { using System; @@ -39,7 +39,7 @@ internal Resources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Deployment.Console.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Deployer.Lumia.Console.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Source/Deployer.Lumia.Gui/App.xaml.cs b/Source/Deployer.Lumia.Gui/App.xaml.cs index 617a27f..3655f0a 100644 --- a/Source/Deployer.Lumia.Gui/App.xaml.cs +++ b/Source/Deployer.Lumia.Gui/App.xaml.cs @@ -1,5 +1,9 @@ -using System.Windows; -using Serilog; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; +using Deployer.Gui.Common; +using Deployer.Lumia.Console; +using Deployer.Lumia.Gui.Views; namespace Deployer.Lumia.Gui { @@ -7,10 +11,34 @@ public partial class App { protected override void OnStartup(StartupEventArgs e) { - base.OnStartup(e); - + base.OnStartup(e); + MahApps.Metro.ThemeManager.IsAutomaticWindowsAppModeSettingSyncEnabled = true; MahApps.Metro.ThemeManager.SyncThemeWithWindowsAppModeSetting(); + + if (e.Args.Any()) + { + LaunchConsole(e.Args); + } + else + { + LaunchGui(); + } + } + + private void LaunchGui() + { + var window = new MainWindow(); + MainWindow = window; + window.Show(); + } + + private void LaunchConsole(string[] args) + { + UpdateChecker.CheckForUpdates(AppProperties.GitHubBaseUrl); + + ConsoleEmbedder.ExecuteInsideConsole(() => Task.Run(() => Program.Main(args)).Wait()); + Shutdown(); } } } diff --git a/Source/Deployer.Lumia.Gui/AppProperties.cs b/Source/Deployer.Lumia.Gui/AppProperties.cs new file mode 100644 index 0000000..166ba5d --- /dev/null +++ b/Source/Deployer.Lumia.Gui/AppProperties.cs @@ -0,0 +1,7 @@ +namespace Deployer.Lumia.Gui +{ + public class AppProperties + { + public const string GitHubBaseUrl = "https://github.com/WOA-Project/WOA-Deployer-Lumia"; + } +} \ No newline at end of file diff --git a/Source/Deployer.Lumia.Gui/Deployer.Lumia.Gui.csproj b/Source/Deployer.Lumia.Gui/Deployer.Lumia.Gui.csproj index 569f953..a87f5fd 100644 --- a/Source/Deployer.Lumia.Gui/Deployer.Lumia.Gui.csproj +++ b/Source/Deployer.Lumia.Gui/Deployer.Lumia.Gui.csproj @@ -7,7 +7,7 @@ {76DCD56D-98E7-4EA1-B04B-FA063B953FD7} WinExe Deployer.Lumia.Gui - WOA Deployer + WoaDeployer v4.6.2 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} @@ -66,6 +66,7 @@ Properties\SharedAssemblyInfo.cs + @@ -254,6 +255,10 @@ + + {b29156bb-b183-4b55-bb04-7b9b926ec926} + Deployer.Lumia.Console + {ad8ea86c-af60-4ccf-9caa-07bbf5e039ec} Deployer.Gui.Common diff --git a/Source/Deployer.Lumia.Gui/Locator.cs b/Source/Deployer.Lumia.Gui/Locator.cs index 5e37129..ffad61e 100644 --- a/Source/Deployer.Lumia.Gui/Locator.cs +++ b/Source/Deployer.Lumia.Gui/Locator.cs @@ -6,7 +6,6 @@ using Deployer.Lumia.Gui.ViewModels; using Deployer.Lumia.Gui.Views; using Deployer.Lumia.NetFx; -using Deployer.Raspberry.Gui.Views; using Deployer.Tasks; using Grace.DependencyInjection; using MahApps.Metro.Controls.Dialogs; diff --git a/Source/Deployer.Lumia.Gui/ViewModels/AdvancedViewModel.cs b/Source/Deployer.Lumia.Gui/ViewModels/AdvancedViewModel.cs index b4182b7..1f47804 100644 --- a/Source/Deployer.Lumia.Gui/ViewModels/AdvancedViewModel.cs +++ b/Source/Deployer.Lumia.Gui/ViewModels/AdvancedViewModel.cs @@ -1,6 +1,5 @@ using System; -using System.Reactive; -using System.Threading.Tasks; +using System.Reactive.Linq; using ByteSizeLib; using Deployer.Gui.Common; using ReactiveUI; @@ -9,26 +8,19 @@ namespace Deployer.Lumia.Gui.ViewModels { public class AdvancedViewModel : ReactiveObject, IBusy { - private readonly UIServices uiServices; private readonly ISettingsService settingsService; - private readonly IWoaDeployer wapDeployer; - public CommandWrapper InstallGpuWrapper { get; set; } private readonly ObservableAsPropertyHelper sizeReservedForWindows; - public AdvancedViewModel(UIServices uiServices, ISettingsService settingsService, IWoaDeployer wapDeployer) + public AdvancedViewModel(ISettingsService settingsService) { - this.uiServices = uiServices; this.settingsService = settingsService; - this.wapDeployer = wapDeployer; - InstallGpuWrapper = new CommandWrapper(this, - ReactiveCommand.CreateFromTask(InstallGpu), uiServices.Dialog); sizeReservedForWindows = this.WhenAnyValue(x => x.GbsReservedForWindows, ByteSize.FromGigaBytes) .ToProperty(this, x => x.SizeReservedForWindows); - IsBusyObservable = InstallGpuWrapper.Command.IsExecuting; + IsBusyObservable = Observable.Return(false); } public ByteSize SizeReservedForWindows => sizeReservedForWindows.Value; @@ -44,26 +36,6 @@ public double GbsReservedForWindows } } - private async Task InstallGpu() - { - try - { - await wapDeployer.InstallGpu(); - var messageViewModel = - new MessageViewModel(Resources.ManualStepsTitle, Resources.InstallGpuManualSteps); - - uiServices.ViewService.Show("MarkdownViewer", messageViewModel); - } - catch (InvalidOperationException) - { - throw new ApplicationException(Resources.PhoneIsNotLumia950XL); - } - catch (Exception) - { - throw new ApplicationException(Resources.CannotInstallGpu); - } - } - public IObservable IsBusyObservable { get; } public bool UseCompactDeployment diff --git a/Source/Deployer.Lumia.Gui/Views/MarkdownViewerWindow.xaml b/Source/Deployer.Lumia.Gui/Views/MarkdownViewerWindow.xaml index 82f3be2..690e3be 100644 --- a/Source/Deployer.Lumia.Gui/Views/MarkdownViewerWindow.xaml +++ b/Source/Deployer.Lumia.Gui/Views/MarkdownViewerWindow.xaml @@ -1,4 +1,4 @@ - - - - - - EXPERIMENTAL: This will install the GPU drivers. Use it with caution. - - ONLY for Lumia 950 XL. - - - - - - - - - - -