Exemplo n.º 1
0
        /// <summary>
        /// Helper method to pop a toast
        /// </summary>
        private void DoToast(int numEventsOfInterest, string eventName)
        {
            // pop a toast for each geofence event
            ToastNotifier ToastNotifier = ToastNotificationManager.CreateToastNotifier();

            // Create a two line toast and add audio reminder

            // Here the xml that will be passed to the
            // ToastNotification for the toast is retrieved
            Windows.Data.Xml.Dom.XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);

            // Set both lines of text
            Windows.Data.Xml.Dom.XmlNodeList toastNodeList = toastXml.GetElementsByTagName("text");
            toastNodeList.Item(0).AppendChild(toastXml.CreateTextNode("Geolocation Sample"));

            if (1 == numEventsOfInterest)
            {
                toastNodeList.Item(1).AppendChild(toastXml.CreateTextNode(eventName));
            }
            else
            {
                string secondLine = "There are " + numEventsOfInterest + " new geofence events";
                toastNodeList.Item(1).AppendChild(toastXml.CreateTextNode(secondLine));
            }

            // now create a xml node for the audio source
            Windows.Data.Xml.Dom.IXmlNode   toastNode = toastXml.SelectSingleNode("/toast");
            Windows.Data.Xml.Dom.XmlElement audio     = toastXml.CreateElement("audio");
            audio.SetAttribute("src", "ms-winsoundevent:Notification.SMS");

            ToastNotification toast = new ToastNotification(toastXml);

            ToastNotifier.Show(toast);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新磁贴内容,最多支持四行信息
        /// </summary>
        /// <param name="p_msgs"></param>
        public static void Tile(params string[] p_msgs)
        {
#if UWP
            // 最多支持四行信息!
            int cnt = p_msgs.Length > 4 ? 4 : p_msgs.Length;
            if (cnt == 0)
            {
                return;
            }

            Windows.Data.Xml.Dom.XmlDocument xml   = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text03);
            Windows.Data.Xml.Dom.XmlNodeList nodes = xml.GetElementsByTagName("text");
            for (uint i = 0; i < cnt; i++)
            {
                nodes.Item(i).InnerText = p_msgs[i];
            }
            TileUpdateManager.CreateTileUpdaterForApplication().Update(new TileNotification(xml));
#elif IOS
            throw new NotImplementedException();
#elif ANDROID
            throw new NotImplementedException();
#elif WASM
            throw new NotImplementedException();
#endif
        }
Exemplo n.º 3
0
        /// <summary>
        /// Displays an image-based Toast Message
        /// </summary>
        /// <param name="appId">string-based application ID for handling Toast messages</param>
        /// <param name="title">Title of the toast message to be displayed</param>
        /// <param name="message">Message for the toast to contain</param>
        /// <param name="image">Image to display in the toast message</param>
        static void ShowImageToast(string appId, string title, string message, string image)
        {
            Windows.Data.Xml.Dom.XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(
                ToastTemplateType.ToastImageAndText02);

            // Fill in the text elements
            Windows.Data.Xml.Dom.XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
            stringElements[0].AppendChild(toastXml.CreateTextNode(title));
            stringElements[1].AppendChild(toastXml.CreateTextNode(message));

            // Specify the absolute path to an image
            String imagePath = "file:///" + image;

            Windows.Data.Xml.Dom.XmlNodeList imageElements = toastXml.GetElementsByTagName("image");
            imageElements[0].Attributes.GetNamedItem("src").NodeValue = imagePath;

            // Create the toast and attach event listeners
            ToastNotification toast = new ToastNotification(toastXml);

            ToastEvents events = new ToastEvents();

            toast.Activated += events.ToastActivated;
            toast.Dismissed += events.ToastDismissed;
            toast.Failed    += events.ToastFailed;

            // Show the toast. Be sure to specify the AppUserModelId
            // on your application's shortcut!
            ToastNotificationManager.CreateToastNotifier(appId).Show(toast);
        }
Exemplo n.º 4
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");
            }
        }
