예제 #1
0
        private async Task showToast(ToastMessageModel input) =>
        await Task.Factory.StartNew(() => {
            var visual = new ToastVisual()
            {
                BindingGeneric = new ToastBindingGeneric()
                {
                    Children =
                    {
                        new AdaptiveText()
                        {
                            Text = "File Watcher Notification"
                        },
                        new AdaptiveText()
                        {
                            Text = input.Message
                        }
                    }
                }
            };

            var actions = new ToastActionsCustom();

            var toastContent = new ToastContent()
            {
                Visual  = visual,
                Actions = actions
            };

            var xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(toastContent.GetContent());
            var toastNotification = new ToastNotification(xmlDoc);
            ToastNotificationManager.CreateToastNotifier(applicationId).Show(toastNotification);
        });
        private static int Show(
            int id,
            string title,
            string body,
            string action,
            string iconReference,
            params NotificationButton[] buttons)
        {
            ToastVisual visual = SetupToastVisualComponent(title, body, iconReference);

            ToastContent toastContent = new ToastContent {
                Visual = visual
            };

            if (!string.IsNullOrWhiteSpace(action?.ToString()))
            {
                toastContent.Launch = action.ToString();
            }

            if (buttons != null && buttons.Any())
            {
                ToastActionsCustom actions = SetupToastActionsComponent(buttons);
                toastContent.Actions = actions;
            }

            ToastNotification toast = new ToastNotification(toastContent.GetXml())
            {
                Tag = id.ToString()
            };

            ToastNotificationManager.CreateToastNotifier().Show(toast);

            return(id);
        }
예제 #3
0
        public static void ShowDesktopNotification(this string notificationText, params ToastButton[] buttons)
        {
            var toastContent = new ToastContent
            {
                Visual = new ToastVisual
                {
                    BindingGeneric = new ToastBindingGeneric
                    {
                        Children =
                        {
                            new AdaptiveText
                            {
                                Text = notificationText
                            }
                        }
                    }
                }
            };

            if (buttons != null && buttons.Length > 0)
            {
                var toastActions = new ToastActionsCustom();

                foreach (var toastButton in buttons)
                {
                    toastActions.Buttons.Add(toastButton);
                }

                toastContent.Actions = toastActions;
            }

            toastContent.Show();
        }
예제 #4
0
        public static void ScheduledToast(DateTimeOffset deliveryTime,
                                          string title, string content,
                                          string buttonText    = null, string buttonActionName = "",
                                          string propertyName  = "", string propertyValue      = "",
                                          string propertyName2 = "", string propertyValue2     = "",
                                          ToastActivationType toastActivationType = ToastActivationType.Foreground)
        {
            // Construct the visuals of the toast
            ToastVisual visual = new ToastVisual()
            {
                BindingGeneric = new ToastBindingGeneric()
                {
                    Children =
                    {
                        new AdaptiveText {
                            Text = title
                        },
                        new AdaptiveText {
                            Text = content
                        },
                    },
                }
            };

            ToastActionsCustom actions = null;

            if (!string.IsNullOrEmpty(buttonText))
            {
                // Construct the actions for the toast (inputs and buttons)
                actions = new ToastActionsCustom()
                {
                    Buttons =
                    {
                        new ToastButton(buttonText, new QueryString()
                        {
                            { "action",             buttonActionName},
                            { propertyName,         propertyValue  },
                            { propertyName2,        propertyValue2 },
                        }.ToString())
                        {
                            ActivationType = toastActivationType
                        }
                    }
                };
            }

            // Now we can construct the final toast content
            ToastContent toastContent = new ToastContent()
            {
                Visual  = visual,
                Actions = actions,
            };

            // And create the toast notification
            var toast = new ScheduledToastNotification(toastContent.GetXml(), deliveryTime);

            // And your scheduled toast to the schedule
            ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);
        }
예제 #5
0
        public XmlDocument Build(Note note)
        {
            var visual = new ToastVisual()
            {
                BindingGeneric = new ToastBindingGeneric()
                {
                    Children =
                    {
                        new AdaptiveText()
                        {
                            Text = note.Title,
                        },
                        new AdaptiveText()
                        {
                            Text = note.Text,
                        },
                    },
                }
            };

            var selectionBox = new ToastSelectionBox("snoozeTime")
            {
                DefaultSelectionBoxItemId = "15",
                Title = "Snooze until:",
            };

            selectionBox.Items.Add(new ToastSelectionBoxItem("5", "5 minutes"));
            selectionBox.Items.Add(new ToastSelectionBoxItem("15", "15 minutes"));
            selectionBox.Items.Add(new ToastSelectionBoxItem("60", "1 hour"));
            selectionBox.Items.Add(new ToastSelectionBoxItem("240", "4 hours"));
            selectionBox.Items.Add(new ToastSelectionBoxItem("1440", "1 day"));
            var actions = new ToastActionsCustom()
            {
                Inputs =
                {
                    selectionBox,
                },
                Buttons =
                {
                    new ToastButtonSnooze
                    {
                        SelectionBoxId = selectionBox.Id,
                    },
                    new ToastButtonDismiss(),
                }
            };


            var toastContent = new ToastContent()
            {
                Visual   = visual,
                Actions  = actions,
                Scenario = ToastScenario.Reminder,
            };

            var xml = toastContent.GetXml();

            return(xml);
        }
예제 #6
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);
        }
