Example #1
0
 public static ToastContent CreateAlarmToast(string[] str, CitySettingsModel currentCityModel)
 {
     var lo = new ResourceLoader();
     var action = new ToastActionsCustom();
     var button = new ToastButton(lo.GetString("Known"), "Today_Alarm_Dismiss");
     button.ActivationType = ToastActivationType.Background;
     action.Buttons.Add(button);
     action.Buttons.Add(new ToastButtonDismiss(lo.GetString("Okay")));
     ToastContent t = new ToastContent()
     {
         Scenario = ToastScenario.Reminder,
         Launch = currentCityModel.Id,
         Actions = action,
         Visual = new ToastVisual()
         {
             TitleText = new ToastText()
             {
                 Text = str[0]
             },
             BodyTextLine1 = new ToastText()
             {
                 Text = str[1]
             }
         }
     };
     return t;
 }
Example #2
0
 public static ToastContent CreateAlertToast(HeWeatherModel fetchresult, CitySettingsModel currentCityModel)
 {
     var lo = new ResourceLoader();
     var action = new ToastActionsCustom();
     var button = new ToastButton(lo.GetString("Known"), "Today_Alert_Dismiss");
     button.ActivationType = ToastActivationType.Background;
     action.Buttons.Add(button);
     action.Buttons.Add(new ToastButtonDismiss(lo.GetString("Dismiss")));
     var alarm = fetchresult.Alarms[0];
     ToastContent t = new ToastContent()
     {
         Scenario = ToastScenario.Reminder,
         Launch = currentCityModel.Id,
         Actions = action,
         Visual = new ToastVisual()
         {
             TitleText = new ToastText()
             {
                 Text = alarm.Title
             },
             BodyTextLine1 = new ToastText()
             {
                 Text = alarm.Text
             }
         }
     };
     return t;
 }
        public void Test_Toast_Xml_Button_ImageUri_Value()
        {
            ToastButton button = new ToastButton("my content", "myArgs")
            {
                ImageUri = "Assets/button.png"
            };

            AssertButtonPayload("<action content='my content' arguments='myArgs' imageUri='Assets/button.png' />", button);
        }
        public void Test_Toast_Xml_Button_TextBoxId_Value()
        {
            ToastButton button = new ToastButton("my content", "myArgs")
            {
                TextBoxId = "myTextBox"
            };

            AssertButtonPayload("<action content='my content' arguments='myArgs' hint-inputId='myTextBox' />", button);
        }
        public void Test_Toast_Xml_Button_Defaults()
        {
            ToastButton button = new ToastButton("my content", "myArgs");

            AssertButtonPayload("<action content='my content' arguments='myArgs' />", button);
        }
        public void Test_Toast_Xml_Button_ActivationType_Protocol()
        {
            ToastButton button = new ToastButton("my content", "myArgs")
            {
                ActivationType = ToastActivationType.Protocol
            };

            AssertButtonPayload("<action content='my content' arguments='myArgs' activationType='protocol' />", button);
        }
        public void Test_Toast_Xml_Button_ActivationType_Foreground()
        {
            ToastButton button = new ToastButton("my content", "myArgs")
            {
                ActivationType = ToastActivationType.Foreground
            };

            AssertButtonPayload("<action content='my content' arguments='myArgs' />", button);
        }
        private void OnSendNotificationWithExtension(object sender, RoutedEventArgs e)
        {
            ToastVisual visual = new ToastVisual
            {
                AppLogoOverride = new ToastAppLogo
                {
                    Crop = ToastImageCrop.None,
                    Source = new ToastImageSource("ms-appx:///Assets/MicrosoftLogo.png")
                },
                TitleText = new ToastText
                {
                    Text = "DotNet Spain Conference"
                },
                BodyTextLine1 = new ToastText
                {
                    Text = "How much do you like my session ?"
                }
            };

            ToastSelectionBox selection = new ToastSelectionBox("rating");
            selection.Items.Add(new ToastSelectionBoxItem("1", "1 (Not very much)"));
            selection.Items.Add(new ToastSelectionBoxItem("2", "2"));
            selection.Items.Add(new ToastSelectionBoxItem("3", "3"));
            selection.Items.Add(new ToastSelectionBoxItem("4", "4"));
            selection.Items.Add(new ToastSelectionBoxItem("5", "5 (A lot!)"));

            ToastButton button = new ToastButton("Vote", "vote");
            button.ActivationType = ToastActivationType.Background;

            ToastContent toast = new ToastContent
            {
                Visual = visual,
                ActivationType = ToastActivationType.Background,
                Actions = new ToastActionsCustom
                {
                    Inputs = {selection},
                    Buttons = { button }
                }
            };

            XmlDocument doc = toast.GetXml();
            ToastNotification notification = new ToastNotification(doc);
            ToastNotificationManager.CreateToastNotifier().Show(notification);
        }
 private static void AssertButtonPayload(string expectedButtonXml, ToastButton button)
 {
     AssertActionsPayload("<actions>" + expectedButtonXml + "</actions>", new ToastActionsCustom()
     {
         Buttons = { button }
     });
 }