Exemplo n.º 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
        }
        /*
         * Tooast notifications to show various success , progress or failures.
         */
        private void ShowToastNotification(string title, string stringContent)
        {
            // Initialize a ToastNotifier.
            ToastNotifier ToastNotifier = ToastNotificationManager.CreateToastNotifier();

            Windows.Data.Xml.Dom.XmlDocument toastXml      = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
            Windows.Data.Xml.Dom.XmlNodeList toastNodeList = toastXml.GetElementsByTagName("text");

            // Add a title and a notification body.
            toastNodeList.Item(0).AppendChild(toastXml.CreateTextNode(title));
            toastNodeList.Item(1).AppendChild(toastXml.CreateTextNode(stringContent));
            Windows.Data.Xml.Dom.IXmlNode toastNode = toastXml.SelectSingleNode("/toast");

            // Set audio property to play on notification.
            Windows.Data.Xml.Dom.XmlElement audio = toastXml.CreateElement("audio");
            audio.SetAttribute("src", "ms-winsoundevent:Notification.SMS");

            ToastNotification toast = new ToastNotification(toastXml)
            {
                // Set the notification to disappeaar after 4 seconds.

                ExpirationTime = DateTime.Now.AddSeconds(4)
            };

            // Display the toast.
            ToastNotifier.Show(toast);
        }
Exemplo n.º 7
0
        public static void Tile(String FromNickName, String ToNickName)
        {
            Windows.Data.Xml.Dom.XmlDocument xdoc = new Windows.Data.Xml.Dom.XmlDocument();
            xdoc.LoadXml(File.ReadAllText("tile.xml"));
            Windows.Data.Xml.Dom.XmlNodeList TileList = xdoc.GetElementsByTagName("text");
            TileList[0].InnerText  = FromNickName;
            TileList[1].InnerText  = "To";
            TileList[2].InnerText  = ToNickName;
            TileList[3].InnerText  = FromNickName;
            TileList[4].InnerText  = "To";
            TileList[5].InnerText  = ToNickName;
            TileList[6].InnerText  = FromNickName;
            TileList[7].InnerText  = "To";
            TileList[8].InnerText  = ToNickName;
            TileList[9].InnerText  = FromNickName;
            TileList[10].InnerText = "To";
            TileList[11].InnerText = ToNickName;

            TileNotification notification = new TileNotification(xdoc);

            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
            TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication();

            updater.Update(notification);
        }
Exemplo n.º 8
0
        //---------------------------------------------------------------------------------------------------------------------------------------------Кнопки для генерации
        private async void CreateExcelButton_Click(object sender, RoutedEventArgs e)
        {
            if (ExcelGroupComboBox.SelectedIndex != -1 && ExcelDiscComboBox.SelectedIndex != -1)
            {
                FileInfo fileex = new FileInfo(ApplicationData.Current.LocalFolder.Path + $@"\{groups[ExcelGroupComboBox.SelectedIndex]}.xlsx");

                ExcelPackage.LicenseContext = LicenseContext.NonCommercial;

                ToastNotifier toastNote = ToastNotificationManager.CreateToastNotifier();
                Windows.Data.Xml.Dom.XmlDocument xml   = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
                Windows.Data.Xml.Dom.XmlNodeList nodes = xml.GetElementsByTagName("text");
                nodes.Item(0).AppendChild(xml.CreateTextNode("Генерация Excel файла"));

                using (ExcelPackage excelPackage = new ExcelPackage(fileex))
                {
                    try
                    {
                        ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.Add($"{disciplines[ExcelDiscComboBox.SelectedIndex]}");

                        List <List <string> > marks = new List <List <string> >();
                        marks = await De_Serialization.Deserialisation <List <List <string> > >($"{disciplines[ExcelDiscComboBox.SelectedIndex]}-{groups[ExcelGroupComboBox.SelectedIndex]}.xml", CreationCollisionOption.OpenIfExists, marks);

                        for (int i = 1; i < marks.Count + 1; i++)
                        {
                            List <string> day = marks[i - 1];
                            for (int g = 1; g < day.Count + 1; g++)
                            {
                                string[] splitted = day[g - 1].Split('|');
                                if (i == 1 && g != day.Count)
                                {
                                    worksheet.Cells[g + 1, i].Value     = splitted[1];
                                    worksheet.Cells[g + 1, i + 1].Value = splitted[0];
                                }
                                else if (g == day.Count)
                                {
                                    worksheet.Cells[1, i + 1].Value = day[g - 1];
                                }
                                else
                                {
                                    worksheet.Cells[g + 1, i + 1].Value = splitted[0];
                                }
                            }
                        }

                        excelPackage.Save();

                        nodes.Item(1).AppendChild(xml.CreateTextNode("Excel файл успешно сохранен!"));
                    }
                    catch
                    {
                        nodes.Item(1).AppendChild(xml.CreateTextNode("Произошла ошибка в сохранении. Такое бывает, если в Excel уже есть лист с таким именем"));
                    }
                    ToastNotification toast = new ToastNotification(xml);
                    toast.ExpirationTime = DateTime.Now.AddSeconds(4);
                    toastNote.Show(toast);
                }
            }
        }
