public void ShowToast(string title, string content, ToastAuidoType auidoType, uint delayInSecond, uint repeat, uint repeatInterval, string token, string id)
        {
            if (repeat > 5)
            {
                throw new ArgumentOutOfRangeException("repeat", repeat, "Should Be Less Than 5");
            }
            if (!string.IsNullOrEmpty(id) && id.Length > 15)
            {
                throw new ArgumentOutOfRangeException("id", id, "Should Be Less Than 15 Characters");
            }
            var toastDOM = new ToastNotificationContent(title, content, auidoType).GetXmlDocument();

            if (!string.IsNullOrEmpty(token))
            {
                var toastNode = toastDOM.SelectSingleNode("/toast");
                if (toastNode != null)
                {
                    var element = toastDOM.CreateElement(EXTRANODENAME);
                    element.SetAttribute(TOKENATTRIBUTENAME, token);
                    toastNode.AppendChild(element);
                }
            }
            try
            {
                if (delayInSecond == 0)
                {
                    var toast = new global::Windows.UI.Notifications.ToastNotification(toastDOM);
                    toast.Activated += Toast_Activated;
                    toast.Dismissed += Toast_Dismissed;
                    toast.Failed    += Toast_Failed;
                    ToastNotifier.Show(toast);
                }
                else
                {
                    var dueTime = DateTimeOffset.Now.AddSeconds(delayInSecond);
                    global::Windows.UI.Notifications.ScheduledToastNotification toast = repeat > 0 ? new global::Windows.UI.Notifications.ScheduledToastNotification(toastDOM, dueTime, TimeSpan.FromSeconds(Math.Min(3600, Math.Max(60, repeatInterval))), repeat) : new global::Windows.UI.Notifications.ScheduledToastNotification(toastDOM, dueTime);
                    if (!string.IsNullOrEmpty(id))
                    {
                        toast.Id = id;
                    }
                    ToastNotifier.AddToSchedule(toast);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
 internal ToastNotificationContent(string title, string content, ToastAuidoType auidoType)
 {
     _title     = title ?? string.Empty;
     _content   = content ?? string.Empty;
     _auidoType = auidoType;
 }
Example #3
0
 public void ShowToast(string title, string content, ToastAuidoType auidoType, uint delayInSecond, uint repeat, uint repeatInterval, string token, string id)
 {
     throw new NotImplementedException();
 }