예제 #1
0
        private void SendUpdate_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(ReplacementText.Text))
            {
                rootPage.NotifyUser("Replacement text is empty.\nEnter a value in the TextBox.", NotifyType.ErrorMessage);
                return;
            }

            // Use a helper method to check whether I can send a toast.
            // Note: If this check wasn't here, the code would fail silently.
            if (MySampleHelper.CanSendToasts())
            {
                string updatedMessage = String.Format("Blue Yonder (BYA) ${0} {1}", ReplacementText.Text, DateTime.Now.ToString("t"));

                // Use a helper method to create a new ToastNotification.
                ToastNotification toast = MySampleHelper.CreateTextOnlyToast("Scenario 5", updatedMessage);

                // Set SuppressPopup = true on the toast in order to send the toast directly to action center without
                // producing a popup on the user's phone.
                toast.SuppressPopup = true;

                // If a toast exists in action center with the following Tag and Group values, it will be replaced
                // when we send this toast.
                toast.Tag   = "BYA";
                toast.Group = "DailyStockPrices";

                // Send the toast.
                ToastNotificationManager.CreateToastNotifier().Show(toast);

                rootPage.NotifyUser("Original notification has been updated.\nOpen the action center to view it", NotifyType.StatusMessage);
            }
        }
        private void Queue_Click(object sender, RoutedEventArgs e)
        {
            // Use a helper method to check whether I can send a toast.
            // Note: If this check wasn't here, the code would fail silently.
            if (MySampleHelper.CanSendToasts())
            {
                // Send multiple toasts to action center
                for (int i = 0; i < numberToastsToSend; i++)
                {
                    // Use a helper method to create a new ToastNotification.
                    ToastNotification toast = MySampleHelper.CreateTextOnlyToast("Scenario 3", String.Format("message {0}", toastIndex));

                    // Set SuppressPopup = true on the toast in order to send it directly to action center without
                    // producing a popup on the user's phone.
                    toast.SuppressPopup = true;

                    // Send the toast.
                    ToastNotificationManager.CreateToastNotifier().Show(toast);
                    toastIndex++;
                }

                // Tell the user that the toast was sent successfully.
                // This can be ommitted in a real app.
                MySampleHelper.ShowSuccessMessage(String.Format("We sent {0} toasts to action center.\nThe last 20 notifications will be shown in action center, followed by a \"More Notifications\" message to indicate that the app sent more toasts than are shown.", numberToastsToSend));
            }
        }
        private void DisplayToast_Click(object sender, RoutedEventArgs e)
        {
            // Use a helper method to check whether I can send a toast.
            // Note: If this check wasn't here, the code would fail silently.
            if (MySampleHelper.CanSendToasts())
            {
                // Use a helper method to create a new ToastNotification.
                // Each time we run this code, we'll append the count (toastIndex in this example) to the message
                // so that it can be seen as a unique message in the action center. This is not mandatory - we
                // do it here for educational purposes.
                ToastNotification toast = MySampleHelper.CreateTextOnlyToast("Scenario 1", String.Format("message {0}", toastIndex));

                // Optional. Setting an expiration time on a toast notification defines the maximum
                // time the notification will be displayed in action center before it expires and is removed.
                // If this property is not set, the notification expires after 7 days and is removed.
                // Tapping on a toast in action center launches the app and removes it immediately from action center.
                toast.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(3600);

                // Display the toast.
                ToastNotificationManager.CreateToastNotifier().Show(toast);
                toastIndex++;

                // Tell the user that the toast was sent successfully.
                // This can be ommitted in a real app.
                MySampleHelper.ShowSuccessMessage();
            }
        }
        private void SampleToasts_Click(object sender, RoutedEventArgs e)
        {
            // Use a helper method to check whether I can send a toast.
            // Note: If this check wasn't here, the code would fail silently.
            if (MySampleHelper.CanSendToasts())
            {
                // Create the notifier once
                var notifier = ToastNotificationManager.CreateToastNotifier();

                // Use a helper method to create a new ToastNotification.
                ToastNotification toast = MySampleHelper.CreateTextOnlyToast("Scenario 4", "msg Tag=\"T1\", Group=\"G1\"");

                // Set SuppressPopup = true on the toast in order to send it directly to action center without
                // producing a popup on the user's phone.
                toast.SuppressPopup = true;

                toast.Tag   = "T1";
                toast.Group = "G1";

                // Send the toast.
                notifier.Show(toast);

                toast = MySampleHelper.CreateTextOnlyToast("Scenario 4", "msg with Tag=\"T2\"");

                // Set SuppressPopup = true on the toast in order to send it directly to action center without
                // producing a popup on the user's phone.
                toast.SuppressPopup = true;

                toast.Tag = "T2";

                // Send the toast.
                notifier.Show(toast);

                toast = MySampleHelper.CreateTextOnlyToast("Scenario 4", "msg with Tag=\"T1\", Group=\"G2\"");

                // Set SuppressPopup = true on the toast in order to send it directly to action center without
                // producing a popup on the user's phone.
                toast.SuppressPopup = true;

                toast.Tag   = "T1";
                toast.Group = "G2";

                // Send the toast.
                notifier.Show(toast);

                toast = MySampleHelper.CreateTextOnlyToast("Scenario 4", "message with no Tag or Group");

                // Set SuppressPopup = true on the toast in order to send it directly to action center without
                // producing a popup on the user's phone.
                toast.SuppressPopup = true;

                // Send the toast.
                notifier.Show(toast);

                // Tell the user that the toast was sent successfully.
                // This can be ommitted in a real app.
                rootPage.NotifyUser("Sample toasts sent.\nYou can now try the remove actions.", NotifyType.StatusMessage);
            }
        }
        private void DisplayToast_Click(object sender, RoutedEventArgs e)
        {
            // Use a helper method to check whether I can send a toast.
            // Note: If this check wasn't here, the code would fail silently.
            if (MySampleHelper.CanSendToasts())
            {
                // Use a helper method to create a new ToastNotification.
                ToastNotification toast = MySampleHelper.CreateTextOnlyToast("Scenario 2", String.Format("message {0}", toastIndex));

                // Set SuppressPopup = true on the toast in order to send it directly to action center without
                // producing a popup on the user's phone.
                toast.SuppressPopup = true;

                // Send the toast.
                ToastNotificationManager.CreateToastNotifier().Show(toast);
                toastIndex++;

                // Tell the user that the toast was sent successfully.
                // This can be ommitted in a real app.
                MySampleHelper.ShowSuccessMessage();
            }
        }
예제 #6
0
        private void SendOriginal_Click(object sender, RoutedEventArgs e)
        {
            // Use a helper method to check whether I can send a toast.
            // Note: If this check wasn't here, the code would fail silently.
            if (MySampleHelper.CanSendToasts())
            {
                // Use a helper method to create a new ToastNotification.
                ToastNotification toast = MySampleHelper.CreateTextOnlyToast("Scenario 5", OriginalText.Text);

                // Set SuppressPopup = true on the toast in order to send it directly to action center without
                // producing a popup on the user's phone.
                toast.SuppressPopup = true;

                // Set the toast's Tag and Group properties so that it can be identified and replaced when we send another
                // toast with the same Tag and Group values.
                toast.Tag   = "BYA";
                toast.Group = "DailyStockPrices";

                // Send the toast.
                ToastNotificationManager.CreateToastNotifier().Show(toast);

                rootPage.NotifyUser("Original notification sent.\nOpen the action center to view it", NotifyType.StatusMessage);
            }
        }