diff --git a/UWPHook.sln b/UWPHook.sln index e86a4f0..9be6383 100644 --- a/UWPHook.sln +++ b/UWPHook.sln @@ -5,9 +5,9 @@ VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UWPHook", "UWPHook\UWPHook.csproj", "{AFE09BCF-28A4-48EE-876B-FEF080D04D5F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpSteam", "..\SharpSteam\SharpSteam\SharpSteam.csproj", "{D0A686FB-B373-4FBC-A0DD-C3417276A816}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpSteam", "..\..\Visual Studio 2015\Projects\SharpSteam\SharpSteam\SharpSteam.csproj", "{D0A686FB-B373-4FBC-A0DD-C3417276A816}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VDFParser", "..\SharpSteam\VDFParser\VDFParser\VDFParser.csproj", "{9543FB59-1EB6-4638-B24C-B12B9D4A15FC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VDFParser", "..\..\Visual Studio 2015\Projects\SharpSteam\VDFParser\VDFParser\VDFParser.csproj", "{9543FB59-1EB6-4638-B24C-B12B9D4A15FC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/UWPHook/AppEntry.cs b/UWPHook/AppEntry.cs index f1abf91..675706a 100644 --- a/UWPHook/AppEntry.cs +++ b/UWPHook/AppEntry.cs @@ -1,4 +1,7 @@ -using System.ComponentModel; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.IO; using System.Runtime.CompilerServices; namespace UWPHook @@ -41,6 +44,40 @@ namespace UWPHook set { _aumid = value; } } + private string _icon; + + public string Icon + { + get { return _icon; } + set { _icon = value; } + } + + public string widestSquareIcon() + { + string result = ""; + Size size = new Size(0, 0); + List images = new List(); + + //Get every file on the directory + images.AddRange( Directory.GetFiles(_icon, "*.jpg", SearchOption.AllDirectories)); + images.AddRange(Directory.GetFiles(_icon, "*.png", SearchOption.AllDirectories)); + + //Decide which is the largest + foreach (string image in images) + { + Image i = Image.FromFile(image); + + if (i.Width == i.Height && (i.Size.Height > size.Height)) + { + size = i.Size; + result = image; + } + } + + return result; + } + + public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) diff --git a/UWPHook/GamesWindow.xaml.cs b/UWPHook/GamesWindow.xaml.cs index d5a7f33..30065e3 100644 --- a/UWPHook/GamesWindow.xaml.cs +++ b/UWPHook/GamesWindow.xaml.cs @@ -1,5 +1,6 @@ using SharpSteam; using System; +using System.Collections.Generic; using System.ComponentModel; using System.Globalization; using System.IO; @@ -113,7 +114,7 @@ namespace UWPHook Exe = @"""" + System.Reflection.Assembly.GetExecutingAssembly().Location + @""" " + app.Aumid, StartDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), AllowDesktopConfig = 1, - Icon = "", + Icon = app.widestSquareIcon(), Index = shortcuts.Length, IsHidden = 0, OpenVR = 0, @@ -162,6 +163,7 @@ namespace UWPHook private void Bwr_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { grid.IsEnabled = true; + listGames.Columns[1].IsReadOnly = true; listGames.Columns[2].IsReadOnly = true; progressBar.Visibility = Visibility.Collapsed; label.Content = "Installed Apps"; @@ -171,22 +173,37 @@ namespace UWPHook { try { - var installedApps = AppManager.GetInstalledApps(); + //Get all installed apps on the system excluding frameworks + List installedApps = AppManager.GetInstalledApps(); + + //Alfabetic sort + installedApps.Sort(); + + //Split every app that we couldn't resolve the app name + var x = (from s in installedApps where s.Contains("double click") select s).ToList(); + + //Remove them from the original list + installedApps.RemoveAll(item => item.Contains("double click")); + + //Rejoin them in the original list, but putting them into last + installedApps = installedApps.Union(x).ToList(); + foreach (var app in installedApps) { //Remove end lines from the String and split both values, I split the appname and the AUMID using | //I hope no apps have that in their name. Ever. var valor = app.Replace("\r\n", "").Split('|'); - - //Frameworks by Microsoft don fill the displayname at all ot have ms-resource as a name instead, this excludes them making the list less bloated - if (!String.IsNullOrWhiteSpace(valor[0]) && !valor[0].Contains("ms-resource")) + if (!String.IsNullOrWhiteSpace(valor[0])) { + //We get the default square tile to find where the app stores it's icons, then we resolve which one is the widest + string logosPath = Path.GetDirectoryName(valor[1]); Application.Current.Dispatcher.BeginInvoke((Action)delegate () { - Apps.Entries.Add(new AppEntry() { Name = valor[0], Aumid = valor[1], Selected = false }); + Apps.Entries.Add(new AppEntry() { Name = valor[0], Icon = logosPath, Aumid = valor[2], Selected = false}); }); } } + } catch (Exception ex) { diff --git a/UWPHook/Resources/GetAUMIDScript.txt b/UWPHook/Resources/GetAUMIDScript.txt index 9be4d36..e03e5ab 100644 --- a/UWPHook/Resources/GetAUMIDScript.txt +++ b/UWPHook/Resources/GetAUMIDScript.txt @@ -1,20 +1,37 @@ $installedapps = get-AppxPackage - +$invalidNames = '*ms-resource*', '*DisplayName*' $aumidList = @() + foreach ($app in $installedapps) { try { - foreach ($appx in (Get-AppxPackageManifest $app)) + if(-not $app.IsFramework){ + foreach ($id in (Get-AppxPackageManifest $app).package.applications.application.id) + { + $appx = Get-AppxPackageManifest $app; + $name = $appx.Package.Properties.DisplayName; + + if($name -like '*DisplayName*' -or $name -like '*ms-resource*') + { + $name = $appx.Package.Applications.Application.VisualElements.DisplayName; + } + if($name -like '*DisplayName*' -or $name -like '*ms-resource*') + { + $name = "App name not found, double click here to edit it"; + } + + $logo = $app.InstallLocation + "\" + $appx.Package.Applications.Application.VisualElements.Square150x150Logo; + + $aumidList += $name + "|" + $logo + "|" + + $app.packagefamilyname + "!" + $id+ ";" + } + } + } + catch { - - $aumidList += $appx.Package.Properties.DisplayName + " | "+ - $app.packagefamilyname + "!" + $appx.package.applications.application.id + ";" - + $ErrorMessage = $_.Exception.Message + $FailedItem = $_.Exception.ItemName } - } catch { - $ErrorMessage = $_.Exception.Message - $FailedItem = $_.Exception.ItemName - } } $aumidList; \ No newline at end of file diff --git a/UWPHook/UWPHook.csproj b/UWPHook/UWPHook.csproj index 53a5458..aad1237 100644 --- a/UWPHook/UWPHook.csproj +++ b/UWPHook/UWPHook.csproj @@ -157,16 +157,6 @@ - - - {d0a686fb-b373-4fbc-a0dd-c3417276a816} - SharpSteam - - - {9543fb59-1eb6-4638-b24c-b12b9d4a15fc} - VDFParser - - @@ -188,6 +178,16 @@ + + + {d0a686fb-b373-4fbc-a0dd-c3417276a816} + SharpSteam + + + {9543fb59-1eb6-4638-b24c-b12b9d4a15fc} + VDFParser + +