예제 #1
0
        private void toastWindowNotification(string text)
        {
            try
            {
                // Get a toast XML template
                Windows.Data.Xml.Dom.XmlDocument toastXml = Windows.UI.Notifications.ToastNotificationManager.GetTemplateContent(Windows.UI.Notifications.ToastTemplateType.ToastImageAndText03);

                // Fill in the text elements
                Windows.Data.Xml.Dom.XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
                for (int i = 0; i < stringElements.Length; i++)
                {
                    stringElements[i].AppendChild(toastXml.CreateTextNode(text));
                }

                // Specify the absolute path to an image
                String imagePath = "file:///" + Path.GetFullPath("toastImageAndText.png"); // 없으면 기본 아이콘 이미지로 알아서 뜸. ACT있는곳에 넣어야되는듯 dll옆이 아니라
                Windows.Data.Xml.Dom.XmlNodeList imageElements = toastXml.GetElementsByTagName("image");
                imageElements[0].Attributes.GetNamedItem("src").NodeValue = imagePath;

                // Create the toast and attach event listeners
                Windows.UI.Notifications.ToastNotification toast = new Windows.UI.Notifications.ToastNotification(toastXml);

                // Show the toast. Be sure to specify the AppUserModelId on your application's shortcut!
                Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier(APP_ID).Show(toast);
            }
            catch (Exception e)
            {
                Log.Ex(e, "error");
            }
        }
        public void InteropWithPlatformOrOldSdks()
        {
            Windows.Data.Xml.Dom.XmlDocument           platformXml = LegacyGenerateXml();
            Windows.UI.Notifications.ToastNotification toast       = LegacyGenerateToast();

            // Can show a toast using legacy XML
            new NotificationBuilder()
            .InitializeFromXml(platformXml)
            .Show();

            // Can show a toast using legacy toast notification
            new NotificationBuilder()
            .InitializeFromToastNotification(toast)
            .Show();

            // Can construct a notification using new APIs and obtain legacy XML to send using legacy APIs
            SendLegacyXml(new NotificationBuilder()
                          .AddText("Hello world")
                          .BuildXml());

            // Can construct a notification using new APIs and obtain legacy toast to send using legacy APIs
            SendLegacyToast(new NotificationBuilder()
                            .AddText("Hello world")
                            .BuildToastNotification());
        }
예제 #3
0
        public void ShowToast(Models.FileInfo file, string message = "Success")
        {
            var image = "https://raw.githubusercontent.com/Windows-XAML/Template10/master/Assets/Template10.png";

            var content = new NotificationsExtensions.Toasts.ToastContent()
            {
                Launch = file.Ref.Path,
                Visual = new NotificationsExtensions.Toasts.ToastVisual()
                {
                    TitleText = new NotificationsExtensions.Toasts.ToastText()
                    {
                        Text = message
                    },

                    BodyTextLine1 = new NotificationsExtensions.Toasts.ToastText()
                    {
                        Text = file.Name
                    },

                    AppLogoOverride = new NotificationsExtensions.Toasts.ToastAppLogo()
                    {
                        Crop = NotificationsExtensions.Toasts.ToastImageCrop.Circle,
                        Source = new NotificationsExtensions.Toasts.ToastImageSource(image)
                    }
                },
                Audio = new NotificationsExtensions.Toasts.ToastAudio()
                {
                    Src = new Uri("ms-winsoundevent:Notification.IM")
                }
            };

            var notification = new Windows.UI.Notifications.ToastNotification(content.GetXml());
            var notifier = Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier();
            notifier.Show(notification);
        }
예제 #4
0
        public async void Run(Windows.ApplicationModel.Background.IBackgroundTaskInstance taskInstance)
        {
            BackgroundTaskDeferral deferral = taskInstance.GetDeferral();
            try
            {
                DeviceConnectionChangeTriggerDetails details = (DeviceConnectionChangeTriggerDetails)taskInstance.TriggerDetails;
                BluetoothLEDevice bleDevice = await BluetoothLEDevice.FromIdAsync(details.DeviceId);
                KeyFob device = new KeyFob(bleDevice);

                if (bleDevice.ConnectionStatus == BluetoothConnectionStatus.Connected)
                {
                    if (device.AlertOnDevice && device.HasLinkLossService)
                    {
                        await device.SetAlertLevelCharacteristic();
                    }
                }
                else
                {
                    if (device.AlertOnPhone)
                    {
                        XmlDocument xml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
                        xml.SelectSingleNode("/toast/visual/binding/text").InnerText = string.Format("Device {0} is out of range.", device.Name);
                        ToastNotification toast = new ToastNotification(xml);
                        ToastNotifier notifier = ToastNotificationManager.CreateToastNotifier();
                        notifier.Show(toast);
                    }
                }
            }
            finally
            {
                deferral.Complete();
            }
        }
