Пример #1
0
        private static StoreApp getAppFromNode(Windows.ApplicationModel.Package package, string packagePath,
                                               XmlNode appNode, XmlNamespaceManager xmlnsManager)
        {
            XmlNode appIdNode = appNode.SelectSingleNode("@Id", xmlnsManager);

            if (appIdNode == null)
            {
                return(null);
            }

            Dictionary <IconSize, string> icons = getIcons(packagePath, appNode, xmlnsManager);

            StoreApp storeApp = new StoreApp(package.Id.FamilyName + "!" + appIdNode.Value)
            {
                DisplayName        = getDisplayName(package.Id.Name, packagePath, appNode, xmlnsManager),
                SmallIconPath      = icons[IconSize.Small],
                MediumIconPath     = icons[IconSize.Medium],
                LargeIconPath      = icons[IconSize.Large],
                ExtraLargeIconPath = icons[IconSize.ExtraLarge],
                JumboIconPath      = icons[IconSize.Jumbo],
                IconColor          = getPlateColor(icons[IconSize.Small], appNode, xmlnsManager),
                EntryPoint         = getEntryPoint(appNode, xmlnsManager)
            };

            return(storeApp);
        }
Пример #2
0
        internal static List <StoreApp> GetStoreApps()
        {
            List <StoreApp> apps = new List <StoreApp>();

            try
            {
                foreach (Windows.ApplicationModel.Package package in getPackages(new Windows.Management.Deployment.PackageManager(), string.Empty))
                {
                    string packagePath = getPackagePath(package);

                    if (string.IsNullOrEmpty(packagePath))
                    {
                        continue;
                    }

                    XmlDocument         manifest     = getManifest(packagePath);
                    XmlNamespaceManager xmlnsManager = getNamespaceManager(manifest);
                    XmlNodeList         appNodeList  = manifest.SelectNodes("/ns:Package/ns:Applications/ns:Application",
                                                                            xmlnsManager);

                    if (appNodeList == null)
                    {
                        continue;
                    }

                    foreach (XmlNode appNode in appNodeList)
                    {
                        // packages can contain multiple apps

                        XmlNode showEntry = getXmlnsNode("uap:VisualElements/@AppListEntry", appNode, xmlnsManager);
                        if (showEntry == null || showEntry.Value.ToLower() == "true" ||
                            showEntry.Value.ToLower() == "default")
                        {
                            // App is visible in the app list
                            StoreApp storeApp = getAppFromNode(package, packagePath, appNode, xmlnsManager);

                            if (storeApp == null)
                            {
                                continue;
                            }

                            bool canAdd = true;
                            foreach (StoreApp added in apps)
                            {
                                if (added.AppUserModelId == storeApp.AppUserModelId)
                                {
                                    canAdd = false;
                                    break;
                                }
                            }

                            if (canAdd)
                            {
                                apps.Add(storeApp);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ShellLogger.Error($"StoreAppHelper: Exception retrieving apps: {e.Message}");
            }

            return(apps);
        }