internal Element_Toast ConvertToElement()
        {
            if (ActivationOptions != null)
            {
#pragma warning disable 618
                if (ActivationOptions.AfterActivationBehavior != ToastAfterActivationBehavior.Default)
#pragma warning restore 618
                {
                    throw new InvalidOperationException("ToastContent does not support a custom AfterActivationBehavior. Please ensure ActivationOptions.AfterActivationBehavior is set to Default.");
                }
            }

            DateTimeOffset?strippedDisplayTimestamp = null;
            if (DisplayTimestamp != null)
            {
                // We need to make sure we don't include more than 3 decimal points on seconds
                // The Millisecond value itself is limited to 3 decimal points, thus by doing the following
                // we bypass the more granular value that can come from Ticks and ensure we only have 3 decimals at most.
                var val = DisplayTimestamp.Value;
                strippedDisplayTimestamp = new DateTimeOffset(val.Year, val.Month, val.Day, val.Hour, val.Minute, val.Second, val.Millisecond, val.Offset);
            }

            var toast = new Element_Toast()
            {
                ActivationType   = Element_Toast.ConvertActivationType(ActivationType),
                Duration         = Duration,
                Launch           = Launch,
                Scenario         = Scenario,
                DisplayTimestamp = strippedDisplayTimestamp
            };

            ActivationOptions?.PopulateElement(toast);

            if (Visual != null)
            {
                toast.Visual = Visual.ConvertToElement();
            }

            if (Audio != null)
            {
                toast.Audio = Audio.ConvertToElement();
            }

            if (Actions != null)
            {
                toast.Actions = ConvertToActionsElement(Actions);
            }

            if (Header != null)
            {
                toast.Header = Header.ConvertToElement();
            }

            return(toast);
        }
        internal Element_ToastAction ConvertToElement()
        {
            var el = new Element_ToastAction
            {
                Content        = Content,
                Arguments      = Arguments,
                ActivationType = Element_Toast.ConvertActivationType(ActivationType),
                Placement      = Element_ToastActionPlacement.ContextMenu
            };

            ActivationOptions?.PopulateElement(el);

            return(el);
        }
        internal Element_ToastAction ConvertToElement()
        {
            var el = new Element_ToastAction()
            {
                Content        = Content,
                Arguments      = Arguments,
                ActivationType = Element_Toast.ConvertActivationType(ActivationType),
                ImageUri       = ImageUri,
                InputId        = TextBoxId
            };

            ActivationOptions?.PopulateElement(el);

            return(el);
        }
Beispiel #4
0
        internal Element_ToastAction ConvertToElement()
        {
            var el = new Element_ToastAction()
            {
                Content      = Content,
                ImageUri     = ImageUri,
                InputId      = TextBoxId,
                HintActionId = HintActionId
            };

            if (_usingSnoozeActivation)
            {
                el.ActivationType = Element_ToastActivationType.System;
                el.Arguments      = "snooze";

                if (_snoozeSelectionBoxId != null)
                {
                    el.InputId = _snoozeSelectionBoxId;
                }

                // Content needs to be specified as empty for auto-generated Snooze content
                if (el.Content == null)
                {
                    el.Content = string.Empty;
                }
            }
            else if (_usingDismissActivation)
            {
                el.ActivationType = Element_ToastActivationType.System;
                el.Arguments      = "dismiss";

                // Content needs to be specified as empty for auto-generated Dismiss content
                if (el.Content == null)
                {
                    el.Content = string.Empty;
                }
            }
            else
            {
                el.ActivationType = Element_Toast.ConvertActivationType(ActivationType);
                el.Arguments      = Arguments;
            }

            ActivationOptions?.PopulateElement(el);

            return(el);
        }
Beispiel #5
0
        internal Element_Toast ConvertToElement()
        {
            if (ActivationOptions != null)
            {
#pragma warning disable 618
                if (ActivationOptions.AfterActivationBehavior != ToastAfterActivationBehavior.Default)
#pragma warning restore 618
                {
                    throw new InvalidOperationException("ToastContent does not support a custom AfterActivationBehavior. Please ensure ActivationOptions.AfterActivationBehavior is set to Default.");
                }
            }

            var toast = new Element_Toast()
            {
                ActivationType   = Element_Toast.ConvertActivationType(ActivationType),
                Duration         = Duration,
                Launch           = Launch,
                Scenario         = Scenario,
                DisplayTimestamp = DisplayTimestamp
            };

            ActivationOptions?.PopulateElement(toast);

            if (Visual != null)
            {
                toast.Visual = Visual.ConvertToElement();
            }

            if (Audio != null)
            {
                toast.Audio = Audio.ConvertToElement();
            }

            if (Actions != null)
            {
                toast.Actions = ConvertToActionsElement(Actions);
            }

            if (Header != null)
            {
                toast.Header = Header.ConvertToElement();
            }

            return(toast);
        }
        internal Element_ToastHeader ConvertToElement()
        {
            if (ActivationOptions != null)
            {
                if (ActivationOptions.AfterActivationBehavior != ToastAfterActivationBehavior.Default)
                {
                    throw new InvalidOperationException("ToastHeader does not support a custom AfterActivationBehavior. Please ensure ActivationOptions.AfterActivationBehavior is set to Default.");
                }
            }

            var el = new Element_ToastHeader()
            {
                Id             = Id,
                Title          = Title,
                Arguments      = Arguments,
                ActivationType = Element_Toast.ConvertActivationType(ActivationType)
            };

            ActivationOptions?.PopulateElement(el);

            return(el);
        }