예제 #5
0
        private void toastWindowNotification(string text)
        {
#if COMPATIBLE
            Task.Run(() =>
            {
                MessageBox.Show(text, "ACTFate", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
            });
#else
            {
                try
                {
                    // Get a toast XML template
                    Windows.Data.Xml.Dom.XmlDocument toastXml = Windows.UI.Notifications.ToastNotificationManager.GetTemplateContent(Windows.UI.Notifications.ToastTemplateType.ToastImageAndText03);

                    // Fill in the text elements
                    Windows.Data.Xml.Dom.XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
                    for (int i = 0; i < stringElements.Length; i++)
                    {
                        stringElements[i].AppendChild(toastXml.CreateTextNode(text));
                    }

                    // Create the toast and attach event listeners
                    Windows.UI.Notifications.ToastNotification toast = new Windows.UI.Notifications.ToastNotification(toastXml);

                    // Show the toast. Be sure to specify the AppUserModelId on your application's shortcut!
                    Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier(APP_ID).Show(toast);
                }
                catch (Exception e)
                {
                    Log.Ex(e, "error");
                }
            }
#endif
        }
        // Raise a new toast with UserNotification.Id as tag
        private void ShowToastNotification(Windows.UI.Notifications.ToastNotification toast)
        {
            var toastNotifier = Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier();

            toast.Activated += (s, e) => Activate(s.Tag, false);
            toastNotifier.Show(toast);
        }
예제 #7
0
        public async void Run(Windows.ApplicationModel.Background.IBackgroundTaskInstance taskInstance)
        {
            BackgroundTaskDeferral deferral = taskInstance.GetDeferral();

            try
            {
                DeviceConnectionChangeTriggerDetails details = (DeviceConnectionChangeTriggerDetails)taskInstance.TriggerDetails;
                BluetoothLEDevice bleDevice = await BluetoothLEDevice.FromIdAsync(details.DeviceId);

                SmartPack device = new SmartPack(bleDevice);

                if (bleDevice.ConnectionStatus == BluetoothConnectionStatus.Connected)
                {
                    if (device.AlertOnDevice && device.HasLinkLossService)
                    {
                        await device.SetAlertLevelCharacteristic();
                    }
                }
                else
                {
                    if (device.AlertOnPhone)
                    {
                        XmlDocument xml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
                        xml.SelectSingleNode("/toast/visual/binding/text").InnerText = string.Format("Device {0} is out of range.", device.Name);
                        ToastNotification toast    = new ToastNotification(xml);
                        ToastNotifier     notifier = ToastNotificationManager.CreateToastNotifier();
                        notifier.Show(toast);
                    }
                }
            }
            finally
            {
                deferral.Complete();
            }
        }
예제 #8
0
        public static void SendDebugToast(string title, string text)
        {
#if DEBUG
            // template to load for showing Toast Notification
            var xmlToastTemplate = "<toast launch=\"app-defined-string\">" +
                                   "<visual>" +
                                   "<binding template =\"ToastGeneric\">" +
                                   "<text>" + WebUtility.HtmlEncode(title) + "</text>" +
                                   "<text>" +
                                   WebUtility.HtmlEncode(text) +
                                   "</text>" +
                                   "</binding>" +
                                   "</visual>" +
                                   "</toast>";

            // load the template as XML document
            var xmlDocument = new Windows.Data.Xml.Dom.XmlDocument();
            xmlDocument.LoadXml(xmlToastTemplate);

            // create the toast notification and show to user
            var toastNotification = new Windows.UI.Notifications.ToastNotification(xmlDocument);
            var notification      = Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier();
            notification.Show(toastNotification);
#endif
        }
예제 #9
0
파일: ToastService.cs 프로젝트: sorryb/UWP
        public void ShowToast(Models.FileInfo file, string message = "Success")
        {
            var image = "https://raw.githubusercontent.com/Windows-XAML/Template10/master/Assets/Template10.png";

            var content = new NotificationsExtensions.Toasts.ToastContent()
            {
                Launch = file.Ref.Path,
                Visual = new NotificationsExtensions.Toasts.ToastVisual()
                {
                    TitleText = new NotificationsExtensions.Toasts.ToastText()
                    {
                        Text = message
                    },
                    BodyTextLine1 = new NotificationsExtensions.Toasts.ToastText()
                    {
                        Text = file.Name
                    },
                    AppLogoOverride = new NotificationsExtensions.Toasts.ToastAppLogo()
                    {
                        Crop   = NotificationsExtensions.Toasts.ToastImageCrop.Circle,
                        Source = new NotificationsExtensions.Toasts.ToastImageSource(image)
                    }
                },
                Audio = new NotificationsExtensions.Toasts.ToastAudio()
                {
                    Src = new Uri("ms-winsoundevent:Notification.IM")
                }
            };

            var notification = new Windows.UI.Notifications.ToastNotification(content.GetXml());
            var notifier     = Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier();

            notifier.Show(notification);
        }
예제 #10
0
        public void Show()
        {
            Windows.UI.Notifications.ToastTemplateType toastTemplate;
            Windows.Data.Xml.Dom.XmlDocument toastDOM;
            if (imageSource != null) //ToastImage....
            {
                toastTemplate = Windows.UI.Notifications.ToastTemplateType.ToastImageAndText02;
                toastDOM = Windows.UI.Notifications.ToastNotificationManager.GetTemplateContent(toastTemplate);
                Windows.Data.Xml.Dom.XmlNodeList ToastImageElements = toastDOM.GetElementsByTagName("image");
                ((Windows.Data.Xml.Dom.XmlElement)ToastImageElements[0]).SetAttribute("src", imageSource.ToString());

            }
            else
            {
                toastTemplate = Windows.UI.Notifications.ToastTemplateType.ToastText02;
                toastDOM = Windows.UI.Notifications.ToastNotificationManager.GetTemplateContent(toastTemplate);
            }
            var toastTextElements = toastDOM.GetElementsByTagName("text");
            ((Windows.Data.Xml.Dom.XmlElement)toastTextElements[0]).AppendChild(toastDOM.CreateTextNode(this.Title));
            ((Windows.Data.Xml.Dom.XmlElement)toastTextElements[1]).AppendChild(toastDOM.CreateTextNode(this.Message));

            Windows.Data.Xml.Dom.IXmlNode toastNode = toastDOM.SelectSingleNode("toast");

            if(MillisecondsUntilHidden > 30000)
            {
                ((Windows.Data.Xml.Dom.XmlElement)toastNode).SetAttribute("duration", "long");
            }
            else
            {
                ((Windows.Data.Xml.Dom.XmlElement)toastNode).SetAttribute("duration", "short");
            }

            toast = new Windows.UI.Notifications.ToastNotification(toastDOM);
            Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
예제 #11
0
        public static void SendToast(string text)
        {
            const Windows.UI.Notifications.ToastTemplateType toastTemplate = Windows.UI.Notifications.ToastTemplateType.ToastText01;
            var toastXml = Windows.UI.Notifications.ToastNotificationManager.GetTemplateContent(toastTemplate);

            var toastTextElements = toastXml.GetElementsByTagName("text");

            toastTextElements[0].AppendChild(toastXml.CreateTextNode(text));

            var toast = new Windows.UI.Notifications.ToastNotification(toastXml);

            Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
예제 #12
0
        private void toastWindowNotification(string text)
        {
            Version currentVersion   = Environment.OSVersion.Version;
            Version compareToVersion = new Version("6.2");

            if (currentVersion.CompareTo(compareToVersion) >= 0)
            {
                try
                {
                    // Get a toast XML template

                    Windows.Data.Xml.Dom.XmlDocument toastXml = Windows.UI.Notifications.ToastNotificationManager.GetTemplateContent(Windows.UI.Notifications.ToastTemplateType.ToastImageAndText03);

                    // Fill in the text elements
                    Windows.Data.Xml.Dom.XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
                    for (int i = 0; i < stringElements.Length; i++)
                    {
                        stringElements[i].AppendChild(toastXml.CreateTextNode(text));
                    }

                    // Specify the absolute path to an image
                    String imagePath = "file:///" + Path.GetFullPath("toastImageAndText.png"); // If it does not exist, it will take the default icon image. It seems to have to be put in ACT
                    Windows.Data.Xml.Dom.XmlNodeList imageElements = toastXml.GetElementsByTagName("image");
                    imageElements[0].Attributes.GetNamedItem("src").NodeValue = imagePath;

                    /*
                     * Windows.Data.Xml.Dom.XmlElement audioElement = toastXml.CreateElement("audio");
                     * audioElement.SetAttribute("src", "ms-winsoundevent:Notification.SMS");
                     * audioElement.SetAttribute("loop", "true");
                     */
                    // Create the toast and attach event listeners
                    Windows.UI.Notifications.ToastNotification toast = new Windows.UI.Notifications.ToastNotification(toastXml);

                    // Show the toast. Be sure to specify the AppUserModelId on your application's shortcut!
                    Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier(APP_ID).Show(toast);
                }
                catch (Exception e)
                {
                    Log.Ex(e, "error");
                }
            }
            else
            {
                MessageBox.Show(text, "ACTFate", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
            }
        }
예제 #13
0
        /// <summary>
        /// New notification for reminding
        /// </summary>
        /// <param name="name">Name of event</param>
        /// <param name="dateTime">Time for start event</param>
        public void Notify(string name, DateTime dateTime)
        {
            var toastContent = new ToastContent()
            {
                Visual = new ToastVisual()
                {
                    BindingGeneric = new ToastBindingGeneric()
                    {
                        Children =
                        {
                            new AdaptiveText()
                            {
                                Text         = ResourceLoader.GetString("Reminder"),
                                HintMaxLines = 1
                            },
                            new AdaptiveText()
                            {
                                Text = name,
                            },
                            new AdaptiveText()
                            {
                                Text = $"{ResourceLoader.GetString("StartAt")} {dateTime.ToLocalTime()}"
                            }
                        },
                        AppLogoOverride = new ToastGenericAppLogo()
                        {
                            //Source = "https://picsum.photos/48?image=883",
                            Source   = @"Assets/user-48.png",
                            HintCrop = ToastGenericAppLogoCrop.Circle
                        }
                    }
                },
                Launch = "app-defined-string"
            };

            // Create the toast notification
            var toastNotif = new Windows.UI.Notifications.ToastNotification(toastContent.GetXml());

            // And send the notification
            Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier().Show(toastNotif);

            CountdownTime();
        }
예제 #14
0
        /// <summary>
        /// Sends a toast notification
        /// </summary>
        /// <param name="msg">Message to send</param>
        /// <param name="subMsg">Sub message</param>
        public void ShowToast(string msg, string subMsg = null)
        {
            if (subMsg == null)
            {
                subMsg = GetMemoryUsageText();
            }

            System.Diagnostics.Debug.WriteLine(msg + "\n" + subMsg);


            var toastXml = Windows.UI.Notifications.ToastNotificationManager.GetTemplateContent(Windows.UI.Notifications.ToastTemplateType.ToastText02);

            var toastTextElements = toastXml.GetElementsByTagName("text");

            toastTextElements[0].AppendChild(toastXml.CreateTextNode(msg));
            toastTextElements[1].AppendChild(toastXml.CreateTextNode(subMsg));

            var toast = new Windows.UI.Notifications.ToastNotification(toastXml);

            Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
예제 #15
0
        public static void SendReopenAppToast()
        {
            // template to load for showing Toast Notification
            var xmlToastTemplate = "<toast launch=\"action=reopenApp\">" +
                                   "<visual>" +
                                   "<binding template =\"ToastGeneric\">" +
                                   "<text>Tap here to open Xpo Music again</text>" +
                                   "</binding>" +
                                   "</visual>" +
                                   "</toast>";

            // load the template as XML document
            var xmlDocument = new Windows.Data.Xml.Dom.XmlDocument();

            xmlDocument.LoadXml(xmlToastTemplate);

            // create the toast notification and show to user
            var toastNotification = new Windows.UI.Notifications.ToastNotification(xmlDocument);
            var notification      = Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier();

            notification.Show(toastNotification);
        }
예제 #16
0
        public void Show()
        {
            Windows.UI.Notifications.ToastTemplateType toastTemplate;
            Windows.Data.Xml.Dom.XmlDocument           toastDOM;
            if (imageSource != null) //ToastImage....
            {
                toastTemplate = Windows.UI.Notifications.ToastTemplateType.ToastImageAndText02;
                toastDOM      = Windows.UI.Notifications.ToastNotificationManager.GetTemplateContent(toastTemplate);
                Windows.Data.Xml.Dom.XmlNodeList ToastImageElements = toastDOM.GetElementsByTagName("image");
                ((Windows.Data.Xml.Dom.XmlElement)ToastImageElements[0]).SetAttribute("src", imageSource.ToString());
            }
            else
            {
                toastTemplate = Windows.UI.Notifications.ToastTemplateType.ToastText02;
                toastDOM      = Windows.UI.Notifications.ToastNotificationManager.GetTemplateContent(toastTemplate);
            }
            var toastTextElements = toastDOM.GetElementsByTagName("text");

            ((Windows.Data.Xml.Dom.XmlElement)toastTextElements[0]).AppendChild(toastDOM.CreateTextNode(this.Title));
            ((Windows.Data.Xml.Dom.XmlElement)toastTextElements[1]).AppendChild(toastDOM.CreateTextNode(this.Message));



            Windows.Data.Xml.Dom.IXmlNode toastNode = toastDOM.SelectSingleNode("toast");

            if (MillisecondsUntilHidden > 30000)
            {
                ((Windows.Data.Xml.Dom.XmlElement)toastNode).SetAttribute("duration", "long");
            }
            else
            {
                ((Windows.Data.Xml.Dom.XmlElement)toastNode).SetAttribute("duration", "short");
            }

            toast = new Windows.UI.Notifications.ToastNotification(toastDOM);
            Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
예제 #17
0
 private ToastNotification(Windows.UI.Notifications.ToastNotification notification)
 {
     _notification = notification;
 }
예제 #18
0
 private ToastNotification(NSUserNotification notification)
 {
     _notification = notification;
 }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ToastContent tnc = new ToastContent()
            {
                Visual = new ToastVisual()
                {
                    TitleText = new ToastText()
                    {
                        Text = "aaaaaaaa"
                    }
                }
            };

            var tn = new Windows.UI.Notifications.ToastNotification(tnc.GetXml());
            var notifier = Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier();

            notifier.Show(tn);
        }
예제 #20
0
        public static async void ShowNotification(string title, string message, string URL, string commentID, string id, string name, string writer, string identity, string thumbnailURL)
        {
            if (MainWindow.IsDND != true)
            {
                if (Environment.OSVersion.Version.Major == 10)
                {
                    try
                    {
                        var Visual = new Microsoft.Toolkit.Uwp.Notifications.ToastVisual()
                        {
                            BindingGeneric = new Microsoft.Toolkit.Uwp.Notifications.ToastBindingGeneric()
                            {
                                Children =
                                {
                                    new Microsoft.Toolkit.Uwp.Notifications.AdaptiveText()
                                    {
                                        Text = title
                                    },

                                    new Microsoft.Toolkit.Uwp.Notifications.AdaptiveText()
                                    {
                                        Text = message
                                    }
                                }
                            }
                        };
                        try
                        {
                            bool   isThumbnailReplaced = false;
                            string text       = URL.Split(new string[] { "!" }, StringSplitOptions.None)[1];
                            string activityID = text.Split(new string[] { "activities/" }, StringSplitOptions.None)[1];
                            var    post       = await KakaoRequestClass.GetPost(activityID);

                            if (commentID != null)
                            {
                                foreach (var comment in post.comments)
                                {
                                    if (comment.id.Equals(commentID))
                                    {
                                        thumbnailURL = comment.decorators?[0]?.media?.url;
                                        if (thumbnailURL != null)
                                        {
                                            isThumbnailReplaced = true;
                                        }
                                        break;
                                    }
                                }
                            }

                            if (!isThumbnailReplaced)
                            {
                                if (post.@object != null)
                                {
                                    if ([email protected]_type?.Equals("video") == true)
                                    {
                                        thumbnailURL = [email protected][0]?.preview_url_hq;
                                    }
                                    else
                                    {
                                        thumbnailURL = [email protected]?[0]?.url;
                                    }
                                }
                                else
                                {
                                    if (post.media_type?.Equals("video") == true)
                                    {
                                        thumbnailURL = post.media[0]?.preview_url_hq;
                                    }
                                    else
                                    {
                                        thumbnailURL = post.media?[0]?.url;
                                    }
                                }
                            }

                            if (thumbnailURL != null)
                            {
                                Visual.BindingGeneric.HeroImage = new Microsoft.Toolkit.Uwp.Notifications.ToastGenericHeroImage()
                                {
                                    Source = thumbnailURL,
                                };
                            }
                        }
                        catch (Exception) { }
                        Microsoft.Toolkit.Uwp.Notifications.ToastActionsCustom Action;
                        if (URL == null)
                        {
                            Action = new Microsoft.Toolkit.Uwp.Notifications.ToastActionsCustom();
                        }
                        else
                        {
                            if (commentID != null)
                            {
                                Action = new Microsoft.Toolkit.Uwp.Notifications.ToastActionsCustom()
                                {
                                    Inputs =
                                    {
                                        new Microsoft.Toolkit.Uwp.Notifications.ToastTextBox("tbReply")
                                        {
                                            PlaceholderContent = "답장 작성하기",
                                        },
                                    },
                                    Buttons =
                                    {
                                        new Microsoft.Toolkit.Uwp.Notifications.ToastButton("보내기", URL + "REPLY!@#$%" + "R!@=!!" + id + "R!@=!!" + name + "R!@=!!" + writer + "R!@=!!" + identity)
                                        {
                                            ActivationType = Microsoft.Toolkit.Uwp.Notifications.ToastActivationType.Background,
                                            TextBoxId      = "tbReply"
                                        },
                                        new Microsoft.Toolkit.Uwp.Notifications.ToastButton("열기",  URL),
                                        new Microsoft.Toolkit.Uwp.Notifications.ToastButton("좋아요", URL + "LIKE!@#$%" + commentID),
                                    },
                                };
                            }
                            else
                            {
                                Action = new Microsoft.Toolkit.Uwp.Notifications.ToastActionsCustom()
                                {
                                    Buttons =
                                    {
                                        new Microsoft.Toolkit.Uwp.Notifications.ToastButton("열기", URL)
                                    }
                                };
                            }
                        }
                        var toastContent = new Microsoft.Toolkit.Uwp.Notifications.ToastContent()
                        {
                            Visual  = Visual,
                            Actions = Action,
                        };
                        var toastXml = new Windows.Data.Xml.Dom.XmlDocument();
                        toastXml.LoadXml(toastContent.GetContent());
                        var toast = new Windows.UI.Notifications.ToastNotification(toastXml);
                        //toast.Activated += (s, e) =>
                        //{
                        //    KSPNotificationActivator.ActivateHandler(URL, null);
                        //};
                        toast.ExpirationTime = DateTimeOffset.MaxValue;
                        DesktopNotificationManagerCompat.CreateToastNotifier().Show(toast);
                    }
                    catch (Exception) { }
                }
            }
        }
예제 #21
0
 /// <summary>
 /// Legacy method for initializing a builder using the legacy platform <see cref="Windows.UI.Notifications.ToastNotification"/>.
 /// </summary>
 /// <param name="notif"></param>
 /// <returns></returns>
 public NotificationBuilder InitializeFromToastNotification(Windows.UI.Notifications.ToastNotification notif)
 {
     throw new NotImplementedException();
 }
예제 #22
0
        /// <summary>
        /// Sends a toast notification
        /// </summary>
        /// <param name="msg">Message to send</param>
        /// <param name="subMsg">Sub message</param>
        public void ShowToast(string msg, string subMsg = null)
        {
            if (subMsg == null)
                subMsg = GetMemoryUsageText();

            System.Diagnostics.Debug.WriteLine(msg + "\n" + subMsg);


            var toastXml = Windows.UI.Notifications.ToastNotificationManager.GetTemplateContent(Windows.UI.Notifications.ToastTemplateType.ToastText02);

            var toastTextElements = toastXml.GetElementsByTagName("text");
            toastTextElements[0].AppendChild(toastXml.CreateTextNode(msg));
            toastTextElements[1].AppendChild(toastXml.CreateTextNode(subMsg));

            var toast = new Windows.UI.Notifications.ToastNotification(toastXml);
            Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
 private void SendLegacyToast(Windows.UI.Notifications.ToastNotification notif)
 {
     Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier().Show(notif);
 }
예제 #24
0
 internal ToastNotification(Windows.UI.Notifications.ToastNotification notification)
 {
     _notification = notification;
 }