Exemplo n.º 9
0
        private void ToastMessage()
        {
            ToastTemplateType toastTemplate = ToastTemplateType.ToastImageAndText01;

            Windows.Data.Xml.Dom.XmlDocument toastxml          = ToastNotificationManager.GetTemplateContent(toastTemplate);
            Windows.Data.Xml.Dom.XmlNodeList toastTextElements = toastxml.GetElementsByTagName("text");
            toastTextElements[0].AppendChild(toastxml.CreateTextNode("You are at a marked position"));
            ToastNotification toast = new ToastNotification(toastxml);

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
Exemplo n.º 10
0
        private void ToastText(string str)
        {
            var toastText = Windows.UI.Notifications.
                            ToastTemplateType.ToastText01;
            var content = Windows.UI.Notifications.
                          ToastNotificationManager.GetTemplateContent(toastText);
            XmlNodeList xml = content.GetElementsByTagName("text");

            xml[0].AppendChild(content.CreateTextNode(str));
            ToastNotification toast = new ToastNotification(content);

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
Exemplo n.º 11
0
        public void Show(string message)
        {
            ToastNotifier ToastNotifier = ToastNotificationManager.CreateToastNotifier();

            Windows.Data.Xml.Dom.XmlDocument toastXml      = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
            Windows.Data.Xml.Dom.XmlNodeList toastNodeList = toastXml.GetElementsByTagName("text");
            toastNodeList.Item(0).AppendChild(toastXml.CreateTextNode(message));

            ToastNotification toast = new ToastNotification(toastXml);

            toast.ExpirationTime = DateTime.Now.AddSeconds(4);
            ToastNotifier.Show(toast);
        }
Exemplo n.º 12
0
        async void IDownloadImage.CopyImage(ZXingBarcodeImageView image)
        {
            EmailMessage emailMessage = new EmailMessage();

            string messageBody = "Hello World";

            emailMessage.Body = messageBody;

            var writer = new ZXing.Mobile.BarcodeWriter();

            if (image != null && image.BarcodeOptions != null)
            {
                writer.Options = image.BarcodeOptions;
            }
            if (image != null)
            {
                writer.Format = image.BarcodeFormat;
            }
            var         value    = image != null ? image.BarcodeValue : string.Empty;
            var         wb       = writer.Write(value);
            StorageFile tempFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync("Barcode_Temp.jpeg", CreationCollisionOption.ReplaceExisting);

            if (tempFile != null)
            {
                CachedFileManager.DeferUpdates(tempFile);
                await ConvertToJPEGFileAsync(tempFile, wb);

                var status = await CachedFileManager.CompleteUpdatesAsync(tempFile);

                var dataPackage = new DataPackage();

                dataPackage.SetStorageItems(new List <IStorageItem>()
                {
                    tempFile
                });
                dataPackage.RequestedOperation = DataPackageOperation.Copy;
                Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
                ToastNotifier ToastNotifier = ToastNotificationManager.CreateToastNotifier();
                Windows.Data.Xml.Dom.XmlDocument toastXml      = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
                Windows.Data.Xml.Dom.XmlNodeList toastNodeList = toastXml.GetElementsByTagName("text");
                toastNodeList.Item(0).AppendChild(toastXml.CreateTextNode("Image Copied"));
                toastNodeList.Item(1).AppendChild(toastXml.CreateTextNode("Image Copied Successfully"));
                Windows.Data.Xml.Dom.IXmlNode   toastNode = toastXml.SelectSingleNode("/toast");
                Windows.Data.Xml.Dom.XmlElement audio     = toastXml.CreateElement("audio");
                audio.SetAttribute("src", "ms-winsoundevent:Notification.SMS");

                ToastNotification toast = new ToastNotification(toastXml);
                toast.ExpirationTime = DateTime.Now.AddSeconds(4);
                ToastNotifier.Show(toast);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Shows toast message with given text
        /// </summary>
        /// <param name="app">app object; unused</param>
        /// <param name="message">toast message</param>
        private void ShowToast(Core.App app, string message)
        {
            ToastNotifier toastNotifier = ToastNotificationManager.CreateToastNotifier();

            Windows.Data.Xml.Dom.XmlDocument toastXml      = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
            Windows.Data.Xml.Dom.XmlNodeList toastNodeList = toastXml.GetElementsByTagName("text");
            toastNodeList.Item(0).AppendChild(toastXml.CreateTextNode(Constants.AppTitle));
            toastNodeList.Item(1).AppendChild(toastXml.CreateTextNode(message));

            var toast = new ToastNotification(toastXml);

            toast.ExpirationTime = DateTime.Now.AddSeconds(4);
            toastNotifier.Show(toast);
        }
Exemplo n.º 14
0
        /// <summary>
        /// 更新磁贴数字
        /// </summary>
        /// <param name="p_num"></param>
        public static void Tile(double p_num)
        {
#if UWP
            Windows.Data.Xml.Dom.XmlDocument xml   = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Block);
            Windows.Data.Xml.Dom.XmlNodeList nodes = xml.GetElementsByTagName("text");
            nodes.Item(0).InnerText = p_num.ToString();
            TileUpdateManager.CreateTileUpdaterForApplication().Update(new TileNotification(xml));
#elif IOS
            throw new NotImplementedException();
#elif ANDROID
            throw new NotImplementedException();
#elif WASM
            throw new NotImplementedException();
#endif
        }
Exemplo n.º 15
0
        private void showToast(string text)
        {
            Windows.Data.Xml.Dom.XmlDocument tost        = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText01);
            Windows.Data.Xml.Dom.XmlNodeList childUpdate = tost?.GetElementsByTagName("text");
            if (childUpdate != null)
            {
                childUpdate[0].InnerText = text;
            }
            ToastNotification titleNotification = new ToastNotification(tost)
            {
                Group = "NetUpdate"
            };

            ToastNotificationManager.CreateToastNotifier().Show(titleNotification);
        }
Exemplo n.º 16
0
        // Method to display Toast messages, mostly Errors, with sound and 4 seconds duration.
        private void ShowToastNotification(string title, string stringContent)
        {
            ToastNotifier ToastNotifier = ToastNotificationManager.CreateToastNotifier();

            Windows.Data.Xml.Dom.XmlDocument toastXml      = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
            Windows.Data.Xml.Dom.XmlNodeList toastNodeList = toastXml.GetElementsByTagName("text");
            toastNodeList.Item(0).AppendChild(toastXml.CreateTextNode(title));
            toastNodeList.Item(1).AppendChild(toastXml.CreateTextNode(stringContent));
            Windows.Data.Xml.Dom.IXmlNode   toastNode = toastXml.SelectSingleNode("/toast");
            Windows.Data.Xml.Dom.XmlElement audio     = toastXml.CreateElement("audio");
            audio.SetAttribute("src", "ms-winsoundevent:Notification.SMS");
            ToastNotification toast = new ToastNotification(toastXml);

            toast.ExpirationTime = DateTime.Now.AddSeconds(4);
            ToastNotifier.Show(toast);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Use COM server with Win32 app to make toast messages persist in the action center https://blogs.msdn.microsoft.com/tiles_and_toasts/2015/10/16/quickstart-handling-toast-activations-from-win32-apps-in-windows-10/
        /// </summary>
        private static void ShowToast(string message)
        {
            // Get a toast XML template
            Windows.Data.Xml.Dom.XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);

            // 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(message));
            }

            var toast = new ToastNotification(toastXml);

            ToastNotificationManager.CreateToastNotifier("Wi-Fi Toaster").Show(toast);
        }
Exemplo n.º 18
0
        //Show toast notification with retrieved string content:
        private void DoToast(string stringContent)
        {
            ToastNotifier ToastNotifier = ToastNotificationManager.CreateToastNotifier();

            Windows.Data.Xml.Dom.XmlDocument toastXml      = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
            Windows.Data.Xml.Dom.XmlNodeList toastNodeList = toastXml.GetElementsByTagName("text");
            toastNodeList.Item(0).AppendChild(toastXml.CreateTextNode("Background tasks Sample"));
            toastNodeList.Item(1).AppendChild(toastXml.CreateTextNode(stringContent));
            Windows.Data.Xml.Dom.IXmlNode   toastNode = toastXml.SelectSingleNode("/toast");
            Windows.Data.Xml.Dom.XmlElement audio     = toastXml.CreateElement("audio");
            audio.SetAttribute("src", "ms-winsoundevent:Notification.SMS");

            ToastNotification toast = new ToastNotification(toastXml);

            ToastNotifier.Show(toast);
        }
Exemplo n.º 19
0
        private void OtherDeviceToastNotification(string DeviceName)
        {
            ToastNotifier ToastNotifier = ToastNotificationManager.CreateToastNotifier();

            Windows.Data.Xml.Dom.XmlDocument toastXml      = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
            Windows.Data.Xml.Dom.XmlNodeList toastNodeList = toastXml.GetElementsByTagName("text");
            toastNodeList.Item(0).AppendChild(toastXml.CreateTextNode(DeviceName));
            toastNodeList.Item(1).AppendChild(toastXml.CreateTextNode("The charge on this device is greater than 90%. You can remove the charger now!"));
            Windows.Data.Xml.Dom.IXmlNode   toastNode = toastXml.SelectSingleNode("/toast");
            Windows.Data.Xml.Dom.XmlElement audio     = toastXml.CreateElement("audio");
            audio.SetAttribute("src", "ms-winsoundevent:Notification.SMS");

            ToastNotification toast = new ToastNotification(toastXml);

            toast.ExpirationTime = DateTime.Now.AddSeconds(15);
            ToastNotifier.Show(toast);
        }
Exemplo n.º 20
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);
            }
        }
