added AppEntry.ToString()


			
			
				pull/73/head
			
			
		
Jon 3 years ago
parent a5ea0db936
commit 16522024cf

@ -118,14 +118,11 @@ namespace UWPHook
public string isKnownApp()
{
if (_aumid.Contains("Microsoft.SeaofThieves"))
if(AppManager.IsKnownApp(_aumid, out string name))
{
return "Sea of Thieves";
}
else if (_aumid.Contains("Microsoft.DeltaPC"))
{
return "Gears of War: Ultimate Edition";
return name;
}
return "Name not found, double click here to edit";
}
@ -135,5 +132,10 @@ namespace UWPHook
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public override string ToString()
{
return $"{Name} ({Aumid})";
}
}
}

@ -101,6 +101,30 @@ namespace UWPHook
return result;
}
/// <summary>
/// Try to convert an aumid into a human-readable app name
/// </summary>
/// <param name="appName">Application user model ID (aumid)</param>
/// <param name="readableName">User-friendly app name</param>
/// <returns>Whether this is a known app</returns>
public static bool IsKnownApp(string appName, out string readableName)
{
string appsJson = File.ReadAllText(@"Resources\KnownApps.json");
var apps = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(appsJson);
foreach (var kvp in apps)
{
if (appName.StartsWith(kvp.Key + "_"))
{
readableName = kvp.Value;
return true;
}
}
readableName = null;
return false;
}
[DllImport("user32.dll")]
private static extern
bool SetForegroundWindow(IntPtr hWnd);

@ -542,6 +542,12 @@ namespace UWPHook
//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 values = app.Replace("\r\n", "").Split('|');
if (values.Length >= 3 && AppManager.IsKnownApp(values[2], out string readableName))
{
values[0] = readableName;
}
if (!String.IsNullOrWhiteSpace(values[0]))
{
//We get the default square tile to find where the app stores it's icons, then we resolve which one is the widest
@ -551,17 +557,6 @@ namespace UWPHook
Apps.Entries.Add(new AppEntry() { Name = values[0], IconPath = logosPath, Aumid = values[2], Selected = false });
});
}
if (values.Length > 2)
{
if (values[2].Contains("Microsoft.SeaofThieves"))
{
values[0] = "Sea of Thieves";
}
else if (values[2].Contains("Microsoft.DeltaPC"))
{
values[0] = "Gears of War: Ultimate Edition";
}
}
}
}
catch (Exception ex)

@ -0,0 +1,4 @@
{
"Microsoft.SeaofThieves": "Sea of Thieves",
"Microsoft.DeltaPC": "Gears of War: Ultimate Edition"
}

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
@ -162,6 +162,9 @@
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
<None Include="Resources\KnownApps.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />

Loading…
Cancel
Save