Exemplo n.º 1
0
        private void CreateToastButton_Click(object sender, EventArgs e)
        {
            var actionButton = new ToastButton();

            actionButton.AddArgument("action", "buttonAction");
            actionButton.SetContent("Action Button");

            var dismissButton = new ToastButton();

            dismissButton.SetContent("Dismiss Button");
            dismissButton.SetDismissActivation();

            var toast = new ToastContentBuilder();

            toast.AddAttributionText("Attribute Text");
            toast.AddText("Title");
            toast.AddText("Text 1");
            toast.AddText("Text 2");
            toast.AddButton(actionButton);
            toast.AddButton(dismissButton);
            toast.Show(toast =>
            {
                toast.ExpirationTime = DateTime.Now.AddSeconds(5);
                toast.Priority       = Windows.UI.Notifications.ToastNotificationPriority.High;
            });
        }
Exemplo n.º 2
0
        public void ToastButtonBuilders_ProtocolActivation_ReturnSelf()
        {
            ToastButton button           = new ToastButton();
            ToastButton anotherReference = button
                                           .SetContent("View")
                                           .SetProtocolActivation(new Uri("https://msn.com"));

            Assert.AreSame(button, anotherReference);
            Assert.AreEqual("View", button.Content);
            Assert.AreEqual("https://msn.com/", button.Arguments);
            Assert.AreEqual(ToastActivationType.Protocol, button.ActivationType);
        }
Exemplo n.º 3
0
        public void ToastButtonBuilders_General_ReturnSelf()
        {
            ToastButton button           = new ToastButton();
            ToastButton anotherReference = button
                                           .SetContent("View")
                                           .AddArgument("action", "view")
                                           .AddArgument("imageId", 601);

            Assert.AreSame(button, anotherReference);
            Assert.AreEqual("View", button.Content);
            Assert.AreEqual("action=view;imageId=601", button.Arguments);
            Assert.AreEqual(ToastActivationType.Foreground, button.ActivationType);
        }
Exemplo n.º 4
0
        public void ToastButtonBuilders_AllProperties_ReturnSelf()
        {
            ToastButton button           = new ToastButton();
            ToastButton anotherReference = button
                                           .SetContent("View")
                                           .SetImageUri(new Uri("ms-appx:///Assets/view.png"))
                                           .AddArgument("action", "view")
                                           .SetBackgroundActivation()
                                           .SetAfterActivationBehavior(ToastAfterActivationBehavior.PendingUpdate)
                                           .SetHintActionId("viewImage");

            Assert.AreSame(button, anotherReference);
            Assert.AreEqual("View", button.Content);
            Assert.AreEqual("action=view", button.Arguments);
            Assert.AreEqual("ms-appx:///Assets/view.png", button.ImageUri);
            Assert.AreEqual(ToastActivationType.Background, button.ActivationType);
            Assert.AreEqual(ToastAfterActivationBehavior.PendingUpdate, button.ActivationOptions.AfterActivationBehavior);
            Assert.AreEqual("viewImage", button.HintActionId);
        }
Exemplo n.º 5
0
        private void OnRafflesWon(object sender, RafflesWonArgs e)
        {
            bool enableToast = Properties.UserConfig.Default.ToastNotifications;

            if (enableToast)
            {
                string logo = Files.LogoFile;
                if (!File.Exists(logo))
                {
                    using (var http = new HttpClient())
                    {
                        string url  = string.Format("https://scrap.tf/apple-touch-icon.png?{0}", Guid.NewGuid());
                        byte[] data = http.GetByteArrayAsync(url).Result;
                        File.WriteAllBytes(logo, data);
                    }
                }

                string message    = e.Message;
                var    viewButton = new ToastButton();
                viewButton.AddArgument("action", "viewRafflesWonPage");
                viewButton.SetContent("View Won Raffles");

                var dismissButton = new ToastButton();
                dismissButton.SetContent("Dismiss");
                dismissButton.SetDismissActivation();

                var toast = new ToastContentBuilder();
                toast.AddAppLogoOverride(new Uri(logo), ToastGenericAppLogoCrop.Circle, null, false);
                toast.AddAttributionText(string.Format("Scraps {0}", Common.Constants.Version.Full));
                toast.AddText("Items Need Withdrawing");
                toast.AddText(message);
                toast.AddButton(viewButton);
                toast.AddButton(dismissButton);
                toast.Show();
            }
        }