Example #1
0
        public void AddButtonTest_WithTextBoxId_ReturnSelfWithButtonAdded()
        {
            // Arrange
            string testInputTextBoxId = Guid.NewGuid().ToString();
            string testButtonContent  = "Test Button Content";
            ToastActivationType testToastActivationType = ToastActivationType.Background;
            string testButtonLaunchArgs = "Test Launch Args";
            Uri    testImageUriSrc      = new Uri("C:/justatesturi.jpg");

            ToastContentBuilder builder = new ToastContentBuilder();

            // Act
            ToastContentBuilder anotherReference = builder.AddButton(testInputTextBoxId, testButtonContent, testToastActivationType, testButtonLaunchArgs, testImageUriSrc);

            // Assert
            Assert.AreSame(builder, anotherReference);

            var button = (builder.Content.Actions as ToastActionsCustom).Buttons.First() as ToastButton;

            Assert.AreEqual(testInputTextBoxId, button.TextBoxId);
            Assert.AreEqual(testButtonContent, button.Content);
            Assert.AreEqual(testToastActivationType, button.ActivationType);
            Assert.AreEqual(testButtonLaunchArgs, button.Arguments);
            Assert.AreEqual(testImageUriSrc.OriginalString, button.ImageUri);
        }
Example #2
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);
        }
 public static Element_ToastActivationType ConvertActivationType(ToastActivationType publicType)
 {
     return(publicType switch
     {
         ToastActivationType.Foreground => Element_ToastActivationType.Foreground,
         ToastActivationType.Background => Element_ToastActivationType.Background,
         ToastActivationType.Protocol => Element_ToastActivationType.Protocol,
         _ => throw new NotImplementedException(),
     });
 public NotificationItem(string title, string description = "", string heroImage = "", string args = "", string logo = "", string tag = "", string attribute = "", ToastActivationType actType = ToastActivationType.Background)
 {
     Title         = title;
     Description   = description;
     HeroImage     = heroImage;
     Args          = args;
     Logo          = logo;
     Tag           = tag;
     AttributeText = attribute;
     ActiveType    = actType;
 }
Example #5
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);
        }
Example #6
0
        public void AddToastActivationInfoTest_WithExpectedArgs_ReturnSelfWithActivationInfoAdded()
        {
            // Arrange
            string testToastLaunchArugments             = "Test Toast Launch Args";
            ToastActivationType testToastActivationType = ToastActivationType.Background;

            // Act
            ToastContentBuilder builder          = new ToastContentBuilder();
            ToastContentBuilder anotherReference = builder.AddToastActivationInfo(testToastLaunchArugments, testToastActivationType);

            // Assert
            Assert.AreSame(builder, anotherReference);
            Assert.AreEqual(testToastLaunchArugments, builder.Content.Launch);
            Assert.AreEqual(testToastActivationType, builder.Content.ActivationType);
        }
Example #7
0
        /// <summary>
        /// Add a button to the current toast.
        /// </summary>
        /// <param name="content">Text to display on the button.</param>
        /// <param name="activationType">Type of activation this button will use when clicked. Defaults to Foreground.</param>
        /// <param name="arguments">App-defined string of arguments that the app can later retrieve once it is activated when the user clicks the button.</param>
        /// <param name="imageUri">Optional image icon for the button to display (required for buttons adjacent to inputs like quick reply).</param>
        /// <returns>The current instance of <see cref="ToastContentBuilder"/></returns>
        public ToastContentBuilder AddButton(string content, ToastActivationType activationType, string arguments, Uri imageUri = default(Uri))
        {
            // Add new button
            ToastButton button = new ToastButton(content, arguments)
            {
                ActivationType = activationType
            };

            if (imageUri != default(Uri))
            {
                button.ImageUri = imageUri.OriginalString;
            }

            return(AddButton(button));
        }
Example #8
0
        public static Element_ToastActivationType ConvertActivationType(ToastActivationType publicType)
        {
            switch (publicType)
            {
            case ToastActivationType.Foreground:
                return(Element_ToastActivationType.Foreground);

            case ToastActivationType.Background:
                return(Element_ToastActivationType.Background);

            case ToastActivationType.Protocol:
                return(Element_ToastActivationType.Protocol);

            default:
                throw new NotImplementedException();
            }
        }
 public ActionDismissToastContentInfo(BindableString greeting, string title,
                                      string contentSection1, string contentSection2, string action,
                                      ToastActivationType actionActivationType, string actionButtonContent, string notNowButtonContent,
                                      string notNowAction, string groupName, Option <string> contentSection3, string companyName)
 {
     Greeting             = greeting;
     Title                = title;
     ContentSection1      = contentSection1;
     ContentSection2      = contentSection2;
     Action               = action;
     ActionButtonContent  = actionButtonContent;
     NotNowButtonContent  = notNowButtonContent;
     NotNowAction         = notNowAction;
     GroupName            = groupName;
     ContentSection3      = contentSection3;
     CompanyName          = companyName;
     ActionActivationType = actionActivationType;
 }
