Skip to content

Commit

Permalink
Integrated console in Gui
Browse files Browse the repository at this point in the history
Updater
Cleanup
  • Loading branch information
SuperJMN committed Mar 5, 2019
1 parent 77090df commit 4ef6d4c
Show file tree
Hide file tree
Showing 21 changed files with 70 additions and 95 deletions.
2 changes: 1 addition & 1 deletion Source/Deployer.Lumia.Console/ConsoleDisplayUpdater.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Linq;

namespace Deployment.Console
namespace Deployer.Lumia.Console
{
public class ConsoleDisplayUpdater : IDisposable
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Deployer.Lumia.Console/ConsoleMarkdownDisplayer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Threading.Tasks;
using Deployer.Tasks;

namespace Deployment.Console
namespace Deployer.Lumia.Console
{
internal class ConsoleMarkdownDisplayer : IMarkdownDisplayer
{
Expand Down
12 changes: 6 additions & 6 deletions Source/Deployer.Lumia.Console/Deployer.Lumia.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B29156BB-B183-4B55-BB04-7B9B926EC926}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Deployment.Console</RootNamespace>
<AssemblyName>WoaDeployer</AssemblyName>
<OutputType>Library</OutputType>
<RootNamespace>Deployer.Lumia.Console</RootNamespace>
<AssemblyName>Deployer.Lumia.Console</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
Expand Down Expand Up @@ -35,8 +35,9 @@
<WarningLevel>4</WarningLevel>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand All @@ -56,7 +57,6 @@
<Compile Include="ConsoleMarkdownDisplayer.cs" />
<Compile Include="Options\DisableDualBootCmdOptions.cs" />
<Compile Include="Options\EnableDualBootCmdOptions.cs" />
<Compile Include="Options\InstallGpuCmdOptions.cs" />
<Compile Include="Options\NonWindowsDeploymentCmdOptions.cs" />
<Compile Include="Resources.Designer.cs">
<AutoGen>True</AutoGen>
Expand Down Expand Up @@ -107,7 +107,7 @@
<Version>3.3.0</Version>
</PackageReference>
<PackageReference Include="System.Reactive">
<Version>4.1.2</Version>
<Version>4.1.3</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 0 additions & 9 deletions Source/Deployer.Lumia.Console/Options/InstallGpuCmdOptions.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 4 additions & 8 deletions Source/Deployer.Lumia.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -50,7 +48,6 @@ private static async Task Execute(IEnumerable<string> args, Subject<double> subj
.ParseArguments<WindowsDeploymentCmdOptions,
EnableDualBootCmdOptions,
DisableDualBootCmdOptions,
InstallGpuCmdOptions,
NonWindowsDeploymentCmdOptions>(args);

await parserResult
Expand All @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Deployer.Lumia.Console/Resources.Designer.cs

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

36 changes: 32 additions & 4 deletions Source/Deployer.Lumia.Gui/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,44 @@
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
{
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();
}
}
}
7 changes: 7 additions & 0 deletions Source/Deployer.Lumia.Gui/AppProperties.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Deployer.Lumia.Gui
{
public class AppProperties
{
public const string GitHubBaseUrl = "https://github.com/WOA-Project/WOA-Deployer-Lumia";
}
}
7 changes: 6 additions & 1 deletion Source/Deployer.Lumia.Gui/Deployer.Lumia.Gui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ProjectGuid>{76DCD56D-98E7-4EA1-B04B-FA063B953FD7}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Deployer.Lumia.Gui</RootNamespace>
<AssemblyName>WOA Deployer</AssemblyName>
<AssemblyName>WoaDeployer</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Expand Down Expand Up @@ -66,6 +66,7 @@
<Compile Include="..\Deployer.Lumia.NetFx\Properties\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="AppProperties.cs" />
<Compile Include="ViewModels\AdvancedViewModel.cs" />
<Compile Include="ViewModels\DualBootViewModel.cs" />
<Compile Include="ViewModels\MessageViewModel.cs" />
Expand Down Expand Up @@ -254,6 +255,10 @@
<Resource Include="Assets\heart.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Deployer.Lumia.Console\Deployer.Lumia.Console.csproj">
<Project>{b29156bb-b183-4b55-bb04-7b9b926ec926}</Project>
<Name>Deployer.Lumia.Console</Name>
</ProjectReference>
<ProjectReference Include="..\DeployerPlatform\Deployer.Gui.Common\Deployer.Gui.Common.csproj">
<Project>{ad8ea86c-af60-4ccf-9caa-07bbf5e039ec}</Project>
<Name>Deployer.Gui.Common</Name>
Expand Down
1 change: 0 additions & 1 deletion Source/Deployer.Lumia.Gui/Locator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
34 changes: 3 additions & 31 deletions Source/Deployer.Lumia.Gui/ViewModels/AdvancedViewModel.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Unit, Unit> InstallGpuWrapper { get; set; }

private readonly ObservableAsPropertyHelper<ByteSize> 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<Unit, Unit>(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;
Expand All @@ -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<bool> IsBusyObservable { get; }

public bool UseCompactDeployment
Expand Down
2 changes: 1 addition & 1 deletion Source/Deployer.Lumia.Gui/Views/MarkdownViewerWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mah:MetroWindow x:Class="Deployer.Raspberry.Gui.Views.MarkdownViewerWindow"
<mah:MetroWindow x:Class="Deployer.Lumia.Gui.Views.MarkdownViewerWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Windows;
using System.Windows.Input;

namespace Deployer.Raspberry.Gui.Views
namespace Deployer.Lumia.Gui.Views
{

public partial class MarkdownViewerWindow
Expand Down
22 changes: 0 additions & 22 deletions Source/Deployer.Lumia.Gui/Views/Parts/AdvancedPart.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,6 @@
d:DesignHeight="450" d:DesignWidth="800" Padding="8"
DataContext="{Binding Source={StaticResource Locator}, Path=AdvancedViewModel}" mah:DialogParticipation.Register="{Binding}">
<StackPanel>
<GroupBox Visibility="Collapsed" Header="GPU" Padding="20" Margin="0,20,0,0">
<HeaderedContentControl
HorizontalContentAlignment="Stretch">
<HeaderedContentControl.Header>
<TextBlock>
EXPERIMENTAL: This will install the GPU drivers. Use it with caution.
<LineBreak />
<Bold>ONLY for Lumia 950 XL.</Bold>
</TextBlock>
</HeaderedContentControl.Header>
<common:IconButton Margin="20"
VerticalAlignment="Center" HorizontalAlignment="Center" Height="50"
Content="Install GPU" Command="{Binding InstallGpuWrapper.Command}"
IsBusy="{Binding InstallGpuWrapper.IsExecuting}">
<common:IconButton.Icon>
<iconPacks:PackIconMaterial Kind="Chip" Style="{StaticResource ButtonIconStyle}" />
</common:IconButton.Icon>
</common:IconButton>
</HeaderedContentControl>

</GroupBox>

<GroupBox Header="Misc" Padding="20" Margin="0,20,0,0">
<UniformGrid Rows="1">
<HeaderedContentControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
// 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("2.0.1")]
[assembly: AssemblyVersion("2.1.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
1 change: 0 additions & 1 deletion Source/Deployer.Lumia/IWoaDeployer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ public interface IWoaDeployer
{
Task Deploy();
Task ToogleDualBoot(bool p0);
Task InstallGpu();
}
}
2 changes: 1 addition & 1 deletion Source/DeployerPlatform

0 comments on commit 4ef6d4c

Please sign in to comment.