Skip to content

Commit

Permalink
Should now show more Windows Store Apps
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonno12345 committed Jul 8, 2016
1 parent 7be7cca commit 580721c
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

namespace TileIconifier.Core.Custom.WindowsStoreShellMethod
{
public class WindowsStoreApp : IEqualityComparer<WindowsStoreApp>
public class WindowsStoreApp
{
public WindowsStoreApp(string displayName, string logoPath, string appUserModelId)
{
Expand All @@ -44,6 +44,10 @@ public WindowsStoreApp(string displayName, string logoPath, string appUserModelI
public string LogoPath { get; }
public string AppUserModelId { get; }

}

public class WindowsStoreAppEqualityComparer : IEqualityComparer<WindowsStoreApp>
{
public bool Equals(WindowsStoreApp x, WindowsStoreApp y)
{
if (x == null || y == null)
Expand All @@ -56,13 +60,13 @@ public bool Equals(WindowsStoreApp x, WindowsStoreApp y)
return true;

return x.DisplayName == y.DisplayName &&
x.LogoPath == y.LogoPath &&
//x.LogoPath == y.LogoPath &&
x.AppUserModelId == y.AppUserModelId;
}

public int GetHashCode(WindowsStoreApp obj)
{
return DisplayName.GetHashCode() ^ LogoPath.GetHashCode() ^ AppUserModelId.GetHashCode();
return obj.GetHashCode() ^ obj.GetHashCode() ^ obj.GetHashCode();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,53 @@ into appPackageSubKey
where !string.IsNullOrEmpty(appPackageDisplayName) && !string.IsNullOrEmpty(appPackageApplicationKey)
select new WindowsStoreApp(appPackageDisplayName, appPackageIconPath, appPackageApplicationKey)
into storeApp
where !storeApps.Contains(storeApp, storeApp)
where !storeApps.Contains(storeApp, new WindowsStoreAppEqualityComparer())
select storeApp)
{
storeApps.Add(storeApp);
}
try
{
GetAppKeysFromAlternateRegistryPath(storeApps);
}
catch
{
//ignore
}
return storeApps;
}

private static void GetAppKeysFromAlternateRegistryPath(List<WindowsStoreApp> storeApps)
{
var rootKey =
Registry.ClassesRoot.OpenSubKey("Extensions\\ContractId\\Windows.Launch\\PackageId\\");

if (rootKey == null) return;

var appPackages = rootKey.GetSubKeyNames();

foreach (var tempStoreApp in from appPackage in appPackages
let mainKey = rootKey.OpenSubKey(appPackage)
let activatableClassIdKey = mainKey?.OpenSubKey("ActivatableClassId")
where activatableClassIdKey != null
let subKeys = activatableClassIdKey.GetSubKeyNames()
where subKeys.Any()
let workingKey = activatableClassIdKey.OpenSubKey(subKeys[0])
where workingKey != null
let iconPath = GetIconPath((string) workingKey.GetValue("Icon"))
let displayName = GetDisplayName((string) workingKey.GetValue("DisplayName"))
let executionPath = GetExecutionPathFromName(appPackage) + "!" + subKeys[0]
where !string.IsNullOrEmpty(executionPath) && !string.IsNullOrEmpty(displayName)
select new WindowsStoreApp(displayName, iconPath, executionPath)
into tempStoreApp
where !storeApps.Contains(tempStoreApp, new WindowsStoreAppEqualityComparer())
select tempStoreApp)
{
storeApps.Add(tempStoreApp);
}
}


private static string ExtractStringFromPriFile(string resourcePath)
{
var stringOut = new StringBuilder(1024);
Expand Down Expand Up @@ -160,5 +199,12 @@ private static string GetDisplayName(string displayName)
displayName = ExtractStringFromPriFile(resourceTag);
return displayName;
}

private static string GetExecutionPathFromName(string name)
{
var regexPattern = @"^(.*?\..*?)_.*_(.*)$";
var regexMatch = Regex.Match(name, regexPattern, RegexOptions.Singleline);
return !regexMatch.Success ? string.Empty : $@"{regexMatch.Groups[1].Value}_{regexMatch.Groups[2].Value}";
}
}
}

0 comments on commit 580721c

Please sign in to comment.