private static ToastVisual SetupToastVisualComponent(string title, string body, string iconReference)
        {
            ToastVisual visual = new ToastVisual();

            ToastBindingGeneric bindingGeneric = new ToastBindingGeneric();

            bindingGeneric.Children.Add(new AdaptiveText {
                Text = title
            });

            if (!string.IsNullOrWhiteSpace(body))
            {
                bindingGeneric.Children.Add(new AdaptiveText {
                    Text = body
                });
            }

            if (!string.IsNullOrWhiteSpace(iconReference))
            {
                bindingGeneric.AppLogoOverride =
                    new ToastGenericAppLogo {
                    Source = iconReference, HintCrop = ToastGenericAppLogoCrop.Circle
                };
            }

            visual.BindingGeneric = bindingGeneric;
            return(visual);
        }
Exemple #2
0
        private static void AssertAdaptiveChildInToast(string expectedAdaptiveChildXml, IAdaptiveChild child)
        {
            var binding = new ToastBindingGeneric();

            // If the child isn't text, we need to add a text element so notification is valid
            if (!(child is AdaptiveText))
            {
                binding.Children.Add(new AdaptiveText()
                {
                    Text = "Required text element"
                });

                expectedAdaptiveChildXml = "<text>Required text element</text>" + expectedAdaptiveChildXml;
            }

            binding.Children.Add(child);

            var content = new ToastContent()
            {
                Visual = new ToastVisual()
                {
                    BindingGeneric = binding
                }
            };

            AssertHelper.AssertXml(
                "<toast><visual><binding template='ToastGeneric'>" + expectedAdaptiveChildXml + "</binding></visual></toast>",
                content.GetContent());
        }