Example #10
0
        public void AddButtonTest_WithTextOnlyButton_ReturnSelfWithButtonAdded()
        {
            // Arrange
            string testButtonContent = "Test Button Content";
            ToastActivationType testToastActivationType = ToastActivationType.Background;
            string testButtonLaunchArgs = "Test Launch Args";
            ToastContentBuilder builder = new ToastContentBuilder();

            // Act
            ToastContentBuilder anotherReference = builder.AddButton(testButtonContent, testToastActivationType, testButtonLaunchArgs);

            // Assert
            Assert.AreSame(builder, anotherReference);

            var button = (builder.Content.Actions as ToastActionsCustom).Buttons.First() as ToastButton;

            Assert.AreEqual(testButtonContent, button.Content);
            Assert.AreEqual(testToastActivationType, button.ActivationType);
            Assert.AreEqual(testButtonLaunchArgs, button.Arguments);
        }
Example #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="activationType"></param>
        /// <param name="content"></param>
        /// <param name="arguments"></param>

        public ToastAction(ToastActivationType activationType, string content, string arguments)
        {
            this.activationType = activationType;
            this.content        = content;
            this.arguments      = arguments;
        }
Example #12
0
        public static void Toast(string title, string content,
                                 string buttonText    = null, string buttonActionName = "",
                                 string propertyName  = "", string propertyValue      = "",
                                 string propertyName2 = "", string propertyValue2     = "",
                                 ToastActivationType toastActivationType = ToastActivationType.Foreground,
                                 bool silent = false)
        {
            // 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
                        }
                    }
                };
            }

            ToastAudio audio = new ToastAudio
            {
                Silent = silent
            };

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

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

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
Example #13
0
        public async void OnToastNotificationActivated(ToastActivationType activationType, string args)
        {
            QueryString query          = QueryString.Parse(args);
            uint        activeCallID   = 0;
            uint        incomingCallID = 0;
            Call        activeCall     = null;
            Call        incomingCall   = null;
            Frame       frame          = null;

            switch (query[NotificationSystem.ACTION])
            {
            case NotificationSystem.END:
                activeCallID = uint.Parse(query[NotificationSystem.ACTIVE_CALL_ID]);
                activeCall   = CallSystem.CallManager.CurrentCalls.FirstOrDefault(x => x.ID == activeCallID);
                //if (activeCall?.AvailableActions.EndCallAvailable ?? false)
                //{
                activeCall?.End();
                //}
                //else
                //{
                //    //LOG
                //}
                break;

            case NotificationSystem.REJECT:
                incomingCallID = uint.Parse(query[NotificationSystem.INCOMING_CALL_ID]);
                incomingCall   = CallSystem.CallManager.CurrentCalls.FirstOrDefault(x => x.ID == incomingCallID);
                incomingCall?.RejectIncoming();
                break;

            case NotificationSystem.TEXT_REPLY:
                incomingCallID = uint.Parse(query[NotificationSystem.INCOMING_CALL_ID]);

                break;

            case NotificationSystem.END_AND_ANSWER:
                activeCallID = uint.Parse(query[NotificationSystem.ACTIVE_CALL_ID]);
                activeCall   = CallSystem.CallManager.CurrentCalls.FirstOrDefault(x => x.ID == activeCallID);
                //if (activeCall?.AvailableActions.EndCallAvailable ?? false)
                //{
                activeCall?.End();
                //}
                //else
                //{
                //    //LOG
                //}
                goto case NotificationSystem.ANSWER;

            case NotificationSystem.HOLD_AND_ANSWER:
                activeCallID = uint.Parse(query[NotificationSystem.ACTIVE_CALL_ID]);
                activeCall   = CallSystem.CallManager.CurrentCalls.FirstOrDefault(x => x.ID == activeCallID);
                //if (activeCall?.AvailableActions.HoldAvailable ?? false)
                //{
                activeCall?.SetHold(true);
                //}
                //else
                //{
                //    //LOG
                //}
                goto case NotificationSystem.ANSWER;

            case NotificationSystem.ANSWER:
                incomingCallID = uint.Parse(query[NotificationSystem.INCOMING_CALL_ID]);
                incomingCall   = CallSystem.CallManager.CurrentCalls.FirstOrDefault(x => x.ID == incomingCallID);
                //if (incomingCall?.AvailableActions.AnswerAvailable ?? false)
                //{
                incomingCall?.AcceptIncomingEx();
                //}
                //else
                //{
                //    //LOG
                //}
                if (activationType == ToastActivationType.Foreground)
                {
                    goto case NotificationSystem.SHOW_CALL_UI;
                }
                else
                {
                    break;
                }

            case NotificationSystem.SHOW_CALL_UI:
                CompactOverlayId = await CallUIPage.ShowInCallUI();

                //frame = Window.Current.Content as Frame;
                //frame.Navigate(typeof(InCallUI));
                break;

            case NotificationSystem.SHOW_INCOMING_CALL_UI:
                frame = Window.Current.Content as Frame;
                frame.Navigate(typeof(IncomingCallUI));
                break;
            }
        }
 /// <summary>
 /// Add a button to the current toast.
 /// </summary>
 /// <param name="content">Text to display on the button.</param>
 /// <param name="activationType">Type of activation this button will use when clicked. Defaults to Foreground.</param>
 /// <param name="arguments">App-defined string of arguments that the app can later retrieve once it is activated when the user clicks the button.</param>
 /// <returns>The current instance of <see cref="ToastContentBuilder"/></returns>
 public ToastContentBuilder AddButton(string content, ToastActivationType activationType, string arguments)
 {
     return(AddButton(content, activationType, arguments, default));
 }
