From 976576761d394d3fd0994f397c72ebb3110c81a4 Mon Sep 17 00:00:00 2001 From: Brian Lima Date: Thu, 24 May 2018 13:41:37 -0300 Subject: [PATCH] Implement Full screen launcher, bum .net version --- UWPHook/App.config | 12 ++--- UWPHook/FullScreenLauncher.xaml | 43 ++++++++++++++++ UWPHook/FullScreenLauncher.xaml.cs | 62 ++++++++++++++++++++++++ UWPHook/GamesWindow.xaml.cs | 31 +++++++++--- UWPHook/Properties/Resources.Designer.cs | 18 ++++--- UWPHook/Properties/Settings.Designer.cs | 2 +- UWPHook/UWPHook.csproj | 9 +++- 7 files changed, 153 insertions(+), 24 deletions(-) create mode 100644 UWPHook/FullScreenLauncher.xaml create mode 100644 UWPHook/FullScreenLauncher.xaml.cs diff --git a/UWPHook/App.config b/UWPHook/App.config index 744efc7..2ddf497 100644 --- a/UWPHook/App.config +++ b/UWPHook/App.config @@ -1,12 +1,12 @@ - + - -
+ +
- + @@ -14,7 +14,7 @@ False - + 5 @@ -24,4 +24,4 @@ - \ No newline at end of file + diff --git a/UWPHook/FullScreenLauncher.xaml b/UWPHook/FullScreenLauncher.xaml new file mode 100644 index 0000000..bcadb41 --- /dev/null +++ b/UWPHook/FullScreenLauncher.xaml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/UWPHook/FullScreenLauncher.xaml.cs b/UWPHook/FullScreenLauncher.xaml.cs new file mode 100644 index 0000000..2b01327 --- /dev/null +++ b/UWPHook/FullScreenLauncher.xaml.cs @@ -0,0 +1,62 @@ +using MaterialDesignThemes.Wpf; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace UWPHook +{ + /// + /// Interaction logic for FullScreenLauncher.xaml + /// + public partial class FullScreenLauncher : Window + { + public PaletteHelper pallet; + public FullScreenLauncher() + { + InitializeComponent(); + textLaunch.Text = GetLauncherText(); + pallet = new PaletteHelper(); + pallet.SetLightDark(true); + } + + string GetLauncherText() + { + int n = DateTime.Now.Second; + + if (n >= 0 && n <= 10) + { + return "Hold on, i'm making your stream full screen!"; + } + else if (n > 10 && n <= 20) + { + return "Waiting Steam in-home Streamming to catch up"; + } + else if (n > 20 && n <= 30) + { + return "Starting Stream in a few seconds!"; + } + else if (n > 30 && n <= 40) + { + return "Let's get this game started!"; + } + else if (n > 40 && n <= 50) + { + return "Don't forget to check for updates at github.com/brianlima"; + } + else + { + return "Good game, enjoy!"; + } + } + } +} diff --git a/UWPHook/GamesWindow.xaml.cs b/UWPHook/GamesWindow.xaml.cs index 1647996..81f68ad 100644 --- a/UWPHook/GamesWindow.xaml.cs +++ b/UWPHook/GamesWindow.xaml.cs @@ -6,6 +6,7 @@ using System.Globalization; using System.IO; using System.Linq; using System.Threading; +using System.Threading.Tasks; using System.Windows; using VDFParser; using VDFParser.Models; @@ -19,6 +20,7 @@ namespace UWPHook { AppEntryModel Apps; BackgroundWorker bwrLoad, bwrSave; + Timer ticker; public GamesWindow() { @@ -31,23 +33,31 @@ namespace UWPHook //When length is 1, the only argument is the path where the app is installed if (Environment.GetCommandLineArgs().Length > 1) { - Launcher(); + LauncherAsync(); } } } - private void Launcher() + /// + /// We have to wait a little untill Steam catches up, otherwise it will stream a black screen + /// + /// + async Task LaunchDelay() { + await Task.Delay(10000); + } + + private async Task LauncherAsync() + { + FullScreenLauncher launcher = null; //So, for some reason, Steam is now stopping in-home streaming if the launched app is minimized, so not hiding UWPHook's window is doing the trick for now if (Properties.Settings.Default.StreamMode) { - this.Show(); - this.WindowStyle = WindowStyle.None; - this.WindowState = WindowState.Maximized; - this.Title = "UWPHook: Streaming a game"; - this.label.Content = "UWPHook is streaming your game, fasten your seatbelts."; + this.Hide(); + launcher = new FullScreenLauncher(); + launcher.Show(); - Thread.Sleep(10000); + await LaunchDelay(); } else { @@ -88,6 +98,11 @@ namespace UWPHook ScriptManager.RunScript("Set - WinUILanguageOverride " + currentLanguage); } + if (launcher != null) + { + launcher.Close(); + } + //The user has probably finished using the app, so let's close UWPHook to keep the experience clean this.Close(); } diff --git a/UWPHook/Properties/Resources.Designer.cs b/UWPHook/Properties/Resources.Designer.cs index fa9483b..03de0f7 100644 --- a/UWPHook/Properties/Resources.Designer.cs +++ b/UWPHook/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace UWPHook.Properties { // 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.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Resources { @@ -62,17 +62,19 @@ namespace UWPHook.Properties { /// /// Looks up a localized string similar to $installedapps = get-AppxPackage - /// + ///$invalidNames = '*ms-resource*', '*DisplayName*' ///$aumidList = @() + /// ///foreach ($app in $installedapps) ///{ - ///    foreach ($id in (Get-AppxPackageManifest $app).package.applications.application.id) - ///    { - ///        $aumidList += $app.name + "|" + $app.packagefamilyname + "!" + $id + ";" - ///    } - ///} + /// try { + /// if(-not $app.IsFramework){ + /// foreach ($id in (Get-AppxPackageManifest $app).package.applications.application.id) + /// { + /// $appx = Get-AppxPackageManifest $app; + /// $name = $appx.Package.Properties.DisplayName; /// - ///$aumidList. + /// if($name -like '*DisplayName*' -or $name -like '*ms-resourc [rest of string was truncated]";. /// public static string GetAUMIDScript { get { diff --git a/UWPHook/Properties/Settings.Designer.cs b/UWPHook/Properties/Settings.Designer.cs index 8072de2..0ef962f 100644 --- a/UWPHook/Properties/Settings.Designer.cs +++ b/UWPHook/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace UWPHook.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")] public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/UWPHook/UWPHook.csproj b/UWPHook/UWPHook.csproj index 3c71d0b..2e60fc3 100644 --- a/UWPHook/UWPHook.csproj +++ b/UWPHook/UWPHook.csproj @@ -9,7 +9,7 @@ Properties UWPHook UWPHook - v4.6.1 + v4.7.1 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 @@ -29,6 +29,7 @@ false false true + AnyCPU @@ -96,6 +97,9 @@ + + FullScreenLauncher.xaml + GamesWindow.xaml @@ -104,6 +108,9 @@ SettingsWindow.xaml + + MSBuild:Compile + Designer MSBuild:Compile