コード例 #1
0
ファイル: PackageHelper.cs プロジェクト: yoshiask/FluentStore
        public static void HandlePackageInstallCompletedToast(SuccessMessage m, ToastNotification progressToast)
        {
            if (!OperatingSystem.IsWindowsVersionAtLeast(10, 0, 18362))
            {
                return;
            }

            PackageBase package = (PackageBase)m.Context;

            var builder = new ToastContentBuilder().SetToastScenario(ToastScenario.Reminder)
                          .AddToastActivationInfo($"package/{package.Urn}", ToastActivationType.Foreground)
                          .AddText(package.ShortTitle)
                          .AddText(package.Title + " just got installed.");

            try
            {
                if (package.GetAppIcon().Result is SDK.Images.FileImage image && !image.Uri.IsFile)
                {
                    builder.AddAppLogoOverride(image.Uri, addImageQuery: false);
                }
            }
            finally { }

            var notif = new ToastNotification(builder.GetXml());

            // Hide progress notification
            Hide(progressToast);
            // Show the final notification
            ToastNotificationManager.GetDefault().CreateToastNotifier().Show(notif);
        }
コード例 #2
0
ファイル: PackageHelper.cs プロジェクト: yoshiask/FluentStore
        public static ToastNotification GenerateDownloadFailureToast(PackageBase package)
        {
            if (!OperatingSystem.IsWindowsVersionAtLeast(10, 0, 18362))
            {
                return(null);
            }

            var builder = new ToastContentBuilder().SetToastScenario(ToastScenario.Reminder)
                          .AddToastActivationInfo($"package/{package.Urn}", ToastActivationType.Foreground)
                          .AddText(package.Title)
                          .AddText("Failed to download, please try again later");

            if (package.GetAppIcon().Result is SDK.Images.FileImage image && !image.Uri.IsFile)
            {
                builder.AddAppLogoOverride(image.Uri, addImageQuery: false);
            }

            return(new ToastNotification(builder.GetXml()));
        }
コード例 #3
0
ファイル: PackageHelper.cs プロジェクト: yoshiask/FluentStore
        public static ToastNotification GenerateProgressToast(PackageBase package)
        {
            if (!OperatingSystem.IsWindowsVersionAtLeast(10, 0, 18362))
            {
                return(null);
            }

            var visualBinding = new ToastBindingGeneric
            {
                Children =
                {
                    new AdaptiveText
                    {
                        Text = new BindableString("progressTitle")
                    },
                    new AdaptiveProgressBar
                    {
                        Value  = new BindableProgressBarValue("progressValue"),
                        Title  = new BindableString("progressVersion"),
                        Status = new BindableString("progressStatus")
                    }
                },
            };

            if (package.GetAppIcon().Result is SDK.Images.FileImage image && !image.Uri.IsFile)
            {
                visualBinding.AppLogoOverride = new ToastGenericAppLogo
                {
                    Source = image.Url
                };
            }

            var content = new ToastContent
            {
                Visual = new ToastVisual
                {
                    BindingGeneric = visualBinding
                },
                // TODO: Add cancel and pause functionality
                //Actions = new ToastActionsCustom()
                //{
                //    Buttons =
                //    {
                //        new ToastButton("Pause", $"action=pauseDownload&packageName={package.PackageMoniker}")
                //        {
                //            ActivationType = ToastActivationType.Background
                //        },
                //        new ToastButton("Cancel", $"action=cancelDownload&packageName={package.PackageMoniker}")
                //        {
                //            ActivationType = ToastActivationType.Background
                //        }
                //    }
                //},
                Launch = $"package/{package.Urn}",
            };

            var notif = new ToastNotification(content.GetXml());

            notif.Data = new NotificationData(new Dictionary <string, string>()
            {
                { "progressTitle", package.Title },
                { "progressVersion", package.Version?.ToString() ?? string.Empty },
                { "progressStatus", "Downloading..." }
            });
            return(notif);
        }