/// <summary>
        /// This is the click handler for the 'Scenario1BtnDefault' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Scenario1BtnDefault_Click(object sender, RoutedEventArgs e)
        {
            String rss = scenario1RssInput.Text;
            if (null != rss && "" != rss)
            {
                try
                {
                    String xml;
                    var doc = new Windows.Data.Xml.Dom.XmlDocument();
                    scenario1OriginalData.Document.GetText(Windows.UI.Text.TextGetOptions.None, out xml);
                    doc.LoadXml(xml);

                    // create a rss CDataSection and insert into DOM tree
                    var cdata = doc.CreateCDataSection(rss);
                    var element = doc.GetElementsByTagName("content").Item(0);
                    element.AppendChild(cdata);

                    Scenario.RichEditBoxSetMsg(scenario1Result, doc.GetXml(), true);
                }
                catch (Exception exp)
                {
                    Scenario.RichEditBoxSetError(scenario1Result, exp.Message);
                }
            }
            else
            {
                Scenario.RichEditBoxSetError(scenario1Result, "Please type in RSS content in the [RSS Content] box firstly.");
            }
        }
Example #2
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);
        }
Example #3
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");
            }
        }
        private async Task SetTileNotification()
        {
            Windows.Data.Xml.Dom.XmlDocument _Tile = null;
            if (string.IsNullOrEmpty(this.Image))
            {
                // a template without an image
                _Tile = Windows.UI.Notifications.TileUpdateManager
                        .GetTemplateContent(Windows.UI.Notifications.TileTemplateType.TileSquareText01);
            }
            else
            {
                // a template with an image
                _Tile = Windows.UI.Notifications.TileUpdateManager
                        .GetTemplateContent(Windows.UI.Notifications.TileTemplateType.TileSquarePeekImageAndText01);
                var _Path = await TileHelper
                            .ResizeForTile(m_Question.Image, TileHelper.TileSize.Square);

                (_Tile.GetElementsByTagName("image")[0] as Windows.Data.Xml.Dom.XmlElement)
                .SetAttribute("src", _Path.ToString());
            }
            var _Texts = _Tile.GetElementsByTagName("text");

            _Texts[0].InnerText = this.Answer;
            _Texts[1].InnerText = Choices[1];
            _Texts[2].InnerText = Choices[2];
            _Texts[3].InnerText = Choices[3];
            var _Notification = new Windows.UI.Notifications.TileNotification(_Tile)
            {
                Tag = "no-repeat"
            };
            var _Updater = Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication();

            _Updater.Clear();
            _Updater.Update(_Notification);
        }
        /*
         * 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);
        }
        public async System.Threading.Tasks.Task LoadKML(System.Collections.Generic.List <Windows.Devices.Geolocation.BasicGeoposition> mapdata)
        {
            Windows.Data.Xml.Dom.XmlLoadSettings loadSettings = new Windows.Data.Xml.Dom.XmlLoadSettings();
            loadSettings.ElementContentWhiteSpace = false;
            Windows.Data.Xml.Dom.XmlDocument kml = new Windows.Data.Xml.Dom.XmlDocument();
            FileOpenPicker openPicker            = new FileOpenPicker();

            openPicker.ViewMode = PickerViewMode.List;
            openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            openPicker.FileTypeFilter.Add(".kml");
            Windows.Storage.IStorageFile file = await openPicker.PickSingleFileAsync();

            if (file != null)
            {
                string[] stringSeparators = new string[] { ",17" };
                kml = await Windows.Data.Xml.Dom.XmlDocument.LoadFromFileAsync(file);

                var    element = kml.GetElementsByTagName("coordinates").Item(0);
                string ats     = element.FirstChild.GetXml();

                string[] atsa = ats.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);
                int      size = atsa.Length - 1;
                for (int i = 0; i < size; i++)
                {
                    string[] coord = atsa[i].Split(',');
                    double   longi = Convert.ToDouble(coord[0]);
                    double   lati  = Convert.ToDouble(coord[1]);
                    mapdata.Add(new Windows.Devices.Geolocation.BasicGeoposition()
                    {
                        Latitude = lati, Longitude = longi
                    });
                }
            }
        }
Example #7
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
        }
Example #8
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
        }
        public async System.Threading.Tasks.Task LoadKML(System.Collections.Generic.List<Windows.Devices.Geolocation.BasicGeoposition> mapdata)
        {
            Windows.Data.Xml.Dom.XmlLoadSettings loadSettings = new Windows.Data.Xml.Dom.XmlLoadSettings();
            loadSettings.ElementContentWhiteSpace = false;
            Windows.Data.Xml.Dom.XmlDocument kml = new Windows.Data.Xml.Dom.XmlDocument();
            FileOpenPicker openPicker = new FileOpenPicker();
            openPicker.ViewMode = PickerViewMode.List;
            openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            openPicker.FileTypeFilter.Add(".kml");
            Windows.Storage.IStorageFile file = await openPicker.PickSingleFileAsync();
            if (file != null)
            {
                string[] stringSeparators = new string[] { ",17" };
                kml = await Windows.Data.Xml.Dom.XmlDocument.LoadFromFileAsync(file);
                var element = kml.GetElementsByTagName("coordinates").Item(0);
                string ats  = element.FirstChild.GetXml();

                string[] atsa = ats.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);
                int size = atsa.Length-1;
                for (int i = 0; i < size; i++)
                {
                    string[] coord = atsa[i].Split(',');
                    double longi = Convert.ToDouble(coord[0]);
                    double lati = Convert.ToDouble(coord[1]);
                    mapdata.Add(new Windows.Devices.Geolocation.BasicGeoposition() { Latitude = lati, Longitude = longi });
                }
            }
        }
Example #10
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);
        }
        /// <summary>
        /// This is the click handler for the 'Scenario1BtnDefault' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Scenario1BtnDefault_Click(object sender, RoutedEventArgs e)
        {
            String rss = scenario1RssInput.Text;

            if (null != rss && "" != rss)
            {
                try
                {
                    String xml;
                    var    doc = new Windows.Data.Xml.Dom.XmlDocument();
                    scenario1OriginalData.Document.GetText(Windows.UI.Text.TextGetOptions.None, out xml);
                    doc.LoadXml(xml);

                    // create a rss CDataSection and insert into DOM tree
                    var cdata   = doc.CreateCDataSection(rss);
                    var element = doc.GetElementsByTagName("content").Item(0);
                    element.AppendChild(cdata);

                    Scenario.RichEditBoxSetMsg(scenario1Result, doc.GetXml(), true);
                }
                catch (Exception exp)
                {
                    Scenario.RichEditBoxSetError(scenario1Result, exp.Message);
                }
            }
            else
            {
                Scenario.RichEditBoxSetError(scenario1Result, "Please type in RSS content in the [RSS Content] box firstly.");
            }
        }
Example #12
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);
        }
Example #13
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);
            }
        }
Example #14
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);
                }
            }
        }
Example #15
0
        private static void UpdateTile(string infoString)
        {
            var updater = TileUpdateManager.CreateTileUpdaterForApplication();

            updater.EnableNotificationQueue(true);
            updater.Clear();
            Windows.Data.Xml.Dom.XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text06);
            tileXml.GetElementsByTagName("text")[0].InnerText = infoString;
            updater.Update(new TileNotification(tileXml));
        }
Example #16
0
 public void Run(Windows.ApplicationModel.Background.IBackgroundTaskInstance taskInstance)
 {
     try
     {
         string value =
             Windows.Storage.ApplicationData.Current.LocalSettings.Values.ContainsKey("value") ?
             (string)Windows.Storage.ApplicationData.Current.LocalSettings.Values["value"] :
             string.Empty;
         Windows.Data.Xml.Dom.XmlDocument xml =
             Windows.UI.Notifications.ToastNotificationManager
             .GetTemplateContent(Windows.UI.Notifications.ToastTemplateType.ToastText02);
         xml.GetElementsByTagName("text")[0].InnerText = "Time Zone Changed";
         xml.GetElementsByTagName("text")[1].InnerText = value;
         Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier().Show(
             new Windows.UI.Notifications.ToastNotification(xml));
     }
     catch
     {
     }
 }
Example #17
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);
        }
Example #18
0
        public static async Task <Podcast> ParseAsync(string url, bool checkDownloads, string login = null, string password = null)
        {
            try
            {
                var data = await CoreTools.DownloadStringAsync(url, true, login, password);

                var document = new Windows.Data.Xml.Dom.XmlDocument();

                try
                {
                    document.LoadXml(data);
                }
                catch
                {
                    data = await CoreTools.DownloadStringAsync(url, false, login, password);

                    document.LoadXml(data);
                }

                var channel = document.GetElementsByTagName("channel")[0] as Windows.Data.Xml.Dom.XmlElement;

                var result = new Podcast
                {
                    Title       = channel.GetChildNodeTextValue("title", "").Sanitize(),
                    Description = channel.GetChildNodeTextValue("description", "").Sanitize(),
                    Link        = channel.GetChildNodeTextValue("link", ""),
                    Image       = channel.GetChildNodeAttribute("itunes:image", "href", ""),
                    FeedUrl     = url,
                    Login       = login,
                    Password    = password
                };

                if (string.IsNullOrEmpty(result.Image))
                {
                    result.LocalImage = "ms-appx:///Assets/IconFull.png";
                }

                if (string.IsNullOrEmpty(result.Description))
                {
                    result.Description = channel.GetChildNodeTextValue("itunes:summary", "").Sanitize();
                }

                await result.ParseAsync(document, false, checkDownloads);

                result.ReOrder();

                return(result);
            }
            catch
            {
                return(null);
            }
        }
Example #19
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);
        }
Example #20
0
        private async void itemGridView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            Windows.Storage.ApplicationDataCompositeValue composite = null;
            composite = (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["nowReading"];

            GridView gv = (GridView)sender;
            Book     bk = (Book)gv.SelectedItem;

            this.currentBook.DataContext       = bk;
            this.currentBookInline.DataContext = bk;
            App.splitBook = bk;
            String currentBookFolder = bk.Location;

            Windows.Data.Xml.Dom.XmlDocument doc = await Routines.GetFile(bk.Location + "\\META-INF", "container.xml");

            var opfPathinit = doc.GetElementsByTagName("rootfile").Item(0).Attributes.GetNamedItem("full-path").NodeValue;

            String[] opfPath_tmp = Routines.parseString(opfPathinit.ToString());
            String   opfPath     = opfPath_tmp[0];
            String   opfFile     = opfPath_tmp[1];

            currentBookFolder = currentBookFolder + "/" + opfPath;

            doc = await Routines.GetFile(currentBookFolder, opfFile);

            this.chapCount.Text       = doc.GetElementsByTagName("itemref").Count.ToString();
            this.chapCountInline.Text = doc.GetElementsByTagName("itemref").Count.ToString();

            if (bk.UniqueId == composite["uniqueid"].ToString())
            {
                this.chapProgressInline.Text = (Convert.ToInt32(composite["chapter"]) + 1).ToString();
            }
            else
            {
                this.chapProgressInline.Text = (1).ToString();
            }
        }
Example #21
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);
            }
        }
Example #22
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);
        }
Example #23
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);
        }
Example #24
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
        }
Example #25
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);
        }
Example #26
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);
        }
Example #27
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);
        }
        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);
        }
Example #29
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);
                }
            }
        }
        private void SetTileNotification(string text)
        {
            Windows.Data.Xml.Dom.XmlDocument _Tile = null;

            // a template without an image
            _Tile = Windows.UI.Notifications.TileUpdateManager
                    .GetTemplateContent(Windows.UI.Notifications.TileTemplateType.TileSquareText04);
            var _Texts = _Tile.GetElementsByTagName("text");

            _Texts[0].InnerText = text;
            var _Notification = new Windows.UI.Notifications.TileNotification(_Tile)
            {
                Tag = "no-repeat"
            };
            var _Updater = Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication();

            _Updater.Clear();
            _Updater.Update(_Notification);
        }
Example #31
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);
        }
Example #32
0
        static public void showInfo(string type, string info1, string info2)
        {
            Windows.Data.Xml.Dom.XmlDocument d = new Windows.Data.Xml.Dom.XmlDocument();
            d.LoadXml(File.ReadAllText("tile.xml"));
            var eles = d.GetElementsByTagName("text");

            for (int i = 0; i < eles.Length; i += 3)
            {
                var ele = eles[i] as Windows.Data.Xml.Dom.XmlElement;
                ele.InnerText = type;
                ele           = eles[i + 1] as Windows.Data.Xml.Dom.XmlElement;
                ele.InnerText = info1;
                ele           = eles[i + 2] as Windows.Data.Xml.Dom.XmlElement;
                ele.InnerText = info2;
            }

            // perform update
            var updator      = TileUpdateManager.CreateTileUpdaterForApplication();
            var notification = new TileNotification(d);

            updator.Update(notification);
        }