Exemplo n.º 21
0
        //磁铁创建函数
        private void tileCreate()
        {
            Windows.Data.Xml.Dom.XmlDocument document = new Windows.Data.Xml.Dom.XmlDocument();
            document.LoadXml(System.IO.File.ReadAllText("XMLFile1.xml"));
            Windows.Data.Xml.Dom.XmlNodeList Texttitle = document.GetElementsByTagName("text");

            TileUpdateManager.CreateTileUpdaterForApplication().Clear();
            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
            for (int i = 0; i < ViewModel.AllRecords.Count; i++)
            {
                if (i < 5)
                {
                    Texttitle[0].InnerText = Texttitle[2].InnerText = Texttitle[4].InnerText = ViewModel.AllRecords[i].score.ToString();
                    Texttitle[1].InnerText = Texttitle[3].InnerText = Texttitle[5].InnerText = ViewModel.AllRecords[i].date.ToString();
                    TileNotification newTile = new TileNotification(document);
                    TileUpdateManager.CreateTileUpdaterForApplication().Update(newTile);
                }
            }
        }
Exemplo n.º 22
0
        public void AddNotification(DateTime startDate, string content)
        {
            Windows.Data.Xml.Dom.XmlDocument toastXml      = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
            Windows.Data.Xml.Dom.XmlNodeList toastNodeList = toastXml.GetElementsByTagName("text");
            toastNodeList.Item(0).AppendChild(toastXml.CreateTextNode("Zadanie do wykonania\n"));
            toastNodeList.Item(1).AppendChild(toastXml.CreateTextNode(content));
            Windows.Data.Xml.Dom.IXmlNode   toastNode = toastXml.SelectSingleNode("/toast");
            Windows.Data.Xml.Dom.XmlElement audio     = toastXml.CreateElement("audio");
            audio.SetAttribute("src", "ms-winsoundevent:Notification.SMS");

            var diffrence = (startDate - DateTime.Now).TotalSeconds;

            DateTime EventDate = DateTime.Now.AddSeconds(diffrence);
            TimeSpan NotTime   = EventDate.Subtract(DateTime.Now);
            DateTime dueTime   = DateTime.Now.Add(NotTime);

            ScheduledToastNotification scheduledToast = new ScheduledToastNotification(toastXml, dueTime);

            ToastNotificationManager.CreateToastNotifier().AddToSchedule(scheduledToast);
        }
