Ejemplo n.º 1
0
        public static string GetBestLogoPath(
            ManifestInfo manifestInfo,
            ManifestApplication manifestApplication,
            string installedLocationPath)
        {
            var    findStrategy = FindLogoScaleStrategy.NeareastToCustomScale;
            string logoPath;

            if (manifestInfo.Apps.Count > 1)
            {
                // TODO: More testing if this is even necessary
                // Try to find logo based on application logo value
                logoPath = FindLogoImagePath(installedLocationPath, manifestApplication.Logo, findStrategy);
                if (!string.IsNullOrWhiteSpace(logoPath) && File.Exists(logoPath))
                {
                    return(logoPath);
                }
            }

            // Try to find logo based on package logo value
            var mainPackageLogo = manifestInfo.GetPropertyStringValue("Logo");

            logoPath = FindLogoImagePath(installedLocationPath, mainPackageLogo, findStrategy);
            if (!string.IsNullOrWhiteSpace(logoPath) && File.Exists(logoPath))
            {
                return(logoPath);
            }

            return("");
        }
Ejemplo n.º 2
0
        private static ManifestInfo GetAppInfoFromManifest(string manifestFilePath)
        {
            if (File.Exists(manifestFilePath))
            {
                var factory = (NativeApiHelper.IAppxFactory) new NativeApiHelper.AppxFactory();

                IStream manifestStream;

                NativeApiHelper.SHCreateStreamOnFileEx(manifestFilePath, STGM_SHARE_DENY_NONE, 0, false, IntPtr.Zero, out manifestStream);

                if (manifestStream != null)
                {
                    var manifestInfo = new ManifestInfo();

                    var reader     = factory.CreateManifestReader(manifestStream);
                    var properties = reader.GetProperties();

                    manifestInfo.Properties = properties;

                    var apps = reader.GetApplications();

                    while (apps.GetHasCurrent())
                    {
                        var app = apps.GetCurrent();
                        var manifestApplication = new ManifestApplication(app);

                        manifestApplication.AppListEntry      = NativeApiHelper.GetStringValue(app, "AppListEntry");
                        manifestApplication.Description       = NativeApiHelper.GetStringValue(app, "Description");
                        manifestApplication.DisplayName       = NativeApiHelper.GetStringValue(app, "DisplayName");
                        manifestApplication.EntryPoint        = NativeApiHelper.GetStringValue(app, "EntryPoint");
                        manifestApplication.Executable        = NativeApiHelper.GetStringValue(app, "Executable");
                        manifestApplication.Id                = NativeApiHelper.GetStringValue(app, "Id");
                        manifestApplication.Logo              = NativeApiHelper.GetStringValue(app, "Logo");
                        manifestApplication.SmallLogo         = NativeApiHelper.GetStringValue(app, "SmallLogo");
                        manifestApplication.StartPage         = NativeApiHelper.GetStringValue(app, "StartPage");
                        manifestApplication.Square150x150Logo = NativeApiHelper.GetStringValue(app, "Square150x150Logo");
                        manifestApplication.Square30x30Logo   = NativeApiHelper.GetStringValue(app, "Square30x30Logo");
                        manifestApplication.BackgroundColor   = NativeApiHelper.GetStringValue(app, "BackgroundColor");
                        manifestApplication.ForegroundText    = NativeApiHelper.GetStringValue(app, "ForegroundText");
                        manifestApplication.WideLogo          = NativeApiHelper.GetStringValue(app, "WideLogo");
                        manifestApplication.Wide310x310Logo   = NativeApiHelper.GetStringValue(app, "Wide310x310Logo");
                        manifestApplication.ShortName         = NativeApiHelper.GetStringValue(app, "ShortName");
                        manifestApplication.Square310x310Logo = NativeApiHelper.GetStringValue(app, "Square310x310Logo");
                        manifestApplication.Square70x70Logo   = NativeApiHelper.GetStringValue(app, "Square70x70Logo");
                        manifestApplication.MinWidth          = NativeApiHelper.GetStringValue(app, "MinWidth");
                        manifestInfo.Apps.Add(manifestApplication);
                        apps.MoveNext();
                    }
                    Marshal.ReleaseComObject(manifestStream);

                    return(manifestInfo);
                }
                else
                {
                    Debug.WriteLine("Call to SHCreateStreamOnFileEx failed on : " + manifestFilePath);
                }
            }
            else
            {
                Debug.WriteLine("Manifest File Missing: " + manifestFilePath);
            }

            return(null);
        }