Exemple #3
0
        public static void SendToast(string title = "Pixiv UWP", string content = "", string image = null, string logo = null, ToastGenericAppLogoCrop hintcrop = ToastGenericAppLogoCrop.None)
        {
            ToastVisual         visual  = new ToastVisual();
            ToastBindingGeneric generic = new ToastBindingGeneric();

            generic.Children.Add(new AdaptiveText()
            {
                Text = title
            });
            generic.Children.Add(new AdaptiveText()
            {
                Text = content
            });
            if (image != null)
            {
                generic.Children.Add(new AdaptiveImage {
                    Source = image
                });
            }
            if (logo != null)
            {
                generic.AppLogoOverride          = new ToastGenericAppLogo();
                generic.AppLogoOverride.Source   = logo;
                generic.AppLogoOverride.HintCrop = hintcrop;
            }
            visual.BindingGeneric = generic;
            ToastContent tcontent = new ToastContent()
            {
                Visual = visual
            };
            var toast = new ToastNotification(tcontent.GetXml());

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
        public static ToastContent GenerateToastContent()
        {
            // Start by constructing the visual portion of the toast
            ToastBindingGeneric binding = new ToastBindingGeneric();

            // We'll always have this summary text on our toast notification
            // (it is required that your toast starts with a text element)
            binding.Children.Add(new AdaptiveText()
            {
                Text = "Today will be mostly sunny with a high of 63 and a low of 42."
            });

            // If Adaptive Toast Notifications are supported
            if (IsAdaptiveToastSupported())
            {
                // Use the rich Tile-like visual layout
                binding.Children.Add(new AdaptiveGroup()
                {
                    Children =
                    {
                        GenerateSubgroup("Mon", "Mostly Cloudy.png", 63, 42),
                        GenerateSubgroup("Tue", "Cloudy.png",        57, 38),
                        GenerateSubgroup("Wed", "Sunny.png",         59, 43),
                        GenerateSubgroup("Thu", "Sunny.png",         62, 42),
                        GenerateSubgroup("Fri", "Sunny.png",         71, 66)
                    }
                });
            }

            // Otherwise...
            else
            {
                // We'll just add two simple lines of text
                binding.Children.Add(new AdaptiveText()
                {
                    Text = "Monday ⛅ 63° / 42°"
                });

                binding.Children.Add(new AdaptiveText()
                {
                    Text = "Tuesday ☁ 57° / 38°"
                });
            }

            // Construct the entire notification
            return(new ToastContent()
            {
                Visual = new ToastVisual()
                {
                    // Use our binding from above
                    BindingGeneric = binding,

                    // Set the base URI for the images, so we don't redundantly specify the entire path
                    BaseUri = new Uri("Assets/NotificationAssets/", UriKind.Relative)
                },

                // Include launch string so we know what to open when user clicks toast
                Launch = "action=viewForecast&zip=98008"
            });
        }
Exemple #5
0
        public void DisplayWin10Message(string message)
        {
            var binding = new ToastBindingGeneric();

            binding.Children.Add(new AdaptiveText {
                Text = message, HintWrap = true
            });

            var content = new ToastContent
            {
                Launch = "",
                Visual = new ToastVisual
                {
                    BindingGeneric = binding
                }
            };

            var xml = content.GetContent();
            var doc = new XmlDocument();

            doc.LoadXml(xml);

            var n = ToastNotificationManager.CreateToastNotifier(Constants.ApplicationId);

            n.Show(new ToastNotification(doc));
        }
 private static void AssertBindingGenericPayload(string expectedBindingXml, ToastBindingGeneric binding)
 {
     AssertVisualPayload("<visual>" + expectedBindingXml + "</visual>", new ToastVisual()
     {
         BindingGeneric = binding
     });
 }
Exemple #7
0
        public static void SendLocalNotification(string title, string message)
        {
            //VISUALS SETUP
            var bindingGeneric = new ToastBindingGeneric();

            bindingGeneric.Children.Add(new AdaptiveText()
            {
                Text = title
            });
            bindingGeneric.Children.Add(new AdaptiveText()
            {
                Text = message
            });

            var visual = new ToastVisual()
            {
                BindingGeneric = bindingGeneric
            };

            //ACTIONS SETUP

            var actions = new ToastActionsCustom();


            var more_info_button = new ToastButton("More Info",
                                                   new QueryString()
            {
                { "action", "view_details" }
            }
                                                   .ToString())
            {
                ActivationType = ToastActivationType.Foreground
            };


            actions.Buttons.Add(more_info_button);
            actions.Buttons.Add(new ToastButtonDismiss("Dismiss"));

            //CONTENT SETUP
            var content = new ToastContent()
            {
                Visual  = visual,
                Actions = actions,
                Launch  = new QueryString()
                {
                    { "action", "view_details" }
                }.ToString(),
                Scenario       = ToastScenario.Alarm,
                ActivationType = ToastActivationType.Foreground,
            };

            //TOAST SETUP
            var toast = new ToastNotification(content.GetXml())
            {
                Tag = Guid.NewGuid().ToString()
            };

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
Exemple #8
0
        /// <summary>
        /// </summary>
        /// <param name="n"> The notification on which the toast is based. </param>
        /// <returns>The toast notification.</returns>
        private static ToastNotification CreateCompleteToastNotification(INotification n)
        {
            var preGeneric = new ToastBindingGeneric();

            if (!string.IsNullOrEmpty(n.Title))
            {
                preGeneric.Children.Add(new AdaptiveText
                {
                    Text = n.Title
                });
            }

            if (!string.IsNullOrEmpty(n.Description))
            {
                preGeneric.Children.Add(new AdaptiveText
                {
                    Text = n.Description
                });
            }

            if (n.GetType() == typeof(PoiNotification))
            {
                var poi = (PoiNotification)n;
                if (!string.IsNullOrEmpty(poi.ImagePath))
                {
                    preGeneric.Children.Add(new AdaptiveImage
                    {
                        Source = poi.ImagePath
                    });
                }
            }

            return(new ToastNotification(new ToastContent
            {
                Visual = new ToastVisual {
                    BindingGeneric = preGeneric
                },
                Actions = new ToastActionsCustom
                {
                    Buttons =
                    {
                        new ToastButton("Pause", "pause")
                        {
                            ActivationType = ToastActivationType.Background
                        },
                        new ToastButton("Close", "close")
                        {
                            ActivationType = ToastActivationType.Background
                        }
                    }
                },
                Audio = new ToastAudio
                {
                    Src = new Uri("ms-winsoundevent:Notification.Reminder")
                },
                Duration = ToastDuration.Short
            }.GetXml()));
        }
Exemple #9
0
        public static void SendToast(ToastBindingGeneric generic)
        {
            ToastVisual visual = new ToastVisual();

            visual.BindingGeneric = generic;
            ToastContent tcontent = new ToastContent()
            {
                Visual = visual
            };
            var toast = new ToastNotification(tcontent.GetXml());

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
Exemple #10
0
        private ToastContent BuildNotification(List <ResponsiveNotificationText> messages)
        {
            ToastVisual         root    = new ToastVisual();
            ToastBindingGeneric binding = new ToastBindingGeneric();

            root.BindingGeneric = binding;

            var results  = messages.ElementAt(0);
            var fixtures = messages.ElementAt(1);

            if (!fixtures.Matches.Any() && !results.Matches.Any())
            {
                return(null);
            }

            foreach (var notificationGroup in messages)
            {
                if (notificationGroup.Matches.Any())
                {
                    var group    = new AdaptiveGroup();
                    var subgroup = new AdaptiveSubgroup()
                    {
                        HintTextStacking = AdaptiveSubgroupTextStacking.Center
                    };
                    subgroup.Children.Add(new AdaptiveText()
                    {
                        Text      = notificationGroup.MatchType,
                        HintStyle = AdaptiveTextStyle.Subtitle
                    });
                    foreach (var match in notificationGroup.Matches)
                    {
                        subgroup.Children.Add(new AdaptiveText()
                        {
                            Text      = match,
                            HintStyle = AdaptiveTextStyle.BaseSubtle
                        });
                    }
                    group.Children.Add(subgroup);
                    binding.Children.Add(group);
                }
            }
            return(new ToastContent()
            {
                Visual = root
            });
        }
Exemple #11
0
        public static void SendMessageNotification(SignalMessage message)
        {
            // notification tags can only be 16 chars (64 after creators update)
            // https://docs.microsoft.com/en-us/uwp/api/Windows.UI.Notifications.ToastNotification#Windows_UI_Notifications_ToastNotification_Tag
            string notificationId            = message.ThreadId;
            ToastBindingGeneric toastBinding = new ToastBindingGeneric()
            {
                AppLogoOverride = new ToastGenericAppLogo()
                {
                    Source   = "ms-appx:///Assets/LargeTile.scale-100.png",
                    HintCrop = ToastGenericAppLogoCrop.Circle
                }
            };

            var notificationText = GetNotificationText(message);

            foreach (var item in notificationText)
            {
                toastBinding.Children.Add(item);
            }

            ToastContent toastContent = new ToastContent()
            {
                Launch = notificationId,
                Visual = new ToastVisual()
                {
                    BindingGeneric = toastBinding
                },
                DisplayTimestamp = DateTimeOffset.FromUnixTimeMilliseconds(message.ReceivedTimestamp)
            };

            ToastNotification toastNotification = new ToastNotification(toastContent.GetXml());

            if (message.Author.ExpiresInSeconds > 0)
            {
                toastNotification.ExpirationTime = DateTime.Now.Add(TimeSpan.FromSeconds(message.Author.ExpiresInSeconds));
            }
            toastNotification.Tag = notificationId;
            ToastNotificationManager.CreateToastNotifier().Show(toastNotification);
        }
Exemple #12
0
        private void Handle_SignalMessageEvent(object sender, SignalMessageEventArgs e)
        {
            if (e.MessageType == Lib.Events.SignalMessageType.NormalMessage)
            {
                string notificationId            = e.Message.ThreadId;
                ToastBindingGeneric toastBinding = new ToastBindingGeneric();

                var notificationText = GetNotificationText(e.Message.Author.ThreadDisplayName, e.Message.Content.Content);
                foreach (var item in notificationText)
                {
                    toastBinding.Children.Add(item);
                }

                ToastContent toastContent = new ToastContent()
                {
                    Launch = notificationId,
                    Visual = new ToastVisual()
                    {
                        BindingGeneric = toastBinding
                    },
                    DisplayTimestamp = DateTimeOffset.FromUnixTimeMilliseconds(e.Message.ReceivedTimestamp)
                };

                ToastNotification toastNotification = new ToastNotification(toastContent.GetXml());
                uint expiresIn = e.Message.ExpiresAt;
                if (expiresIn > 0)
                {
                    toastNotification.ExpirationTime = DateTime.Now.Add(TimeSpan.FromSeconds(expiresIn));
                }
                toastNotification.Tag = notificationId;
                ToastNotifier.Show(toastNotification);
            }
            else if (e.MessageType == Lib.Events.SignalMessageType.PipeEmptyMessage)
            {
                Logger.LogInformation("Background task has drained the pipe");
                ResetEvent.Set();
            }
        }
        private static ToastContent GenerateToastContent(string title, CatalogItemModel item)
        {
            var binding = new ToastBindingGeneric
            {
                Children =
                {
                    new AdaptiveText
                    {
                        Text = title
                    },
                    new AdaptiveText
                    {
                        Text = item.Name
                    },
                    new AdaptiveText
                    {
                        Text = item.Description
                    }
                }
            };

            if (!string.IsNullOrEmpty(item.PictureUri))
            {
                binding.Children.Add(new AdaptiveImage
                {
                    Source = item.PictureUri
                });
            }

            return(new ToastContent
            {
                Launch = item.Id.ToString(),
                Visual = new ToastVisual
                {
                    BindingGeneric = binding
                }
            });
        }
Exemple #14
0
        internal static ToastContent GenerateToastContentSimpleAutoHide(string AdaptiveTitle, string Adaptive2, string Adaptive3)
        {
            // Start by constructing the visual portion of the toast
            ToastBindingGeneric binding = new ToastBindingGeneric();

            // We'll always have this summary text on our toast notification
            // (it is required that your toast starts with a text element)
            binding.Children.Add(new AdaptiveText()
            {
                Text = AdaptiveTitle
            });

            // We'll just add two simple lines of text
            binding.Children.Add(new AdaptiveText()
            {
                Text = Adaptive2
            });

            binding.Children.Add(new AdaptiveText()
            {
                Text = Adaptive3
            });

            // Construct the entire notification
            return(new ToastContent()
            {
                ActivationType = ToastActivationType.Foreground,
                Visual = new ToastVisual()
                {
                    // Use our binding from above
                    BindingGeneric = binding,
                },
                // Include launch string so we know what to open when user clicks toast
                Launch = "action=viewForecast&zip=98008"
                         //The argument is = action=viewForecast&zip=98008
            });
        }
        private static void AssertAdaptiveChildInToast(string expectedAdaptiveChildXml, IAdaptiveChild child)
        {
            var binding = new ToastBindingGeneric();

            // If the child isn't text, we need to add a text element so notification is valid
            if (!(child is AdaptiveText))
            {
                binding.Children.Add(new AdaptiveText()
                {
                    Text = "Required text element"
                });

                expectedAdaptiveChildXml = "<text>Required text element</text>" + expectedAdaptiveChildXml;
            }

            binding.Children.Add(child);

            var content = new ToastContent()
            {
                Visual = new ToastVisual()
                {
                    BindingGeneric = binding
                }
            };

            AssertHelper.AssertXml(
                "<toast><visual><binding template='ToastGeneric'>" + expectedAdaptiveChildXml + "</binding></visual></toast>",
                content.GetContent());
        }
Exemple #16
0
        /// <summary>
        /// Send adaptive toast, including now playing item, to Action Center.
        /// </summary>
        /// <param name="file">To file to be sent.</param>
        public static void SendAdaptiveToast(DbMediaFile file)
        {
            if (file == null)
            {
                return;
            }
            if (IsAdaptiveToastSupported())
            {
                // Start by constructing the visual portion of the toast
                var binding = new ToastBindingGeneric();

                binding.AppLogoOverride = new ToastGenericAppLogo
                {
                    Source        = "DefaultCover.png",
                    AlternateText = "Light Player logo"
                };

                binding.Children.Add(new AdaptiveText
                {
                    Text         = $"Now Playing: {file.Title}",
                    HintMaxLines = 1,
                    HintStyle    = AdaptiveTextStyle.Default
                });

                binding.Children.Add(new AdaptiveGroup
                {
                    Children =
                    {
                        new AdaptiveSubgroup
                        {
                            HintWeight = 1,
                            Children   =
                            {
                                new AdaptiveText
                                {
                                    Text         = $"{file.Album} - {file.Artist}",
                                    HintMaxLines = 2,
                                    HintStyle    = AdaptiveTextStyle.CaptionSubtle
                                }
                            }
                        }
                    }
                });

                // Construct the entire notification
                var content = new ToastContent
                {
                    Visual = new ToastVisual
                    {
                        // Use our binding from above
                        BindingGeneric = binding,
                        // Set the base URI for the images, so we don't redundantly specify the entire path
                        BaseUri = new Uri("Assets/", UriKind.Relative)
                    },
                    // Include launch string so we know what to open when user clicks toast
                    Launch   = "action=viewNowPlaying",
                    Duration = ToastDuration.Short,
                    Audio    = new ToastAudio
                    {
                        Silent = true
                    }
                };

                try
                {
                    // Make sure all cleared before we send new toasts
                    ToastNotificationManager.History.Clear();
                    // Generate the toast notification content and pop the toast
                    var toastNotifier = ToastNotificationManager.CreateToastNotifier();
                    if (toastNotifier.Setting == NotificationSetting.Enabled)
                    {
                        var notification = new ToastNotification(content.GetXml());
                        // Only show in action center
                        notification.SuppressPopup = true;
                        // Now playing item should not be available for roaming
                        notification.NotificationMirroring = NotificationMirroring.Disabled;
                        toastNotifier.Show(notification);
                    }
                }
                catch (Exception ex)
                {
                    TelemetryHelper.TrackExceptionAsync(ex);
                }
            }
        }
Exemple #17
0
        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);
        }
 private static void AssertBindingGenericPayload(string expectedBindingXml, ToastBindingGeneric binding)
 {
     AssertVisualPayload("<visual>" + expectedBindingXml + "</visual>", new ToastVisual()
     {
         BindingGeneric = binding
     });
 }
 private static void AssertBindingGenericProperty(string expectedPropertyName, string expectedPropertyValue, ToastBindingGeneric binding)
 {
     AssertBindingGenericPayload($"<binding template='ToastGeneric' {expectedPropertyName}='{expectedPropertyValue}'/>", binding);
 }
        public ToastNotification CreateCallNotification(IEnumerable <Call> currentCalls)
        {
            List <Call>         calls   = currentCalls.Where(x => x.State != CallState.Disconnected && x.State != CallState.Indeterminate).OrderBy(x => x.State).ToList();
            ToastBindingGeneric content = new ToastBindingGeneric();
            ToastActionsCustom  actions = new ToastActionsCustom();

            switch (calls.Count)
            {
            case 0:
                return(null);

            case 1:
                Call singleCall = calls.First();
                foreach (IToastBindingGenericChild child in CreateVisualForCall(singleCall))
                {
                    content.Children.Add(child);
                }
                foreach (IToastButton button in CreateButtonsForCall(singleCall))
                {
                    actions.Buttons.Add(button);
                }
                break;

            default:
                content.Children.Add(new AdaptiveText()
                {
                    Text = "Dialer - Active calls"
                });
                for (int i0 = 0; i0 < calls.Count / 2; i0++)
                {
                    AdaptiveGroup group = new AdaptiveGroup();
                    for (int i1 = i0 * 2; i1 < i0 * 2 + 2 && i1 < calls.Count; i1++)
                    {
                        AdaptiveSubgroup subgroup = new AdaptiveSubgroup();
                        foreach (IAdaptiveSubgroupChild child in CreateVisualForCall(calls[i1]))
                        {
                            subgroup.Children.Add(child);
                        }
                        group.Children.Add(subgroup);
                    }
                    content.Children.Add(group);
                }
                foreach (IToastButton button in MergeButtons(calls.Select(x => CreateButtonsForCall(x)).SelectMany(x => x)))
                {
                    actions.Buttons.Add(button);
                }
                break;
            }
            Call         incomingCall = calls.FirstOrDefault(x => x.State == CallState.Incoming);
            bool         hasRingTone  = !string.IsNullOrEmpty(incomingCall?.Contact?.RingToneToken);
            ToastContent toastContent = new ToastContent()
            {
                Visual = new ToastVisual()
                {
                    BindingGeneric = content
                },
                Actions = actions,
                Audio   = new ToastAudio()
                {
                    Silent = calls.Any(x => x.State != CallState.Incoming),
                    Loop   = true,
                    Src    = hasRingTone ? new Uri(incomingCall.Contact.RingToneToken) : null
                },
                Launch   = $"{ACTION}={SHOW_CALL_UI}",
                Scenario = ToastScenario.IncomingCall
            };
            ToastNotification notification = new ToastNotification(toastContent.GetXml())
            {
                Tag             = CALL_NOTIFICATION_UI,
                ExpiresOnReboot = true,
                Priority        = ToastNotificationPriority.High,
                Data            = new NotificationData()
                {
                    Values =
                    {
                        { USED_CALLS,        calls.Aggregate(new StringBuilder(), (x, y) => x.Append(y.ID).Append(';'),          x => x.ToString()) },
                        { USED_CALLS_STATES, calls.Aggregate(new StringBuilder(), (x, y) => x.Append((uint)y.State).Append(';'), x => x.ToString()) }
                    }
                }
            };

            return(notification);
        }
Exemple #21
0
        private static XmlDocument GenerateToastReminder(string title, string item1, string item2, string launch, string markCompleteArgs = null)
        {
            ToastBindingGeneric binding = new ToastBindingGeneric()
            {
                Children =
                {
                    new AdaptiveText()
                    {
                        Text = UWPNotificationsHelper.StripInvalidCharacters(title)
                    }
                }
            };

            if (item1 != null)
            {
                binding.Children.Add(new AdaptiveText()
                {
                    Text = UWPNotificationsHelper.StripInvalidCharacters(item1)
                });
            }

            if (item2 != null)
            {
                binding.Children.Add(new AdaptiveText()
                {
                    Text = UWPNotificationsHelper.StripInvalidCharacters(item2)
                });
            }

            ToastContent content = new ToastContent()
            {
                Launch   = launch,
                Scenario = ToastScenario.Reminder,
                Visual   = new ToastVisual()
                {
                    BindingGeneric = binding
                },

                Actions = new ToastActionsCustom()
                {
                    Inputs =
                    {
                        new ToastSelectionBox("1")
                        {
                            Items =
                            {
                                new ToastSelectionBoxItem("5",    PowerPlannerResources.GetXMinutes(5)),
                                new ToastSelectionBoxItem("15",   PowerPlannerResources.GetXMinutes(5)),
                                new ToastSelectionBoxItem("60",   PowerPlannerResources.GetXHours(1)),
                                new ToastSelectionBoxItem("240",  PowerPlannerResources.GetXHours(4)),
                                new ToastSelectionBoxItem("1440", PowerPlannerResources.GetString("String_OneDay"))
                            },

                            DefaultSelectionBoxItemId = "15"
                        }
                    },

                    Buttons =
                    {
                        new ToastButtonSnooze()
                        {
                            SelectionBoxId = "1"
                        },

                        new ToastButtonDismiss()
                    }
                }
            };

            if (markCompleteArgs != null)
            {
                (content.Actions as ToastActionsCustom).Buttons.Insert(0, new ToastButton(PowerPlannerResources.GetString("String_Complete"), markCompleteArgs)
                {
                    ActivationType = ToastActivationType.Background
                });
            }

            return(content.GetXml());
        }
        private static XmlDocument GenerateToastReminder(string title, string item1, string item2, string launch)
        {
            ToastBindingGeneric binding = new ToastBindingGeneric()
            {
                Children =
                {
                    new AdaptiveText()
                    {
                        Text = title
                    }
                }
            };

            if (item1 != null)
            {
                binding.Children.Add(new AdaptiveText()
                {
                    Text = item1
                });
            }

            if (item2 != null)
            {
                binding.Children.Add(new AdaptiveText()
                {
                    Text = item2
                });
            }

            ToastContent content = new ToastContent()
            {
                Launch   = launch,
                Scenario = ToastScenario.Reminder,
                Visual   = new ToastVisual()
                {
                    BindingGeneric = binding
                },

                Actions = new ToastActionsCustom()
                {
                    Inputs =
                    {
                        new ToastSelectionBox("1")
                        {
                            Items =
                            {
                                new ToastSelectionBoxItem("5",    "5 minutes"),
                                new ToastSelectionBoxItem("15",   "15 minutes"),
                                new ToastSelectionBoxItem("60",   "1 hour"),
                                new ToastSelectionBoxItem("240",  "4 hours"),
                                new ToastSelectionBoxItem("1440", "1 day")
                            },

                            DefaultSelectionBoxItemId = "5"
                        }
                    },

                    Buttons =
                    {
                        new ToastButtonSnooze()
                        {
                            SelectionBoxId = "1"
                        },

                        new ToastButtonDismiss()
                    }
                }
            };

            //XmlDocument doc = new XmlDocument();
            //doc.LoadXml(content.GetContent());

            //return doc;
            return(content.GetXml());
        }
 private static void AssertBindingGenericProperty(string expectedPropertyName, string expectedPropertyValue, ToastBindingGeneric binding)
 {
     AssertBindingGenericPayload($"<binding template='ToastGeneric' {expectedPropertyName}='{expectedPropertyValue}'/>", binding);
 }