Exemplo n.º 23
0
        public void messageflex()
        {
            ToastNotifier toastNotifier = ToastNotificationManager.CreateToastNotifier();

            Windows.Data.Xml.Dom.XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);

            Windows.Data.Xml.Dom.XmlNodeList toastNodeList = toastXml.GetElementsByTagName("text");

            toastNodeList.Item(0).AppendChild(toastXml.CreateTextNode("Уведомление"));

            toastNodeList.Item(1).AppendChild(toastXml.CreateTextNode("Файл успешно создан."));

            Windows.Data.Xml.Dom.XmlElement audio = toastXml.CreateElement("audio");

            audio.SetAttribute("src", "ms-winsoundevent:Notification.SMS");

            ToastNotification toast = new ToastNotification(toastXml);

            toast.ExpirationTime = DateTime.Now.AddSeconds(4);

            toastNotifier.Show(toast);
        }
Exemplo n.º 24
0
        public void ExportSvg(StorageFolder outputFolder)
        {
            if (TableRecords == null || outputFolder == null)
            {
                return;
            }

            // Export each SVG glyph by iterating over the table records.
            int numExportedSvgs = 0;

            foreach (TableRecord record in TableRecords)
            {
                if (record.tag == "SVG ")
                {
                    numExportedSvgs = parser.ExportSvgContent(record, source, outputFolder);
                }
            }

            // Show toast with number of successful SVG files saved.
            if (numExportedSvgs > 0)
            {
                // Make the toast.
                ToastTemplateType toastTemplate      = ToastTemplateType.ToastText01;
                Windows.Data.Xml.Dom.XmlDocument xml = ToastNotificationManager.GetTemplateContent(toastTemplate);
                xml.DocumentElement.SetAttribute("launch", "Args");

                // Set up the toast text.
                string toastString = numExportedSvgs + " SVGs were successfully saved to " + outputFolder.Path;
                Windows.Data.Xml.Dom.XmlText     toastText = xml.CreateTextNode(toastString);
                Windows.Data.Xml.Dom.XmlNodeList elements  = xml.GetElementsByTagName("text");
                elements[0].AppendChild(toastText);

                // Show the toast.
                ToastNotification toast         = new ToastNotification(xml);
                ToastNotifier     toastNotifier = ToastNotificationManager.CreateToastNotifier();
                toastNotifier.Show(toast);
            }
        }