예제 #7
0
        public void ShowNotification()
        {
            // Construct the visuals of the toast
            ToastVisual visual = new ToastVisual()
            {
                BindingGeneric = new ToastBindingGeneric()
                {
                    Children =
                    {
                        new AdaptiveText()
                        {
                            Text = Title
                        },

                        new AdaptiveText()
                        {
                            Text = Content
                        },
                    },
                }
            };

            // Now we can construct the final toast content
            ToastContent toastContent = new ToastContent()
            {
                Visual = visual
            };

            if (ToastLaunchArguments != null)
            {
                toastContent.Launch = ToastLaunchArguments;
            }

            ToastActionsCustom actionsCustom = new ToastActionsCustom();

            if (ToastButtonContent != null && ToastButtonArguments != null)
            {
                actionsCustom.Buttons.Add(new ToastButton(ToastButtonContent, ToastButtonArguments)
                {
                    ActivationType = ToastActivationType.Foreground
                });
            }

            if (ToastButton2Content != null && ToastButton2Arguments != null)
            {
                actionsCustom.Buttons.Add(new ToastButton(ToastButton2Content, ToastButton2Arguments)
                {
                    ActivationType = ToastActivationType.Foreground
                });
            }

            toastContent.Actions = actionsCustom;

            // And create the toast notification
            ToastNotification toast = new ToastNotification(toastContent.GetXml());

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
예제 #8
0
파일: Toast.cs 프로젝트: BramDC3/Stapp-UWP
        public ToastNotification createToast(string title, string content)
        {
            // Construct the visuals of the toast
            ToastVisual visual = new ToastVisual()
            {
                BindingGeneric = new ToastBindingGeneric()
                {
                    Children =
                    {
                        new AdaptiveText()
                        {
                            Text = title
                        },

                        new AdaptiveText()
                        {
                            Text = content
                        }
                    }
                }
            };


            // Construct the actions for the toast (inputs and buttons)
            ToastActionsCustom actions = new ToastActionsCustom()
            {
                Buttons =
                {
                    new ToastButton("Bekijk hier!", "showsubscriptions")
                    {
                        ActivationType = ToastActivationType.Foreground
                    },
                }
            };

            ToastContent toastContent = new ToastContent()
            {
                Visual  = visual,
                Actions = actions,

                // Arguments when the user taps body of toast
                Launch = new QueryString()
                {
                    { "showsubscriptions" }
                }.ToString()
            };

            // And create the toast notification
            var toast = new ToastNotification(toastContent.GetXml());

            toast.ExpirationTime = DateTime.Now.AddDays(1);
            toast.Tag            = "18365";
            toast.Group          = "stapp";

            return(toast);
        }
예제 #9
0
        private void ShowToastWithButton_Click(object sender, RoutedEventArgs e)
        {
            // Construct the visuals of the toast
            ToastVisual visual = new ToastVisual()
            {
                BindingGeneric = new ToastBindingGeneric()
                {
                    Children =
                    {
                        new AdaptiveText()
                        {
                            Text = "Title"
                        },

                        new AdaptiveText()
                        {
                            Text = "Desription"
                        }
                    }
                }
            };

            ToastActionsCustom actions = new ToastActionsCustom()
            {
                Buttons =
                {
                    new ToastButton("Reply", new QueryString()
                    {
                        { "action",          "reply"     }
                    }.ToString()),
                    new ToastButton("View",  new QueryString()
                    {
                        { "action",          "viewImage" }
                    }.ToString())
                }
            };


            // Now we can construct the final toast content
            ToastContent toastContent = new ToastContent()
            {
                Visual  = visual,
                Actions = actions
            };

            // And create the toast notification
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(toastContent.GetContent());
            ToastNotification notification = new ToastNotification(xmlDoc);

            // And then send the toast
            ToastNotificationManager.CreateToastNotifier(APP_ID).Show(notification);
        }
예제 #10
0
        private string ComposeInteractiveToast()
        {
            var toastVisual = new ToastVisual
            {
                BindingGeneric = new ToastBindingGeneric
                {
                    Children =
                    {
                        new AdaptiveText {
                            Text = "DesktopToast WPF Sample"
                        },                                                                             // Title
                        new AdaptiveText {
                            Text = "This is an interactive toast test."
                        },                                                                                        // Body
                    },
                    AppLogoOverride = new ToastGenericAppLogo
                    {
                        Source        = string.Format("file:///{0}", Path.GetFullPath("Resources/toast128.png")),
                        AlternateText = "Logo"
                    }
                }
            };
            var toastAction = new ToastActionsCustom
            {
                Inputs =
                {
                    new ToastTextBox(id: MessageId)
                    {
                        PlaceholderContent = "Input a message"
                    }
                },
                Buttons =
                {
                    new ToastButton(content: "Reply", arguments: "action=Replied")
                    {
                        ActivationType = ToastActivationType.Background
                    },
                    new ToastButton(content: "Ignore", arguments: "action=Ignored")
                }
            };
            var toastContent = new ToastContent
            {
                Visual   = toastVisual,
                Actions  = toastAction,
                Duration = ToastDuration.Long,
                Audio    = new NotificationsExtensions.Toasts.ToastAudio
                {
                    Loop = true,
                    Src  = new Uri("ms-winsoundevent:Notification.Looping.Alarm4")
                }
            };

            return(toastContent.GetContent());
        }
예제 #11
0
        private void ShowNotification(string title, string message, bool retry, bool changePort)
        {
            ToastContent toastContent = new ToastContent()
            {
                Visual = new ToastVisual()
                {
                    BindingGeneric = new ToastBindingGeneric()
                    {
                        Children =
                        {
                            new AdaptiveText()
                            {
                                Text = title
                            },

                            new AdaptiveText()
                            {
                                Text = message
                            }
                        }
                    }
                }
            };

            ToastActionsCustom buttons = new ToastActionsCustom();

            buttons.Buttons.Add(new ToastButton("Stop", "stop"));
            if (retry)
            {
                buttons.Buttons.Add(new ToastButton("Retry", "retry"));
            }
            if (changePort)
            {
                buttons.Buttons.Add(new ToastButton("Change Port", "changePort"));

                ToastSelectionBox portBox = new ToastSelectionBox("portBox");

                foreach (var port in SerialPort.GetPortNames())
                {
                    portBox.Items.Add(new ToastSelectionBoxItem(port, port));
                }
                buttons.Inputs.Add(portBox);
            }

            toastContent.Actions = buttons;
            var doc = new XmlDocument();

            doc.LoadXml(toastContent.GetContent());

            var toast = new ToastNotification(doc);

            DesktopNotificationManagerCompat.CreateToastNotifier().Show(toast);
        }
예제 #12
0
        public static void Toast(string title, string content,
                                 string buttonText, QueryString queries,
                                 ToastActivationType toastActivationType = ToastActivationType.Foreground)
        {
            // Construct the visuals of the toast
            ToastVisual visual = new ToastVisual()
            {
                BindingGeneric = new ToastBindingGeneric()
                {
                    Children =
                    {
                        new AdaptiveText {
                            Text = title
                        },
                        new AdaptiveText {
                            Text = content
                        },
                    },
                }
            };

            ToastActionsCustom actions = null;

            if (!string.IsNullOrEmpty(buttonText))
            {
                // Construct the actions for the toast (inputs and buttons)
                actions = new ToastActionsCustom()
                {
                    Buttons =
                    {
                        new ToastButton(buttonText, queries.ToString())
                        {
                            ActivationType = toastActivationType
                        }
                    }
                };
            }

            // Now we can construct the final toast content
            ToastContent toastContent = new ToastContent()
            {
                Visual  = visual,
                Actions = actions,
            };

            // And create the toast notification
            var toast = new ToastNotification(toastContent.GetXml());

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
예제 #13
0
        public void NotifyWithUrl(string title, string message, string url)
        {
            ToastVisual visual = new ToastVisual()
            {
                TitleText = new ToastText()
                {
                    Text = title
                },
                BodyTextLine1 = new ToastText()
                {
                    Text = message
                },
                AppLogoOverride = new ToastAppLogo()
                {
                    Crop   = ToastImageCrop.Circle,
                    Source = new ToastImageSource("http://i.imgur.com/qeFYZoL.png?1")
                }
            };

            ToastActionsCustom actions = new ToastActionsCustom()
            {
                Buttons =
                {
                    new ToastButton("Browse unwatched", new QueryString()
                    {
                        { "action",                     "openurl"},
                        { "url",                        url }
                    }.ToString())
                    {
                        ActivationType = ToastActivationType.Foreground
                    },
                    new ToastButtonDismiss("Not now...")
                }
            };

            _toastContent = new ToastContent()
            {
                Visual  = visual,
                Actions = actions,

                // Arguments when the user taps body of toast
                Launch = new QueryString()
                {
                    { "action", "openurl" },
                    { "url", url }
                }.ToString()
            };
            SendNotification();
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            string title   = "titulo";
            string content = "contenido";
            string logo    = "Assets/fb.png";
            string image   = "Assets/satya.jpg";

            ToastVisual visual = new ToastVisual()
            {
                TitleText = new ToastText()
                {
                    Text = title
                },
                BodyTextLine1 = new ToastText()
                {
                    Text = content
                },
                AppLogoOverride = new ToastAppLogo()
                {
                    Source = new ToastImageSource(logo), Crop = ToastImageCrop.Circle
                },
                InlineImages = { new ToastImage()
                                 {
                                     Source = new ToastImageSource(image)
                                 } }
            };

            ToastActionsCustom action = new ToastActionsCustom()
            {
                Inputs = { new ToastTextBox("txt")
                           {
                               PlaceholderContent = "comment here"
                           } },
                Buttons = { new ToastButton("Reply", new QueryString()
                    {
                        "Action", "Reply"
                    }.ToString()) }
            };

            ToastContent Content = new ToastContent()
            {
                Visual = visual, Actions = action
            };
            ToastNotification notification = new ToastNotification();

            ToastNotificationManager.CreateToastNotifier().Show(notification);
        }
예제 #15
0
        public void ShowToast(string title, string content, ToastDuration duration = ToastDuration.Short, bool isSuppress = false, string luanchContent = null, Action toastActivatedAction = null, params ToastButton[] toastButtons)
        {
            var toust = new ToastContent();

            toust.Visual = new ToastVisual()
            {
                BindingGeneric = new ToastBindingGeneric()
                {
                    Children =
                    {
                        new AdaptiveText()
                        {
                            Text = title
                        },

                        new AdaptiveText()
                        {
                            Text = content,
                        },
                    }
                }
            };

            toust.Launch   = luanchContent;
            toust.Duration = duration;

            if (toastButtons.Any())
            {
                var actions = new ToastActionsCustom();
                foreach (var button in toastButtons)
                {
                    actions.Buttons.Add(button);
                }
                toust.Actions = actions;
            }
            var toast = new ToastNotification(toust.GetXml());

            toast.SuppressPopup = isSuppress;

            if (toastActivatedAction != null)
            {
                toast.Activated += (ToastNotification sender, object args) => toastActivatedAction();
            }

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
예제 #16
0
        private string ComposeInteractiveToast()
        {
            var toastVisual = new ToastVisual
            {
                BindingGeneric = new ToastBindingGeneric
                {
                    Children =
                    {
                        new AdaptiveText {
                            Text = MessageTitle
                        },
                        new AdaptiveText {
                            Text = MessageBody
                        },
                    },
                    AppLogoOverride = new ToastGenericAppLogo
                    {
                        Source        = string.Format("file:///{0}", Path.GetFullPath("DesktopToast.png")),
                        AlternateText = ""
                    }
                }
            };
            var toastAction = new ToastActionsCustom
            {
                Buttons =
                {
                    new ToastButton(content: "More Info", arguments: "action=Replied")
                    {
                        ActivationType = ToastActivationType.Background
                    },
                    new ToastButton(content: "Ignore", arguments: "action=Ignored")
                }
            };

            var toastContent = new ToastContent
            {
                Visual   = toastVisual,
                Actions  = toastAction,
                Duration = ToastDuration.Long,
                Scenario = ToastScenario.Reminder
            };

            return(toastContent.GetContent());
        }
예제 #17
0
        public void CreateToast()
        {
            ToastVisual visual = new ToastVisual
            {
                TitleText = new ToastText {
                    Text = "Sample notification"
                },
                BodyTextLine1 = new ToastText {
                    Text = $"Your latest random number: {Value}!"
                }
            };
            ToastActionsCustom actions = new ToastActionsCustom
            {
                Buttons =
                {
                    new ToastButton("Delete",        new QueryString
                    {
                        { "action",                  "delete"         },
                        { "id",                      Value.ToString() },
                    }.ToString()),
                    new ToastButton("Get a new one", new QueryString
                    {
                        { "action",                  "regenerate"     },
                        { "id",                      Value.ToString() }
                    }.ToString())
                },
            };
            ToastContent content = new ToastContent
            {
                Visual  = visual,
                Actions = actions,
            };
            ToastNotification toast = new ToastNotification(content.GetXml())
            {
                ExpirationTime = DateTime.Now.AddDays(2),
                Tag            = Value.ToString(),
                Group          = "Random Numbers!"
            };

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
        private static ToastActionsCustom SetupToastActionsComponent(NotificationButton[] buttons)
        {
            ToastActionsCustom actions = new ToastActionsCustom();

            foreach (NotificationButton button in buttons)
            {
                ToastButton toastButton =
                    new ToastButton(button.Label, button.Action.ToString())
                {
                    ActivationType = ToastActivationType
                                     .Foreground
                };

                if (!string.IsNullOrWhiteSpace(button.IconReference))
                {
                    toastButton.ImageUri = button.IconReference;
                }

                actions.Buttons.Add(toastButton);
            }
            return(actions);
        }
예제 #19
0
        private static string ComposeInteractiveToast(string title, string body, Slot slot)
        {
            // なぜか、 image タグが反映されない。
            var toastVisual = new ToastVisual
            {
                BindingGeneric = new ToastBindingGeneric
                {
                    Children =
                    {
                        new AdaptiveText {
                            Text = title
                        },
                        new AdaptiveText {
                            Text = body
                        }
                    }
                }
            };
            var toastAction = new ToastActionsCustom
            {
                Buttons =
                {
                    new ToastButton(Resources.View, $"action=View&channelId={slot?.Channel.ChannelId}")
                    {
                        ActivationType = ToastActivationType.Background
                    },
                    new ToastButton(Resources.Ignore, "action=Ignored")
                }
            };
            var toastContent = new ToastContent
            {
                Visual   = toastVisual,
                Actions  = toastAction,
                Duration = ToastDuration.Long
            };

            Debug.WriteLine(toastContent.GetContent());
            return(toastContent.GetContent());
        }
예제 #20
0
        public static void SendNotification(string title, string content, string tag, string group, int days)
        {
            ToastVisual visual = new ToastVisual()
            {
                BindingGeneric = new ToastBindingGeneric()
                {
                    Children =
                    {
                        new AdaptiveText()
                        {
                            Text = title
                        },
                        new AdaptiveText()
                        {
                            Text = content
                        }
                    }
                }
            };

            ToastActionsCustom actions = new ToastActionsCustom();

            ToastContent toastContent = new ToastContent()
            {
                Visual  = visual,
                Actions = actions
            };

            var toast = new ToastNotification(toastContent.GetXml());

            toast.ExpirationTime = DateTime.Now.AddDays(days);
            toast.Tag            = tag;
            toast.Group          = group;

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
예제 #21
0
        public string GetInteractiveToastXml()
        {
            var toastVisual = new ToastVisual
            {
                BindingGeneric = new ToastBindingGeneric
                {
                    Children =
                    {
                        new AdaptiveText {
                            Text = _toastModel.Title
                        },                                             // Title
                        new AdaptiveText {
                            Text = _toastModel.Body
                        },                                            // Body
                    },
                    AppLogoOverride = new ToastGenericAppLogo
                    {
                        Source        = _toastModel.ImagePath,
                        AlternateText = "Logo"
                    }
                }
            };
            var toastAction = new ToastActionsCustom
            {
                //Inputs =
                //{
                //    new ToastTextBox(id: MessageId) { PlaceholderContent = "Input a message" }
                //},
                Buttons =
                {
                    // Note that there's no reason to specify background activation, since our COM
                    // activator decides whether to process in background or launch foreground window
                    new ToastButton("Open",  new QueryString()
                    {
                        { "action",          "open"    }
                    }.ToString()),

                    new ToastButton("Close", new QueryString()
                    {
                        { "action",          "dismiss" }
                    }.ToString()),
                }
            };

            var toastAudio = new ToastAudio();

            if (!_toastModel.Silent)
            {
                toastAudio = new ToastAudio
                {
                    Loop = true,
                    Src  = new Uri("ms-winsoundevent:Notification.Looping.Alarm4")
                };
            }

            var toastContent = new ToastContent
            {
                Visual   = toastVisual,
                Actions  = toastAction,
                Duration = ToastDuration.Long,
                Audio    = toastAudio
            };

            return(toastContent.GetContent());
        }
예제 #22
0
        /// <summary>
        /// Show Toast of recieving a Friend Request
        /// </summary>
        public void FriendNotification(User user)
        {
            string toastTitle = user.Username + " " + App.GetString("/Main/Notifications_SentAfriendRequest");
            string userPhoto  = "https://cdn.discordapp.com/avatars/" + user.Id + "/" +
                                user.Avatar + ".jpg";
            // Construct the visuals of the toast
            ToastVisual visual = new ToastVisual()
            {
                BindingGeneric = new ToastBindingGeneric()
                {
                    Children =
                    {
                        new AdaptiveText()
                        {
                            Text         = toastTitle,
                            HintMaxLines = 6
                        }
                    },
                    AppLogoOverride = new ToastGenericAppLogo()
                    {
                        Source   = userPhoto,
                        HintCrop = ToastGenericAppLogoCrop.Circle
                    }
                }
            };

            // Construct the actions for the toast (inputs and buttons)
            ToastActionsCustom actions = new ToastActionsCustom()
            {
                Buttons =
                {
                    new ToastButton(App.GetString("/Main/Notifications_Accept"), new QueryString()
                    {
                        { "action",                                              "AddRelationship"    },
                        { "id",                                                  user.Id              }
                    }.ToString())
                    {
                        ActivationType = ToastActivationType.Foreground,
                    },
                    new ToastButton(App.GetString("/Main/Notifications_Refuse"), new QueryString()
                    {
                        { "action",                                              "RemoveRelationship" },
                        { "id",                                                  user.Id              }
                    }.ToString())
                    {
                        ActivationType = ToastActivationType.Foreground,
                    },
                }
            };

            // Now we can construct the final toast content
            ToastContent toastContent = new ToastContent()
            {
                Visual  = visual,
                Actions = actions,
                // Arguments when the user taps body of toast
                Launch = new QueryString()
                {
                    { "action", "Navigate" },
                    { "page", "Friends" }
                }.ToString()
            };

            // And create the toast notification
            ToastNotification notification = new ToastNotification(toastContent.GetXml());

            // And then send the toast
            ToastNotificationManager.CreateToastNotifier().Show(notification);
        }
예제 #23
0
        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);
        }
예제 #24
0
        public static ToastNotification ConvertToast(MyToast myToast)
        {
            Dictionary <int, Models.ToastVisual> visualDict = new Dictionary <int, Models.ToastVisual>();
            Dictionary <int, QueryString>        actionDict = new Dictionary <int, QueryString>();

            ToastActionsCustom actions = new ToastActionsCustom();
            QueryString        launch  = new QueryString();

            Microsoft.Toolkit.Uwp.Notifications.ToastVisual visual = new Microsoft.Toolkit.Uwp.Notifications.ToastVisual()
            {
                BindingGeneric = new ToastBindingGeneric()
                {
                    Children =
                    {
                        new AdaptiveText()
                        {
                            Text = ""
                        }
                    }
                }
            };

            foreach (Models.ToastVisual nowVisual in myToast.VisualList)
            {
                switch (nowVisual.Visual)
                {
                case VisualType.TITLE:
                    visual.BindingGeneric.Children[0] = new AdaptiveText()
                    {
                        Text = nowVisual.ToString()
                    };
                    break;

                case VisualType.DETAIL:
                    visual.BindingGeneric.Children.Add(new AdaptiveText()
                    {
                        Text = nowVisual.ToString()
                    });
                    break;

                case VisualType.MAIN_IMG:
                    visual.BindingGeneric.Children.Add(new AdaptiveImage()
                    {
                        Source = nowVisual.ToString()
                    });
                    break;

                case VisualType.LOGO_IMG:
                    visual.BindingGeneric.AppLogoOverride = new ToastGenericAppLogo()
                    {
                        Source   = nowVisual.ToString(),
                        HintCrop = ToastGenericAppLogoCrop.Circle
                    };
                    break;

                case VisualType.BUTTON1:
                case VisualType.BUTTON2:
                case VisualType.BUTTON3:
                    int index = (int)nowVisual.Visual - (int)VisualType.BUTTON1;
                    if (!visualDict.ContainsKey(index))
                    {
                        visualDict.Add(index, nowVisual);
                    }
                    else
                    {
                        visualDict[index] = nowVisual;
                    }
                    break;
                }
            }


            foreach (ToastAction nowAction in myToast.ActionList)
            {
                switch (nowAction.When)
                {
                case WhenType.BODY:
                    launch.Add(new QueryString()
                    {
                        { "action", ((int)nowAction.ActionType).ToString() },
                        { "id", nowAction.ToString() },
                        { "folder", nowAction.Folder }
                    }.ToString());
                    break;

                case WhenType.BUTTON1:
                case WhenType.BUTTON2:
                case WhenType.BUTTON3:
                    int when = (int)nowAction.When - (int)WhenType.BUTTON1;
                    if (!actionDict.ContainsKey(when))
                    {
                        actionDict.Add(when, new QueryString()
                        {
                            { "action", ((int)nowAction.ActionType).ToString() },
                            { "id", nowAction.ToString() },
                            { "folder", nowAction.Folder }
                        });
                    }
                    else
                    {
                        actionDict[when].Add("action", ((int)nowAction.ActionType).ToString());
                        actionDict[when].Add("id", nowAction.ToString());
                        actionDict[when].Add("folder", nowAction.Folder);
                    }
                    break;
                }
            }

            /*Add button*/
            foreach (var nowVisual in visualDict.OrderBy(x => x.Key))
            {
                actions.Buttons.Add(
                    new ToastButton(nowVisual.Value.ToString(),
                                    actionDict.ContainsKey(nowVisual.Key) == true ?
                                    actionDict[nowVisual.Key].ToString() : "")
                    );
            }

            ToastContent toastContent = new ToastContent()
            {
                Visual  = visual,
                Actions = actions,
                Launch  = launch.ToString(),
            };

            // Create the XML document (BE SURE TO REFERENCE WINDOWS.DATA.XML.DOM)
            var doc = new XmlDocument();

            doc.LoadXml(toastContent.GetContent());

            // And create the toast notification
            var toast = new ToastNotification(doc);

            toast.ExpirationTime = DateTime.Now.AddDays(3);

            return(toast);
        }
예제 #25
0
        /// <summary>
        /// Show toast notification.
        /// </summary>
        /// <param name="arguments">Notification arguments object.</param>
        /// <returns>Toast notification object.</returns>
        public static async Task <ToastNotification> ShowToast(NotificationArguments arguments)
        {
            //Set the toast visual
            var visual = new ToastVisual()
            {
                BindingGeneric = new ToastBindingGeneric()
                {
                    Children =
                    {
                        new AdaptiveText()
                        {
                            Text = arguments.Title
                        },
                        new AdaptiveText()
                        {
                            Text = arguments.Message
                        }
                    }
                }
            };

            //Set the attribution text
            if (!string.IsNullOrWhiteSpace(arguments.AttributionText))
            {
                visual.BindingGeneric.Attribution = new ToastGenericAttributionText()
                {
                    Text = arguments.AttributionText
                };
            }

            //Set the logo override
            var imagePath       = Globals.GetImageOrDefault(arguments.PicturePath);
            var isInternetImage = IsInternetImage(imagePath);
            var imageSource     = isInternetImage ? await DownloadImageToDisk(imagePath) : imagePath;

            visual.BindingGeneric.AppLogoOverride = new ToastGenericAppLogo()
            {
                Source   = imageSource,
                HintCrop = ToastGenericAppLogoCrop.Circle
            };

            //Set a background image
            if (!string.IsNullOrWhiteSpace(arguments.Image))
            {
                isInternetImage = IsInternetImage(arguments.Image);
                imageSource     = isInternetImage ? await DownloadImageToDisk(arguments.Image) : arguments.Image;

                visual.BindingGeneric.Children.Add(new AdaptiveImage()
                {
                    Source = imageSource
                });
            }

            // Construct the actions for the toast (inputs and buttons)
            var actions = new ToastActionsCustom();

            // Add any inputs
            if (arguments.Inputs != null)
            {
                foreach (var input in arguments.Inputs)
                {
                    var textBox = new ToastTextBox(input.Id)
                    {
                        PlaceholderContent = input.PlaceHolderText
                    };

                    if (!string.IsNullOrWhiteSpace(input.Title))
                    {
                        textBox.Title = input.Title;
                    }
                    actions.Inputs.Add(textBox);
                }
            }

            // Add any buttons
            if (arguments.Buttons != null)
            {
                foreach (var button in arguments.Buttons)
                {
                    actions.Buttons.Add(new ToastButton(button.Text, button.Arguments));

                    //Background activation is not needed the COM activator decides whether
                    //to process in background or launch foreground window
                    //actions.Buttons.Add(new ToastButton(button.Text, button.Arguments)
                    //{
                    //	ActivationType = ToastActivationType.Background
                    //});
                }
            }

            //Set the audio
            ToastAudio audio = null;

            if (!string.IsNullOrWhiteSpace(arguments.WindowsSound) || !string.IsNullOrWhiteSpace(arguments.SoundPath))
            {
                string sound;
                if (string.IsNullOrWhiteSpace(arguments.WindowsSound))
                {
                    sound = "file:///" + arguments.SoundPath;
                }
                else
                {
                    sound = $"ms-winsoundevent:{arguments.WindowsSound}";
                }

                audio = new ToastAudio()
                {
                    Src    = new Uri(sound),
                    Loop   = bool.Parse(arguments.Loop),
                    Silent = arguments.Silent
                };
            }

            // Construct the toast content
            var toastContent = new ToastContent()
            {
                Visual  = visual,
                Actions = actions,
                Audio   = audio
            };

            // Create notification
            var xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(toastContent.GetContent());

            var toast = new ToastNotification(xmlDocument);

            // Set the expiration time
            if (!string.IsNullOrWhiteSpace(arguments.Duration))
            {
                switch (arguments.Duration)
                {
                case "short":
                    toast.ExpirationTime = DateTime.Now.AddSeconds(5);
                    break;

                case "long":
                    toast.ExpirationTime = DateTime.Now.AddSeconds(25);
                    break;
                }
            }

            //Add event handlers
            var events = new NotificationEvents();

            toast.Activated += events.Activated;
            toast.Dismissed += events.Dismissed;
            toast.Failed    += events.Failed;

            //Show notification
            DesktopNotificationManagerCompat.CreateToastNotifier().Show(toast);

            return(toast);
        }
예제 #26
0
        // Send Notification
        private void SendNotification(KnockInfo knock)
        {
            String knockGUID = knock.KnockGuid.ToString("N");

            // First, the code for the visual aspects of the toast
            ToastVisual visual = new ToastVisual()
            {
                BindingGeneric = new ToastBindingGeneric()
                {
                    Children =
                    {
                        new AdaptiveText()
                        {
                            Text = knock.FromUser
                        },
                        new AdaptiveText()
                        {
                            Text = knock.Message
                        }
                    }
                }
            };

            // Second, code for the actions for the toast.
            ToastActionsCustom actions = new ToastActionsCustom()
            {
                Buttons =
                {
                    new ToastButton("No",   new QueryString()
                    {
                        { "action",         "Clear"   },
                        { "knockGUID",      knockGUID }
                    }.ToString())
                    {
                        ActivationType = ToastActivationType.Background
                    },

                    new ToastButton("Wait", new QueryString()
                    {
                        { "action",         "Clock"   },
                        { "knockGUID",      knockGUID }
                    }.ToString())
                    {
                        ActivationType = ToastActivationType.Background
                    },

                    new ToastButton("OK",   new QueryString()
                    {
                        { "action",         "Accept"  },
                        { "knockGUID",      knockGUID }
                    }.ToString())
                    {
                        ActivationType = ToastActivationType.Background
                    }
                }
            };


            // Third, construction of the toast
            ToastContent toastContent = new ToastContent()
            {
                Visual  = visual,
                Actions = actions,
                Audio   = new ToastAudio()
                {
                    Src = new Uri("ms-appx:///Assets/Menu1A.wav")
                }
            };

            // Create toast notification
            var toast = new ToastNotification(toastContent.GetXml());

            toast.Tag = knockGUID;

            // Show the notification
            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
        /// <summary>
        /// Shows an actionable toast notification.
        /// </summary>
        /// <param name="launchString">
        /// The launch string.
        /// </param>
        /// <param name="title">
        /// The title.
        /// </param>
        /// <param name="body">
        /// The body.
        /// </param>
        /// <param name="buttons">
        /// The buttons.
        /// </param>
        public void ShowActionableNotification(
            string launchString,
            string title,
            string body,
            List <ToastButton> buttons)
        {
            if (string.IsNullOrWhiteSpace(title))
            {
                throw new ArgumentNullException(nameof(title));
            }

            if (string.IsNullOrWhiteSpace(launchString))
            {
                throw new ArgumentNullException(nameof(launchString));
            }

            if (buttons == null)
            {
                throw new ArgumentNullException(nameof(buttons));
            }

            if (!buttons.Any())
            {
                throw new InvalidOperationException("No buttons passed through.");
            }

            if (buttons.Count > 5)
            {
                throw new InvalidOperationException("Cannot have more than 5 buttons.");
            }

            var visualPart = new ToastVisual {
                TitleText = new ToastText {
                    Text = title
                }
            };

            if (!string.IsNullOrWhiteSpace(body))
            {
                visualPart.BodyTextLine1 = new ToastText {
                    Text = body
                };
            }

            var actionPart = new ToastActionsCustom();

            foreach (var button in buttons)
            {
                actionPart.Buttons.Add(button);
            }

            var notification = new ToastContent
            {
                Visual   = visualPart,
                Launch   = launchString,
                Scenario = ToastScenario.Default,
                Actions  = actionPart
            };

            this.ShowNotification(notification);
        }
        /// <summary>
        /// 推送本地Toast通知
        /// </summary>
        /// <param name="minutes">toast消息过期时间(分钟)</param>
        public void ToastPush(int minutes)
        {
            // Construct the visuals of the toast
            if (image != null)
            {
                visual = new ToastVisual()
                {
                    BindingGeneric = new ToastBindingGeneric()
                    {
                        Children =
                        {
                            new AdaptiveText()
                            {
                                Text = title
                            },
                            new AdaptiveText()
                            {
                                Text = content
                            },
                            new AdaptiveImage()
                            {
                                Source = image
                            }
                        },
                        AppLogoOverride = new ToastGenericAppLogo()
                        {
                            Source   = logo,
                            HintCrop = ToastGenericAppLogoCrop.Circle
                        }
                    }
                };
            }
            else
            {
                visual = new ToastVisual()
                {
                    BindingGeneric = new ToastBindingGeneric()
                    {
                        Children =
                        {
                            new AdaptiveText()
                            {
                                Text = title
                            },
                            new AdaptiveText()
                            {
                                Text = content
                            }
                        },
                        AppLogoOverride = new ToastGenericAppLogo()
                        {
                            Source   = logo,
                            HintCrop = ToastGenericAppLogoCrop.Circle
                        }
                    }
                };
            }
            actions = new ToastActionsCustom();
            switch (toastMode)
            {
            case ExtendedRevoked:
                actions.Buttons.Add(new ToastButton("电源设置", new QueryString()
                {
                    "action", "BatterySetting"
                }.ToString())
                {
                    ActivationType = ToastActivationType.Protocol
                });
                break;

            case WallpaperUpdate:
                actions.Buttons.Add(new ToastButton("下一张", new QueryString()
                {
                    "action", "NextIllust"
                }.ToString())
                {
                    ActivationType = ToastActivationType.Foreground
                });
                break;

            case ErrorMessage:
                actions = null;
                break;
            }
            toastContent        = new ToastContent();
            toastContent.Visual = visual;
            if (actions != null)
            {
                toastContent.Actions = actions;
            }
            var toast = new ToastNotification(toastContent.GetXml());

            toast.ExpirationTime = DateTime.Now.AddMinutes(minutes);
            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
예제 #29
0
        //private void RemoveNotificationFromDb(string url)
        //{
        //    using (SQLiteConnection conn = new SQLiteConnection(DatabaseSource))
        //    {
        //        conn.Open();
        //        string sql = "DELETE FROM TblNotifications WHERE URL=@url";
        //        SQLiteCommand command = new SQLiteCommand(sql, conn);
        //        SQLiteParameter param = new SQLiteParameter("@url", url);
        //        command.Parameters.Add(param);
        //        command.ExecuteNonQuery();
        //    }
        //}

        private UnicornToastContent ConstructToast(SyndicationItem syndicationItem)
        {
            var unicornToastContent = new UnicornToastContent();

            var toastvisual = new ToastVisual();
            var toastActionsCustom = new ToastActionsCustom();
            var path = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
            var defaultImage = path + "\\Resources\\Unicorn.png";

            if (syndicationItem.ElementExtensions.Where(p => p.OuterName == "image").Count() != 0)
            {
                string imgUrl = syndicationItem.ElementExtensions.Where(p => p.OuterName == "image").First().GetObject<XElement>().Value;
                var localPath = SaveImage(imgUrl);

                toastvisual = new ToastVisual()
                {
                    BindingGeneric = new ToastBindingGeneric()
                    {
                        Children = {
                                      new AdaptiveText() { Text = syndicationItem.Title.Text,HintStyle=AdaptiveTextStyle.Title },
                                      new AdaptiveText() { Text = syndicationItem.Summary.Text,HintStyle=AdaptiveTextStyle.Subtitle },
                                      new AdaptiveImage() { Source = localPath }
                                   },
                        AppLogoOverride = new ToastGenericAppLogo()
                        {
                            Source = defaultImage,
                            HintCrop = ToastGenericAppLogoCrop.Circle
                        }
                    },
                };
            }
            else
            {
                toastvisual = new ToastVisual()
                {
                    BindingGeneric = new ToastBindingGeneric()
                    {
                        Children = {
                                      new AdaptiveText() { Text = syndicationItem.Title.Text,HintStyle=AdaptiveTextStyle.Title },
                                      new AdaptiveText() { Text = syndicationItem.Summary.Text,HintStyle=AdaptiveTextStyle.Subtitle },
                                   },
                        AppLogoOverride = new ToastGenericAppLogo()
                        {
                            Source = defaultImage,
                            HintCrop = ToastGenericAppLogoCrop.Circle
                        }
                    },
                };
            }

            if (syndicationItem.Links.ElementAtOrDefault(1) != null)
            {
                toastActionsCustom = new ToastActionsCustom
                {
                    Buttons = {
                                  {
                                      new ToastButton("Open", syndicationItem.Links.ElementAtOrDefault(1).Uri.AbsoluteUri)
                                      {
                                          ActivationType = ToastActivationType.Protocol
                                      }
                                  },
                                  {
                                      new ToastButtonDismiss()
                                  }
                              }
                };
            }
            else
            {
                toastActionsCustom = new ToastActionsCustom
                {
                    Buttons = {
                                  {
                                      new ToastButtonDismiss()
                                  }
                              }
                };
            }

            unicornToastContent.ToastContent = new ToastContent { Visual = toastvisual, Actions = toastActionsCustom, Scenario = ToastScenario.Reminder };
            unicornToastContent.Url = syndicationItem.Links.First().Uri.AbsoluteUri;

            return unicornToastContent;
        }
예제 #30
0
        public static void  Notifications_Tocast()
        {
            string title   = "查看今天的新文件";
            string content = "发现新文件";
            string view    = "查看";
            string cancel  = "取消";

            switch (UserSettings.PrimaryLanguage)
            {
            case "en-US":
            {
                title   = "Today's New Files";
                content = "Find New Files";
                view    = "View";
                cancel  = "Cancel";
                break;
            }

            case "ja":
            {
                title   = "今日の新しいファイル";
                content = "新しいファイルを発見";
                view    = "確認";
                cancel  = "キャッセル";
                break;
            }

            case "zh-Hans-CN":
            {
                title   = "查看今天的新文件";
                content = "发现新文件";
                view    = "查看";
                cancel  = "取消";
                break;
            }

            default:
                break;
            }



            //string image = "https://picsum.photos/360/202?image=883";
            //string image = "Resources/BF942982C59CEBF2640D14CD6F9420CB.png";
            var    image = "https://img-prod-cms-rt-microsoft-com.akamaized.net/cms/api/am/imageFileData/RE3sKm8?ver=08d4&q=90&m=6&h=201&w=358&b=%23FFFFFFFF&l=f&o=t&aim=true";
            string logo  = "Resources/BF942982C59CEBF2640D14CD6F9420CB.png";

            // Construct the visuals of the toast
            ToastVisual visual = new ToastVisual()
            {
                BindingGeneric = new ToastBindingGeneric()
                {
                    Children =
                    {
                        new AdaptiveText()
                        {
                            Text = title
                        },

                        new AdaptiveText()
                        {
                            Text = content
                        },

                        new AdaptiveImage()
                        {
                            Source = image
                        }
                    },

                    AppLogoOverride = new ToastGenericAppLogo()
                    {
                        Source   = logo,
                        HintCrop = ToastGenericAppLogoCrop.Circle
                    }
                }
            };
            ////

            // In a real app, these would be initialized with actual data
            int conversationId = 384928;

            // Construct the actions for the toast (inputs and buttons)
            ToastActionsCustom actions = new ToastActionsCustom()
            {
                Inputs = {               }, Buttons = { new ToastButton(view, new QueryString()
                    {
                        { "action",                                           "viewImage"}, { "imageUrl",       image                     }
                    }.ToString()),                                            new ToastButton(cancel, new QueryString()
                    {
                        { "action",                                           "cancel" }, { "conversationId", conversationId.ToString() }
                    }.ToString())
                                                        {
                                                            ActivationType = ToastActivationType.Background
                                                        } }
            };
            ////
            ToastContent toastContent = new ToastContent()
            {
                Visual  = visual,
                Actions = actions,

                // Arguments when the user taps body of toast
                Launch = new QueryString()
                {
                    { "action", "viewConversation" },
                    { "conversationId", conversationId.ToString() }
                }.ToString()
            };

            // And create the toast notification
            var toast = new ToastNotification(toastContent.GetXml());

            toast.ExpirationTime = DateTime.Now.AddDays(1);
            //
            toast.Tag   = "18365";
            toast.Group = "wallPosts";
            //
            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
        private void ButtonSendToast_Click(object sender, RoutedEventArgs e)
        {
            // In a real app, these would be initialized with actual data
            string title = "Andrew sent you a picture";
            string content = "Check this out, Happy Canyon in Utah!";
            string image = "http://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-71-81-permanent/2727.happycanyon1_5B00_1_5D00_.jpg";
            string logo = "ms-appdata:///local/Andrew.jpg";
            int conversationId = 384928;

            // Construct the visuals of the toast
            ToastVisual visual = new ToastVisual()
            {
                BindingGeneric = new ToastBindingGeneric()
                {
                    Children =
                    {
                        new AdaptiveText()
                        {
                            Text = title
                        },

                        new AdaptiveText()
                        {
                            Text = content
                        },

                        new AdaptiveImage()
                        {
                            Source = image
                        }
                    },

                    AppLogoOverride = new ToastGenericAppLogo()
                    {
                        Source = logo,
                        HintCrop = ToastGenericAppLogoCrop.Circle
                    }
                }
            };

            // Construct the actions for the toast (inputs and buttons)
            ToastActionsCustom actions = new ToastActionsCustom()
            {
                Inputs =
                {
                    new ToastTextBox("tbReply")
                    {
                        PlaceholderContent = "Type a response"
                    }
                },

                Buttons =
                {
                    new ToastButton("Reply", new QueryString()
                    {
                        { "action", "reply" },
                        { "conversationId", conversationId.ToString() }

                    }.ToString())
                    {
                        ActivationType = ToastActivationType.Background,
                        ImageUri = "Assets/Reply.png",

                        // Reference the text box's ID in order to
                        // place this button next to the text box
                        TextBoxId = "tbReply"
                    },

                    new ToastButton("Like", new QueryString()
                    {
                        { "action", "like" },
                        { "conversationId", conversationId.ToString() }

                    }.ToString())
                    {
                        ActivationType = ToastActivationType.Background
                    },

                    new ToastButton("View", new QueryString()
                    {
                        { "action", "viewImage" },
                        { "imageUrl", image }

                    }.ToString())
                }
            };

            // Now we can construct the final toast content
            ToastContent toastContent = new ToastContent()
            {
                Visual = visual,
                Actions = actions,

                // Arguments when the user taps body of toast
                Launch = new QueryString()
                {
                    { "action", "viewConversation" },
                    { "conversationId", conversationId.ToString() }

                }.ToString()
            };

            // And create the toast notification
            ToastNotification notification = new ToastNotification(toastContent.GetXml());

            // And then send the toast
            ToastNotificationManager.CreateToastNotifier().Show(notification);
        }