Example #15
0
        public void OnToastNotificationActivated(ToastActivationType activationType, string args)
        {
            WwwFormUrlDecoder decoder = new WwwFormUrlDecoder(args);
            uint  activeCallID        = 0;
            uint  incomingCallID      = 0;
            Call  activeCall          = null;
            Call  incomingCall        = null;
            Frame frame = null;

            switch (decoder.GetFirstValueByName(NotificationSystem.ACTION))
            {
            case NotificationSystem.END:
                activeCallID = uint.Parse(decoder.GetFirstValueByName(NotificationSystem.ACTIVE_CALL_ID));
                activeCall   = CallSystem.CallManager.CurrentCalls.FirstOrDefault(x => x.ID == activeCallID);
                //if (activeCall?.AvailableActions.EndCallAvailable ?? false)
                //{
                activeCall?.End();
                //}
                //else
                //{
                //    //LOG
                //}
                break;

            case NotificationSystem.REJECT:
                incomingCallID = uint.Parse(decoder.GetFirstValueByName(NotificationSystem.INCOMING_CALL_ID));
                incomingCall   = CallSystem.CallManager.CurrentCalls.FirstOrDefault(x => x.ID == incomingCallID);
                incomingCall?.RejectIncoming();
                break;

            case NotificationSystem.TEXT_REPLY:
                incomingCallID = uint.Parse(decoder.GetFirstValueByName(NotificationSystem.INCOMING_CALL_ID));

                break;

            case NotificationSystem.END_AND_ANSWER:
                activeCallID = uint.Parse(decoder.GetFirstValueByName(NotificationSystem.ACTIVE_CALL_ID));
                activeCall   = CallSystem.CallManager.CurrentCalls.FirstOrDefault(x => x.ID == activeCallID);
                //if (activeCall?.AvailableActions.EndCallAvailable ?? false)
                //{
                activeCall?.End();
                //}
                //else
                //{
                //    //LOG
                //}
                goto case NotificationSystem.ANSWER;

            case NotificationSystem.HOLD_AND_ANSWER:
                activeCallID = uint.Parse(decoder.GetFirstValueByName(NotificationSystem.ACTIVE_CALL_ID));
                activeCall   = CallSystem.CallManager.CurrentCalls.FirstOrDefault(x => x.ID == activeCallID);
                //if (activeCall?.AvailableActions.HoldAvailable ?? false)
                //{
                activeCall?.SetHold(true);
                //}
                //else
                //{
                //    //LOG
                //}
                goto case NotificationSystem.ANSWER;

            case NotificationSystem.ANSWER:
                incomingCallID = uint.Parse(decoder.GetFirstValueByName(NotificationSystem.INCOMING_CALL_ID));
                incomingCall   = CallSystem.CallManager.CurrentCalls.FirstOrDefault(x => x.ID == incomingCallID);
                //if (incomingCall?.AvailableActions.AnswerAvailable ?? false)
                //{
                incomingCall?.AcceptIncomingEx();
                //}
                //else
                //{
                //    //LOG
                //}
                if (activationType == ToastActivationType.Foreground)
                {
                    goto case NotificationSystem.SHOW_CALL_UI;
                }
                else
                {
                    break;
                }

            case NotificationSystem.SHOW_CALL_UI:
                UISystem.ShowCallUIWindow();
                //frame = Window.Current.Content as Frame;
                //frame.Navigate(typeof(InCallUI));
                break;

            case NotificationSystem.SHOW_INCOMING_CALL_UI:
                frame = Window.Current.Content as Frame;
                //frame.Navigate(typeof(IncomingCallUI));
                break;
            }
        }
 /// <summary>
 /// Add info that can be used by the application when the app was activated/launched by the toast.
 /// </summary>
 /// <param name="launchArgs">Custom app-defined launch arguments to be passed along on toast activation</param>
 /// <param name="activationType">Set the activation type that will be used when the user click on this toast</param>
 /// <returns>The current instance of <see cref="ToastContentBuilder"/></returns>
 public ToastContentBuilder AddToastActivationInfo(string launchArgs, ToastActivationType activationType)
 {
     Content.Launch         = launchArgs;
     Content.ActivationType = activationType;
     return(this);
 }
Example #17
0
 public IUwpExtension AddButton(string textBoxId, string content, ToastActivationType activationType, string arguments, Uri?imageUri = null)
 {
     tbc.AddButton(textBoxId, content, activationType, arguments, imageUri);
     return(this);
 }