Exemplo n.º 25
0
        private static int ParseRSS(Windows.Data.Xml.Dom.XmlDocument xmlDoc, ObservableCollection <FeedItem> feedItems)
        {
            int addedItems = 0;

            Windows.Data.Xml.Dom.XmlNodeList rssNodes = xmlDoc.SelectNodes("rss/channel/item");

            foreach (Windows.Data.Xml.Dom.IXmlNode rssNode in rssNodes)
            {
                Windows.Data.Xml.Dom.IXmlNode rssSubNode = rssNode.SelectSingleNode("title");
                string title = rssSubNode != null ? rssSubNode.InnerText : "";

                rssSubNode = rssNode.SelectSingleNode("link");
                string link = rssSubNode != null ? rssSubNode.InnerText : "";

                rssSubNode = rssNode.SelectSingleNode("description");
                string description = rssSubNode != null ? rssSubNode.InnerText : "";

                feedItems.Add(new FeedItem(title, link, description));
                addedItems++;
            }

            return(addedItems);
        }
Exemplo n.º 26
0
        //Methods for displaying toasts, setting up shortcut, and toastevents.
        #region ToastHandlingMethods
        /// <summary>
        /// Displays a text-based Toast Message
        /// </summary>
        /// <param name="appId">string-based application ID for handling Toast messages</param>
        /// <param name="title">Title of the toast message to be displayed</param>
        /// <param name="message">Message for the toast to contain</param>
        static void ShowTextToast(string appId, string title, string message)
        {
            Windows.Data.Xml.Dom.XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(
                ToastTemplateType.ToastText02);

            // Fill in the text elements
            Windows.Data.Xml.Dom.XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
            stringElements[0].AppendChild(toastXml.CreateTextNode(title));
            stringElements[1].AppendChild(toastXml.CreateTextNode(message));

            // Create the toast and attach event listeners
            ToastNotification toast  = new ToastNotification(toastXml);
            ToastEvents       events = new ToastEvents();

            //Adds details to event.
            toast.Activated += events.ToastActivated;
            toast.Dismissed += events.ToastDismissed;
            toast.Failed    += events.ToastFailed;

            // Show the toast. Be sure to specify the AppUserModelId
            // on your application's shortcut!
            ToastNotificationManager.CreateToastNotifier(appId).Show(toast);
        }
