mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 11:39:16 +08:00
temp hack for multipla application mismatch problem #198
e.g. mail and calendar, skype video and messaging https://github.com/Wox-launcher/Wox/issues/198#issuecomment-244778783
This commit is contained in:
parent
5ca880c8fd
commit
89a77feea7
@ -42,12 +42,10 @@ namespace Wox.Plugin.Program.Programs
|
|||||||
FullName = Package.Id.FullName;
|
FullName = Package.Id.FullName;
|
||||||
FamilyName = Package.Id.FamilyName;
|
FamilyName = Package.Id.FamilyName;
|
||||||
Location = Package.InstalledLocation.Path;
|
Location = Package.InstalledLocation.Path;
|
||||||
|
Apps = MergedApps();
|
||||||
InitializeAppDisplayInfo(package);
|
|
||||||
InitializeAppInfo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeAppInfo()
|
private Application[] AppInfos()
|
||||||
{
|
{
|
||||||
var path = Path.Combine(Location, "AppxManifest.xml");
|
var path = Path.Combine(Location, "AppxManifest.xml");
|
||||||
var appx = new AppxFactory();
|
var appx = new AppxFactory();
|
||||||
@ -66,46 +64,50 @@ namespace Wox.Plugin.Program.Programs
|
|||||||
Description = properties.GetStringValue("Description");
|
Description = properties.GetStringValue("Description");
|
||||||
|
|
||||||
var apps = reader.GetApplications();
|
var apps = reader.GetApplications();
|
||||||
int i = 0;
|
var parsedApps = new List<Application>();
|
||||||
while (apps.GetHasCurrent() != 0 && i <= Apps.Length)
|
while (apps.GetHasCurrent() != 0)
|
||||||
{
|
{
|
||||||
var current = apps.GetCurrent();
|
var current = apps.GetCurrent();
|
||||||
var appListEntry = current.GetStringValue("AppListEntry");
|
var appListEntry = current.GetStringValue("AppListEntry");
|
||||||
if (appListEntry != "nonoe")
|
if (appListEntry != "none")
|
||||||
{
|
{
|
||||||
Apps[i].UserModelId = current.GetAppUserModelId();
|
var app = new Application
|
||||||
Apps[i].BackgroundColor = current.GetStringValue("BackgroundColor") ?? string.Empty;
|
{
|
||||||
Apps[i].Location = Location;
|
UserModelId = current.GetAppUserModelId(),
|
||||||
Apps[i].Valid = !string.IsNullOrEmpty(Apps[i].UserModelId);
|
BackgroundColor = current.GetStringValue("BackgroundColor") ?? string.Empty,
|
||||||
|
Location = Location,
|
||||||
|
LogoPath = Application.LogoFromManifest(current, Location)
|
||||||
|
};
|
||||||
|
|
||||||
// todo use hidpi logo when use hidpi screen
|
app.Valid = !string.IsNullOrEmpty(app.UserModelId);
|
||||||
Apps[i].LogoPath = Application.LogoFromManifest(current, Location);
|
parsedApps.Add(app);
|
||||||
}
|
}
|
||||||
apps.MoveNext();
|
apps.MoveNext();
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
if (i != Apps.Length)
|
|
||||||
|
return parsedApps.ToArray();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
var message = $"Wrong application number - {Name}: {i}";
|
return new Application[] { };
|
||||||
Console.WriteLine(message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeAppDisplayInfo(Package package)
|
private Application[] AppDisplayInfos()
|
||||||
{
|
{
|
||||||
IReadOnlyList<AppListEntry> apps;
|
IReadOnlyList<AppListEntry> apps;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
apps = package.GetAppListEntriesAsync().AsTask().Result;
|
apps = Package.GetAppListEntriesAsync().AsTask().Result;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
var message = $"{e.Message} @ {Name}";
|
var message = $"{e.Message} @ {Name}";
|
||||||
Console.WriteLine(message);
|
Console.WriteLine(message);
|
||||||
return;
|
return new Application[] { };
|
||||||
}
|
}
|
||||||
Apps = apps.Select(a =>
|
|
||||||
|
var displayinfos = apps.Select(a =>
|
||||||
{
|
{
|
||||||
RandomAccessStreamReference logo;
|
RandomAccessStreamReference logo;
|
||||||
try
|
try
|
||||||
@ -127,8 +129,37 @@ namespace Wox.Plugin.Program.Programs
|
|||||||
LogoStream = logo
|
LogoStream = logo
|
||||||
};
|
};
|
||||||
return parsed;
|
return parsed;
|
||||||
|
}).ToArray();
|
||||||
|
|
||||||
|
return displayinfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Application[] MergedApps()
|
||||||
|
{
|
||||||
|
|
||||||
|
var infos = AppInfos();
|
||||||
|
var displayInfos = AppDisplayInfos();
|
||||||
|
|
||||||
|
if (infos.Length > 0)
|
||||||
|
{
|
||||||
|
var apps = infos;
|
||||||
|
// todo: temp hack for multipla application mismatch problem
|
||||||
|
// e.g. mail and calendar, skype video and messaging
|
||||||
|
// https://github.com/Wox-launcher/Wox/issues/198#issuecomment-244778783
|
||||||
|
var length = infos.Length;
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
var j = length - i - 1;
|
||||||
|
apps[i].DisplayName = displayInfos[j].DisplayName;
|
||||||
|
apps[i].Description = displayInfos[j].Description;
|
||||||
|
apps[i].LogoStream = displayInfos[j].LogoStream;
|
||||||
|
}
|
||||||
|
return apps;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new Application[] { };
|
||||||
}
|
}
|
||||||
).ToArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Application[] All()
|
public static Application[] All()
|
||||||
|
Loading…
Reference in New Issue
Block a user