예제 #1
0
        /// <summary>
        /// Retrieve the icon of a Windows Store app
        /// </summary>
        /// <param name="package">The Windows Store package</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        private async Task <BitmapImage> GetWindowsStoreIconAsync(WindowsStoreApp package)
        {
            Requires.NotNull(package, nameof(package));

            // if the AppDetails has not been loaded yet and that the icon is requested, to don't make the use wait, we just return null.
            if (package.AppDetails == null)
            {
                return(null);
            }

            var appIcon = package.AppDetails.DisplayInfo.GetLogo(new Windows.Foundation.Size(Consts.WindowsIconsSize * 2, Consts.WindowsIconsSize * 2));
            var stream  = await appIcon.OpenReadAsync().AsTask().ConfigureAwait(false);

            using (var reader = new DataReader(stream.GetInputStreamAt(0)))
            {
                await reader.LoadAsync((uint)stream.Size);

                var bytes = new byte[stream.Size];
                reader.ReadBytes(bytes);
                using (var ms = new MemoryStream(bytes))
                {
                    var image = new BitmapImage();
                    image.BeginInit();
                    image.CacheOption       = BitmapCacheOption.OnLoad;
                    image.DecodePixelHeight = Consts.WindowsIconsSize * 2;
                    image.StreamSource      = ms;
                    image.EndInit();
                    image.Freeze();
                    return(image);
                }
            }
        }
예제 #2
0
        /// <inheritdoc/>
        public void Initialize(IServiceSettingProvider settingProvider)
        {
            WindowsList = new List <Window>();

            using (Logger.Instance.Stopwatch($"{GetType().Name} is retreiving Windows Store apps information."))
            {
                try
                {
                    // We retrieve the installed Windows Store apps.
                    var packageManager = new PackageManager();
                    var packages       = packageManager.FindPackagesForUser("");

                    foreach (var package in packages)
                    {
                        var app = new WindowsStoreApp(package);
                        app.InitializeAsync().Wait();
                        _windowsStoreApps.Add(app);
                    }
                }
                catch
                {
                    Logger.Instance.Information($"{GetType().Name} has failed to retrieve Windows Store apps information.");
                }

                Logger.Instance.Information($"{GetType().Name} has found {_windowsStoreApps.Count} Windows Store apps.");
            }

            Logger.Instance.Information($"{GetType().Name} initialized.");
        }
 public WindowsStoreAppListViewItemGroup(WindowsStoreApp windowsStoreApp)
 {
     WindowsStoreApp = windowsStoreApp;
     Text = windowsStoreApp.DisplayName;
 }
예제 #4
0
 public WindowsStoreAppListViewItemGroup(WindowsStoreApp windowsStoreApp)
 {
     WindowsStoreApp = windowsStoreApp;
     Text            = windowsStoreApp.DisplayName;
 }