Exemplo n.º 27
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);
        }
Exemplo n.º 28
0
        private static int ParseAtom(Windows.Data.Xml.Dom.XmlDocument xmlDoc, ObservableCollection <FeedItem> feedItems)
        {
            int    addedItems = 0;
            string atomNS     = "xmlns:atom='http://www.w3.org/2005/Atom'";

            Windows.Data.Xml.Dom.XmlNodeList atomNodes = xmlDoc.SelectNodesNS("atom:feed/atom:entry", atomNS);

            foreach (Windows.Data.Xml.Dom.IXmlNode atomNode in atomNodes)
            {
                Windows.Data.Xml.Dom.IXmlNode atomSubNode = atomNode.SelectSingleNodeNS("atom:title", atomNS);
                string title = atomSubNode != null ? atomSubNode.InnerText : "";

                atomSubNode = atomNode.SelectSingleNodeNS("atom:link", atomNS);
                string link = atomSubNode.Attributes.Where(a => a.NodeName == "href").FirstOrDefault()?.InnerText;

                atomSubNode = atomNode.SelectSingleNodeNS("atom:summary", atomNS);
                string summary = atomSubNode != null ? atomSubNode.InnerText : "";

                feedItems.Add(new FeedItem(title, link, summary));
                addedItems++;
            }

            return(addedItems);
        }
Exemplo n.º 29
0
        public Task <INotificationResult> Notify(INotificationOptions options)
        {
            return(Task.Run(() =>
            {
                ToastNotifier ToastNotifier = ToastNotificationManager.CreateToastNotifier();
                Windows.Data.Xml.Dom.XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
                Windows.Data.Xml.Dom.XmlNodeList toastNodeList = toastXml.GetElementsByTagName("text");
                toastNodeList.Item(0).AppendChild(toastXml.CreateTextNode(options.Title));
                toastNodeList.Item(1).AppendChild(toastXml.CreateTextNode(options.Description));
                Windows.Data.Xml.Dom.IXmlNode toastNode = toastXml.SelectSingleNode("/toast");

                var id = _count.ToString();

                var root = toastXml.DocumentElement;
                root.SetAttribute("launch", id.ToString());

                if (!string.IsNullOrEmpty(options.WindowsOptions.LogoUri))
                {
                    Windows.Data.Xml.Dom.XmlElement image = toastXml.CreateElement("image");
                    image.SetAttribute("placement", "appLogoOverride");

                    var imageUri = options.WindowsOptions.LogoUri;
                    if (!options.WindowsOptions.LogoUri.Contains("//"))
                    {
                        imageUri = $"ms-appx:///{options.WindowsOptions.LogoUri}";
                    }

                    image.SetAttribute("src", imageUri);

                    toastXml.GetElementsByTagName("binding")[0].AppendChild(image);
                    toastXml.GetElementsByTagName("binding")[0].Attributes[0].InnerText = "ToastGeneric";
                }

                if (options.DelayUntil.HasValue)
                {
                    ScheduledToastNotification toast = new ScheduledToastNotification(toastXml, options.DelayUntil.Value);
                    ToastNotifier.AddToSchedule(toast);
                    return new NotificationResult()
                    {
                        Action = NotificationAction.NotApplicable
                    };
                }
                else
                {
                    Windows.UI.Notifications.ToastNotification toast = new Windows.UI.Notifications.ToastNotification(toastXml);


                    toast.Tag = id;
                    _count++;
                    toast.Dismissed += Toast_Dismissed;
                    toast.Activated += Toast_Activated;
                    toast.Failed += Toast_Failed;
                    _notificationOptions.Add(id, options);

                    var waitEvent = new ManualResetEvent(false);

                    _resetEvents.Add(id, waitEvent);

                    ToastNotifier.Show(toast);

                    waitEvent.WaitOne();

                    INotificationResult result = _eventResult[id];

                    if (!options.IsClickable && result.Action == NotificationAction.Clicked) // A click is transformed to manual dismiss
                    {
                        result = new NotificationResult()
                        {
                            Action = NotificationAction.Dismissed
                        }
                    }
                    ;

                    if (_resetEvents.ContainsKey(id))
                    {
                        _resetEvents.Remove(id);
                    }
                    if (_eventResult.ContainsKey(id))
                    {
                        _eventResult.Remove(id);
                    }
                    if (_notificationOptions.ContainsKey(id))
                    {
                        _notificationOptions.Remove(id);
                    }

                    return result;
                }
            }));
        }
Exemplo n.º 30
0
        private async void PrintJournal_Click(object sender, RoutedEventArgs e)
        {
            ToastNotifier toast = ToastNotificationManager.CreateToastNotifier();

            Windows.Data.Xml.Dom.XmlDocument toastxml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText02);

            Windows.Data.Xml.Dom.XmlNodeList toastnodelist = toastxml.GetElementsByTagName("text");

            ToastNotification toastNotification;

            ComboBox gBox = new ComboBox();

            int kol = 0;

            FileInfo fi;

            List <TeacherRecord> records = new List <TeacherRecord>();

            ContentDialog dialog = new ContentDialog()
            {
                Title             = "Export data",
                Content           = gBox,
                PrimaryButtonText = "Export"
            };

            for (int count = 0; count < listGroups.Count; count++)
            {
                gBox.Items.Add(listGroups[count].Name);
            }

            if (gBox.Items.Count > 0)
            {
                gBox.SelectedIndex = 0;
            }
            else
            {
                gBox.PlaceholderText = "Groups are not found!";
            }


            ContentDialogResult res = await dialog.ShowAsync();

            if (res == ContentDialogResult.Primary)
            {
                if (gBox.Items.Count == 0)
                {
                    return;
                }

                using (ExcelPackage excel = new ExcelPackage())
                {
                    excel.Workbook.Properties.Title = "Export";

                    ExcelWorksheet worksheet = excel.Workbook.Worksheets.Add(gBox.SelectedItem.ToString());

                    for (int count = 0; count < listrecords.Count; count++)
                    {
                        if (listrecords[count].group == gBox.SelectedItem.ToString())
                        {
                            records.Add(listrecords[count]);
                        }
                    }

                    for (int count = 0; count < records.Count; count++)
                    {
                        {
                            for (int count2 = 0; count2 < 5; count2++)
                            {
                                switch (count2)
                                {
                                case 0:
                                {
                                    worksheet.Cells[count + 1, count2 + 1].Value = listrecords[count].data;
                                    break;
                                }

                                case 1:
                                {
                                    worksheet.Cells[count + 1, count2 + 1].Value = listrecords[count].subject;
                                    break;
                                }

                                case 2:
                                {
                                    worksheet.Cells[count + 1, count2 + 1].Value = listrecords[count].group;
                                    break;
                                }

                                case 3:
                                {
                                    worksheet.Cells[count + 1, count2 + 1].Value = listrecords[count].student;
                                    break;
                                }

                                case 4:
                                {
                                    worksheet.Cells[count + 1, count2 + 1].Value = listrecords[count].value;
                                    break;
                                }
                                }

                                kol++;
                            }
                        }
                    }
                    if (kol == 0)
                    {
                        worksheet.Cells[1, 1].Value = "Records are not found!";
                    }

                    fi = new FileInfo(ApplicationData.Current.LocalFolder.Path + @"\" + "Export" + " group " + gBox.SelectedItem.ToString() + ".xlsx");


                    try
                    {
                        excel.SaveAs(fi);
                    }
                    catch (Exception ex)
                    {
                        toastnodelist.Item(0).AppendChild(toastxml.CreateTextNode("Exception!"));
                        toastnodelist.Item(1).AppendChild(toastxml.CreateTextNode(e.ToString()));

                        toastNotification = new ToastNotification(toastxml);
                        toastNotification.ExpirationTime = DateTime.Now.AddSeconds(4);

                        toast.Show(toastNotification);

                        return;
                    }
                    finally
                    {
                        toastnodelist.Item(0).AppendChild(toastxml.CreateTextNode("Success!"));
                        toastnodelist.Item(1).AppendChild(toastxml.CreateTextNode(ApplicationData.Current.LocalFolder.Path + @"\" + "Export" + " group " + gBox.SelectedItem.ToString() + ".xlsx"));

                        toastNotification = new ToastNotification(toastxml);
                        toastNotification.ExpirationTime = DateTime.Now.AddSeconds(4);

                        toast.Show(toastNotification);
                    }

                    //var msg = await new MessageDialog(ApplicationData.Current.LocalFolder.Path + @"\" + "Export" + " group " + gBox.SelectedItem.ToString() + ".xlsx").ShowAsync();
                }
            }
        }