AppendChild() 공개 메소드

public AppendChild ( [ newChild ) : IXmlNode
newChild [
리턴 IXmlNode
예제 #1
0
        /// <summary>
        /// Set the application's tile to display a local image file.
        /// After clicking, go back to the start screen to watch your application's tile update.
        /// </summary>
        private void SetTileImageButtonClick(object sender, RoutedEventArgs e)
        {
            // It is possible to start from an existing template and modify what is needed.
            // Alternatively you can construct the XML from scratch.
            var tileXml = new XmlDocument();
            var title = tileXml.CreateElement("title");
            var visual = tileXml.CreateElement("visual");
            visual.SetAttribute("version", "1");
            visual.SetAttribute("lang", "en-US");

            // The template is set to be a TileSquareImage. This tells the tile update manager what to expect next.
            var binding = tileXml.CreateElement("binding");
            binding.SetAttribute("template", "TileSquareImage");
            // An image element is then created under the TileSquareImage XML node. The path to the image is specified
            var image = tileXml.CreateElement("image");
            image.SetAttribute("id", "1");
            image.SetAttribute("src", @"ms-appx:///Assets/DemoImage.png");

            // All the XML elements are chained up together.
            title.AppendChild(visual);
            visual.AppendChild(binding);
            binding.AppendChild(image);
            tileXml.AppendChild(title);

            // The XML is used to create a new TileNotification which is then sent to the TileUpdateManager
            var tileNotification = new TileNotification(tileXml);
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
        }
예제 #2
0
        protected virtual async Task <XmlDocument> GetCategoryXml(string blogId)
        {
            // Get the service document
            Login();

            FixupBlogId(ref blogId);

            XmlRestRequestHelper.XmlRequestResult result = new XmlRestRequestHelper.XmlRequestResult();
            result.uri = FeedServiceUrl;
            var xmlDoc = await xmlRestRequestHelper.Get(RequestFilter, result);

            foreach (XmlElement entryEl in xmlDoc.SelectNodesNS("app:service/app:workspace/app:collection", _nsMgr.ToNSMethodFormat()))
            {
                string href = XmlHelper.GetUrl(entryEl, "@href", result.uri);
                if (blogId == href)
                {
                    XmlDocument results     = new XmlDocument();
                    XmlElement  rootElement = results.CreateElement("categoryInfo");
                    results.AppendChild(rootElement);
                    foreach (XmlElement categoriesNode in entryEl.SelectNodesNS("app:categories", _nsMgr.ToNSMethodFormat()))
                    {
                        await AddCategoriesXml(categoriesNode, rootElement, result);
                    }
                    return(results);
                }
            }
            //Debug.Fail("Couldn't find collection in service document:\r\n" + xmlDoc.OuterXml);
            return(new XmlDocument());
        }
        public static XmlDocument CreateTileTemplate(Wallpaper wallpaper)
        {
            XmlDocument document = new XmlDocument();

            // tile 根节点。
            XmlElement tile = document.CreateElement("tile");
            document.AppendChild(tile);

            // visual 元素。
            XmlElement visual = document.CreateElement("visual");
            tile.AppendChild(visual);

            // Medium,150x150。
            {
                // binding
                XmlElement binding = document.CreateElement("binding");
                binding.SetAttribute("template", "TileMedium");
                visual.AppendChild(binding);

                // image
                XmlElement image = document.CreateElement("image");
                image.SetAttribute("src", wallpaper.GetOriginalUrl(new WallpaperSize(150, 150)));
                image.SetAttribute("placement", "background");
                binding.AppendChild(image);

                // text
                XmlElement text = document.CreateElement("text");
                text.AppendChild(document.CreateTextNode(wallpaper.Archive.Info));
                text.SetAttribute("hint-wrap", "true");
                binding.AppendChild(text);
            }

            // Wide,310x150。
            {
                // binding
                XmlElement binding = document.CreateElement("binding");
                binding.SetAttribute("template", "TileWide");
                visual.AppendChild(binding);

                // image
                XmlElement image = document.CreateElement("image");
                image.SetAttribute("src", wallpaper.GetOriginalUrl(new WallpaperSize(310, 150)));
                image.SetAttribute("placement", "background");
                binding.AppendChild(image);

                // text
                XmlElement text = document.CreateElement("text");
                text.AppendChild(document.CreateTextNode(wallpaper.Archive.Info));
                text.SetAttribute("hint-wrap", "true");
                binding.AppendChild(text);
            }

            return document;
        }
예제 #4
0
파일: Auditor.cs 프로젝트: RajaBellebon/edX
        private async void doAuditing(Order order)
        {
            List<OrderItem> ageRestrictedItems = findAgeRestrictedItems(order);
            if (ageRestrictedItems.Count > 0)
            {
                try
                {
                    StorageFile file = await KnownFolders.DocumentsLibrary.CreateFileAsync("audit-" + order.OrderID.ToString() + ".xml");
                    if (file != null)
                    {
                        XmlDocument doc = new XmlDocument();
                        XmlElement root = doc.CreateElement("Order");
                        root.SetAttribute("ID", order.OrderID.ToString());
                        root.SetAttribute("Date", order.Date.ToString());

                        foreach (OrderItem orderItem in ageRestrictedItems)
                        {
                            XmlElement itemElement = doc.CreateElement("Item");
                            itemElement.SetAttribute("Product", orderItem.Item.Name);
                            itemElement.SetAttribute("Description", orderItem.Item.Description);
                            root.AppendChild(itemElement);
                        }

                        doc.AppendChild(root);

                        await doc.SaveToFileAsync(file);
                    }
                    else
                    {
                        MessageDialog dlg = new MessageDialog(String.Format("Unable to save to file: {0}", file.DisplayName), "Not saved");
                        dlg.ShowAsync();
                    }
                }
                catch (Exception ex)
                {
                    MessageDialog dlg = new MessageDialog(ex.Message, "Exception");
                    dlg.ShowAsync();
                }
                finally 
                {
                    if (this.AuditProcessingComplete != null) 
                    {
                        this.AuditProcessingComplete(String.Format(
                            "Audit record written for Order {0}", order.OrderID)); 
                    }
                }
            }
        }
        public List<string> getList(string franchUserID, string password,
            string userID, string userKey, string username, string userrole,
            string userstatus, string usertype)
        {
            List<string> servicesNames = new List<string>();


            XmlDocument doc = new XmlDocument();

            XmlElement el = (XmlElement)doc.AppendChild(doc.CreateElement("soapenv:Header"));
            el.SetAttribute("Bar", "some & value");



            return servicesNames;
        }
예제 #6
0
        public static async Task SaveOPMLFile(StorageFile libraryFile)
        {
            var document = new Windows.Data.Xml.Dom.XmlDocument();

            var rootNode = document.CreateElement("opml");

            rootNode.AddAttribute("version", "1.1");
            document.AppendChild(rootNode);

            var headNode = document.CreateElement("head");

            headNode.AddChildWithInnerText("title", "Generated by Cast");
            headNode.AddChildWithInnerText("dateCreated", DateTime.Now.ToString(CultureInfo.InvariantCulture));
            rootNode.AppendChild(headNode);

            var bodyNode = document.CreateElement("body");

            rootNode.AppendChild(bodyNode);

            foreach (var category in Categories)
            {
                var categoryNode = document.CreateElement("outline");
                bodyNode.AppendChild(categoryNode);
                categoryNode.AddAttribute("text", category);

                foreach (var podcast in Podcasts.Where(p => p.Category == category))
                {
                    var podcastNode = document.CreateElement("outline");
                    categoryNode.AppendChild(podcastNode);

                    podcastNode.AddAttribute("title", podcast.Title);
                    podcastNode.AddAttribute("type", "rss");
                    podcastNode.AddAttribute("text", podcast.FeedUrl);
                    podcastNode.AddAttribute("xmlUrl", podcast.FeedUrl);
                }
            }

            await document.SaveToFileAsync(libraryFile);
        }
예제 #7
0
        private async void CheckGoodsFile()
        {
            try
            {
                Windows.Storage.StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
                Windows.Storage.StorageFile storageFile = await storageFolder.GetFileAsync("Goods.xml");
            }
            catch(IOException e)
            {
#if DEBUG
                System.Diagnostics.Debug.WriteLine(e.Message);
#endif
                Windows.Storage.StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
                Windows.Storage.StorageFile storageFile = await storageFolder.CreateFileAsync("Goods.xml", CreationCollisionOption.ReplaceExisting);
                XmlDocument doc = new XmlDocument();
                XmlElement ele = doc.CreateElement("orders");
                ele.InnerText = "";
                doc.AppendChild(ele);
                await doc.SaveToFileAsync(storageFile);
            }
            try
            {
                Windows.Storage.StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
                Windows.Storage.StorageFile storageFile = await storageFolder.GetFileAsync("ShoppingCart.xml");
            }
            catch (IOException e)
            {
#if DEBUG
                System.Diagnostics.Debug.WriteLine(e.Message);
#endif
                Windows.Storage.StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
                Windows.Storage.StorageFile storageFile = await storageFolder.CreateFileAsync("ShoppingCart.xml", CreationCollisionOption.ReplaceExisting);
                XmlDocument doc = new XmlDocument();
                XmlElement ele = doc.CreateElement("goods");
                ele.InnerText = "";
                doc.AppendChild(ele);
                await doc.SaveToFileAsync(storageFile);
            }
        }
예제 #8
0
        public static void SendToast(string txt, string imgurl = "")
        {
            if (toaster.Setting != NotificationSetting.Enabled) return;

            // It is possible to start from an existing template and modify what is needed.
            // Alternatively you can construct the XML from scratch.
            var toastXml = new Windows.Data.Xml.Dom.XmlDocument();
            var title = toastXml.CreateElement("toast");
            var visual = toastXml.CreateElement("visual");
            visual.SetAttribute("version", "1");
            visual.SetAttribute("lang", "en-US");

            // The template is set to be a ToastImageAndText01. This tells the toast notification manager what to expect next.
            var binding = toastXml.CreateElement("binding");
            binding.SetAttribute("template", "ToastImageAndText01");

            // An image element is then created under the ToastImageAndText01 XML node. The path to the image is specified
            var image = toastXml.CreateElement("image");
            image.SetAttribute("id", "1");
            image.SetAttribute("src", imgurl);

            // A text element is created under the ToastImageAndText01 XML node.
            var text = toastXml.CreateElement("text");
            text.SetAttribute("id", "1");
            text.InnerText = txt;

            // All the XML elements are chained up together.
            title.AppendChild(visual);
            visual.AppendChild(binding);
            binding.AppendChild(image);
            binding.AppendChild(text);

            toastXml.AppendChild(title);

            // Create a ToastNotification from our XML, and send it to the Toast Notification Manager
            var toast = new ToastNotification(toastXml);
            toaster.Show(toast);
        }
        /// <summary>
        /// Init the Connector. Create the File if not exist, or open and load it.
        /// </summary>
        public async void InitDataBase()
        {
            var localFolder = ApplicationData.Current.LocalFolder;
            _rootDocument = new XmlDocument();

            _databaseXmlFile = await localFolder.CreateFileAsync("TaskTimeRecorder.xml", CreationCollisionOption.OpenIfExists);
            var fileContent = await FileIO.ReadTextAsync(_databaseXmlFile);

            if (fileContent == "")
            {
                var rootElement = _rootDocument.CreateElement("TaskTimeRecorder");
                var tasksElement = _rootDocument.CreateElement("Tasks");

                rootElement.AppendChild(tasksElement);
                _rootDocument.AppendChild(rootElement);

                _rootDocument.SaveToFileAsync(_databaseXmlFile);
            }
            else
            {
                _rootDocument.LoadXml(fileContent);
                LoadAllTasks();
            }
        }
        /// <summary>
        /// Raises a image toast notification locally.
        /// IMPORTANT: if copying this into your own application, ensure that "Toast capable" is enabled in the application manifest
        /// </summary>
        private void NotificationImageButton_Click(object sender, RoutedEventArgs e)
        {
            // It is possible to start from an existing template and modify what is needed.
            // Alternatively you can construct the XML from scratch.
            var toastXml = new XmlDocument();
            var title = toastXml.CreateElement("toast");
            var visual = toastXml.CreateElement("visual");
            visual.SetAttribute("version", "1");
            visual.SetAttribute("lang", "en-US");

            // The template is set to be a ToastImageAndText01. This tells the toast notification manager what to expect next.
            var binding = toastXml.CreateElement("binding");
            binding.SetAttribute("template", "ToastImageAndText01");

            // An image element is then created under the ToastImageAndText01 XML node. The path to the image is specified
            var image = toastXml.CreateElement("image");
            image.SetAttribute("id", "1");
            image.SetAttribute("src", @"Assets/DemoImage.png");

            // A text element is created under the ToastImageAndText01 XML node.
            var text = toastXml.CreateElement("text");
            text.SetAttribute("id", "1");
            text.InnerText = "Another sample toast. This time with an image";

            // All the XML elements are chained up together.
            title.AppendChild(visual);
            visual.AppendChild(binding);
            binding.AppendChild(image);
            binding.AppendChild(text);

            toastXml.AppendChild(title);

            // Create a ToastNotification from our XML, and send it to the Toast Notification Manager
            var toast = new ToastNotification(toastXml);
            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
예제 #11
0
        private async Task GetHtmlContent(DataPackage requestData, Empresa empresa, Item item)
        {
            var xml = new XmlDocument();
            var body = xml.CreateElement("DIV");

            xml.AppendChild(body);

            //Dados da empresa
            string Telefones = Utils.GetTelefoneNumeros(empresa.Telefones);

            string empresaShareText = empresa.ShareTexto.Replace("#TELEFONE#", Telefones).Replace("#URL#", empresa.Website);


            var empresaData = xml.CreateElement("P");
            empresaData.InnerText = empresaShareText;
            body.AppendChild(empresaData);

            body.AppendChild(xml.CreateElement("HR"));


            //Dados do Item compartilhado

            var Image = xml.CreateElement("IMG");
            Image.SetAttribute("SRC", new Uri(_baseUri, item.ImageUrl).ToString());
            body.AppendChild(Image);

            var Itemtipo = xml.CreateElement("H2");
            Itemtipo.InnerText = item.SubTitulo;

            var breakline = xml.CreateElement("BR");
            Itemtipo.AppendChild(breakline);

            var bold = xml.CreateElement("b");
            bold.InnerText = string.Format("R$ {0}", item.Valor);
            Itemtipo.AppendChild(bold);

            body.AppendChild(Itemtipo);

            var ImageDescription = xml.CreateElement("P");
            ImageDescription.InnerText = item.Descricao;
            body.AppendChild(ImageDescription);

            var localImage = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(item.ImageUrl.Replace("/", "\\"));

            requestData.SetHtmlFormat(HtmlFormatHelper.CreateHtmlFormat(xml.GetXml()));
            requestData.ResourceMap[new Uri(_baseUri, item.ImageUrl).ToString()] = Windows.Storage.Streams.RandomAccessStreamReference.CreateFromFile(localImage);
        }
        /// <summary>
        /// Appends a wide tile with a big block of text. Used to display up-coming buses.
        /// </summary>
        public void AppendTileWithBlockTextAndLines(DateTimeOffset scheduledTime, string blockText, string statusText, string busName, string tripHeadsign, string stopName, string scheduledArrivalTime, string predictedArrivalTime)
        {
            //<tile>
            //  <visual>
            //    <binding template="TileWideBlockAndText01">
            //      <text id="1">Text Field 1</text>
            //      <text id="2">Text Field 2</text>
            //      <text id="3">Text Field 3</text>
            //      <text id="4">Text Field 4</text>
            //      <text id="5">T5</text>
            //      <text id="6">Text Field 6</text>
            //    </binding>  
            //  </visual>
            //</tile>
            var document = new XmlDocument();
            var rootElement = document.CreateElement("tile");
            document.AppendChild(rootElement);

            XmlElement visualElement = document.CreateElement("visual");
            visualElement.SetAttribute("version", "2");
            rootElement.AppendChild(visualElement);

            // Support large tiles for Win 8.1 and higher:
            //<visual version="2">
            //  <binding template="TileSquare310x310BlockAndText01">
            //    <text id="1">Text Field 1 (large text)</text>
            //    <text id="2">Text Field 2</text>
            //    <text id="3">Text Field 3</text>
            //    <text id="4">Text Field 4</text>
            //    <text id="5">Text Field 5</text>
            //    <text id="6">Text Field 6</text>
            //    <text id="7">Text Field 7</text>
            //    <text id="8">Text Field 8 (block text)</text>
            //    <text id="9">Text Field 9</text>
            //  </binding>  
            //</visual>
            XmlElement largeBindingElement = document.CreateElement("binding");
            largeBindingElement.SetAttribute("template", "TileSquare310x310BlockAndText01");

            AddSubTextElements(largeBindingElement, new string[]
            {
                busName,
                tripHeadsign,
                stopName,
                "SCHED / ETA",
                string.Format("{0} / {1}", scheduledArrivalTime, predictedArrivalTime),
                string.Empty,
                string.Empty,
                blockText,
                statusText,
            });

            visualElement.AppendChild(largeBindingElement);


            XmlElement wideBindingElement = document.CreateElement("binding");            
            wideBindingElement.SetAttribute("template", "TileWide310x150BlockAndText01");
            wideBindingElement.SetAttribute("fallback", "TileWideBlockAndText01");
            visualElement.AppendChild(wideBindingElement);

            AddSubTextElements(wideBindingElement, new string[]
            {
                busName,
                tripHeadsign,
                stopName,
                string.Format("{0} / {1}", scheduledArrivalTime, predictedArrivalTime),
                blockText,
                statusText,
            });

            // Unfortunately, there is only one small tile template that supports block text.
            //<tile>
            //  <visual>
            //    <binding template="TileSquareBlock">
            //      <text id="1">Text Field 1</text>
            //      <text id="2">Text Field 2</text>
            //    </binding>  
            //  </visual>
            //</tile>
            XmlElement smallBindingElement = document.CreateElement("binding");
            smallBindingElement.SetAttribute("template", "TileSquare150x150Block");
            smallBindingElement.SetAttribute("fallback", "TileSquareBlock");
            visualElement.AppendChild(smallBindingElement);

            XmlElement smallBlockTextElement = document.CreateElement("text");
            smallBlockTextElement.SetAttribute("id", "1");
            smallBlockTextElement.InnerText = blockText;
            smallBindingElement.AppendChild(smallBlockTextElement);

            XmlElement smallSubTextElement = document.CreateElement("text");
            smallSubTextElement.SetAttribute("id", "2");
            smallSubTextElement.InnerText = busName;
            smallBindingElement.AppendChild(smallSubTextElement);

            if ((scheduledTime - DateTime.Now).TotalMinutes < 1)
            {
                var notification = new TileNotification(document);
                notification.ExpirationTime = scheduledTime.AddMinutes(1);
                notification.Tag = (busName + tripHeadsign + stopName + scheduledTime.ToString("hh:mm")).GetHashCode().ToString("X");
                this.tileUpdater.Update(notification);
            }
            else
            {
                var notification = new ScheduledTileNotification(document, scheduledTime);
                notification.ExpirationTime = scheduledTime.AddMinutes(1);
                notification.Tag = (busName + tripHeadsign + stopName + scheduledTime.ToString("hh:mm")).GetHashCode().ToString("X");
                this.tileUpdater.AddToSchedule(notification);
            }
        }
예제 #13
0
        private async Task LoadLocalMetadata()
        {
            if (localXml == null)
            {
                var file = await _folder.CreateFileAsync("magazines.metadata", CreationCollisionOption.OpenIfExists);
                Task task = null;
                try
                {
                    localXml = await XmlDocument.LoadFromFileAsync(file);
                }
                catch
                {
                    localXml = new XmlDocument();
                    var root = localXml.CreateElement("root");
                    localXml.AppendChild(root);

                    task = localXml.SaveToFileAsync(file).AsTask();
                }

                if (task != null)
                    await task;
            }

            _magazinesLocalUrl.Clear();
            var mags = localXml.SelectNodes("/root/mag");
            bool error = false;
            foreach (var mag in mags)
            {
                try
                {
                    _magazinesLocalUrl.Add(DownloadManager.GetLocalUrl(mag));
                }
                catch
                {
                    error = true;
                    break;
                }
            }

            if (error)
            {
                var file = await _folder.CreateFileAsync("magazines.metadata", CreationCollisionOption.ReplaceExisting);

                localXml = new XmlDocument();
                var root = localXml.CreateElement("root");
                localXml.AppendChild(root);

                var task = localXml.SaveToFileAsync(file).AsTask();

                _magazinesLocalUrl.Clear();
            }

            if (_magazinesLocalUrl.Count == 0)
            {
                var fileHandle =
                            await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"CustomizationAssets\Magazines.plist");
                var stream = await fileHandle.OpenReadAsync();
                var dataReader = new DataReader(stream.GetInputStreamAt(0));
                var size = await dataReader.LoadAsync((uint)stream.Size);
                var str = dataReader.ReadString(size);
                dataReader.DetachStream();
                stream.Dispose();
                stream = null;
                if (str.Contains("<!DOCTYPE"))
                {
                    var pos = str.IndexOf("<!DOCTYPE");
                    var end = str.IndexOf(">", pos + 7);
                    if (end >= 0)
                        str = str.Remove(pos, end - pos + 1);
                }
                XmlDocument xml = new XmlDocument();
                xml.LoadXml(str);
                await ReadPList(xml);

                var folder = ApplicationData.Current.LocalFolder;
                try
                {
                    // Set query options to create groups of files within result
                    var queryOptions = new QueryOptions(Windows.Storage.Search.CommonFolderQuery.DefaultQuery);
                    queryOptions.UserSearchFilter = "System.FileName:=Covers";

                    // Create query and retrieve result
                    StorageFolderQueryResult queryResult = folder.CreateFolderQueryWithOptions(queryOptions);
                    IReadOnlyList<StorageFolder> folders = await queryResult.GetFoldersAsync();

                    if (folders.Count != 1)
                    {
                        await Utils.Utils.LoadDefaultData();
                    }
                }
                catch { }
            }
        }
예제 #14
0
        private async Task<StorageFile> DownloadPDFAssetsAsync(LibrelioLocalUrl magUrl, IList<string> list, IProgress<int> progress = null, CancellationToken cancelToken = default(CancellationToken))
        {
            var folder = await StorageFolder.GetFolderFromPathAsync(magUrl.FolderPath.Substring(0, magUrl.FolderPath.Length-1));
            var file = await folder.CreateFileAsync(magUrl.MetadataName, CreationCollisionOption.ReplaceExisting);
            var xml = new XmlDocument();
            var root = xml.CreateElement("root");
            var name = xml.CreateElement("name");
            name.InnerText = magUrl.FullName;
            var date = xml.CreateElement("date");
            date.InnerText = DateTime.Today.Month.ToString() + "/" + DateTime.Today.Day.ToString() + "/" + DateTime.Today.Year.ToString();
            xml.AppendChild(root);
            root.AppendChild(name);
            root.AppendChild(date);
            await xml.SaveToFileAsync(file);
            cancelToken.ThrowIfCancellationRequested();

            for (int i = 0; i < list.Count; i++)
            {
                var loader = new ResourceLoader();
                StatusText = loader.GetString("downloading") + " " + (i + 2) + "/" + (list.Count + 1);
                var url = list[i];
                cancelToken.ThrowIfCancellationRequested();

                string absLink = url;
                var pos = absLink.IndexOf('?');
                if (pos >= 0) absLink = url.Substring(0, pos);
                string fileName = absLink.Replace("http://localhost/", "");
                string linkString = "";
                linkString = folder.Path + "\\" + absLink.Replace("http://localhost/", "");
                pos = magUrl.Url.LastIndexOf('/');
                var assetUrl = magUrl.Url.Substring(0, pos + 1);
                absLink = absLink.Replace("http://localhost/", assetUrl);

                var sampleFile = await folder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);

                await DownloadFileAsyncWithProgress(absLink, sampleFile, progress, cancelToken);

                var asset = xml.CreateElement("asset");
                asset.InnerText = linkString;
                root.AppendChild(asset);
                await xml.SaveToFileAsync(file);
            }

            return file;
        }
예제 #15
0
파일: City.xaml.cs 프로젝트: 745322878/Code
        /// <summary>
        /// 在此页将要在 Frame 中显示时进行调用。
        /// </summary>
        /// <param name="e">描述如何访问此页的事件数据。
        /// 此参数通常用于配置页。</param>
        async protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter != null)
            {
                cityname = new Citys();

                cityname.city = e.Parameter.ToString();
                App.nearFindCity.Clear();
                //读取近期城市文件
                StorageFolder storage = await ApplicationData.Current.LocalFolder.CreateFolderAsync("NearCityList", CreationCollisionOption.OpenIfExists);
               //获取当前文件夹中的文件
                var files = await storage.GetFilesAsync();        
                //遍历每个文件 
                foreach (StorageFile file in files)
                 {
                     file.DateCreated.ToFileTime();
                    //XmlDocument doc=await XmlDocument.LoadFromUriAsync (new Uri(file.Path));
                    //cityname.city = doc.DocumentElement.Attributes.GetNamedItem("city").NodeValue.ToString();
                     cityname1 = new Citys();
                     cityname1.city = file.DisplayName;
                     if (cityname1.city == "City")
                         continue;
                     else
                     {
                         App.nearFindCity.Add(cityname1);
                     }
                 }
                 if (App.nearFindCity.Count == 0)
                     App.nearFindCity.Add(cityname);
                 else
                 {
                    //if(App.nearFindCity.Contains (cityname )==true )
                    //     return;
                     foreach (Citys  city5 in App.nearFindCity)
                     {
                         if (city5.city.ToString() == cityname.city.ToString()) 
                            goto loop;
                     }
                     
                         App.nearFindCity.Add(cityname);
                         if (App.nearFindCity.Count > 3)
                         {
                             do
                             {
                                 Random r = new Random();
                                 
                                 App.nearFindCity.RemoveAt(r.Next(2));
                             } while (App.nearFindCity.Count != 3);
                         }
                     
                 }
                
                  loop:
                  StorageFolder storage1 = await ApplicationData.Current.LocalFolder.CreateFolderAsync("NearCityList",CreationCollisionOption.ReplaceExisting);
                
                  foreach(Citys cityname2 in App.nearFindCity )
                 {
                     XmlDocument _doc = new XmlDocument();
                     XmlElement _item = _doc.CreateElement(cityname2.city.ToString ());
                     _doc.AppendChild(_item);
                     StorageFile file1 = await storage1.CreateFileAsync(cityname2.city.ToString() + ".xml", CreationCollisionOption.ReplaceExisting);
                     await _doc.SaveToFileAsync(file1);
                 }
               
              
            }
           
        }
예제 #16
0
        private async Task LoadLocalMetadata()
        {
            if (localXml == null)
            {
                var file = await _folder.CreateFileAsync("magazines.metadata", CreationCollisionOption.OpenIfExists);
                try
                {
                    localXml = await XmlDocument.LoadFromFileAsync(file);
                }
                catch
                {
                    localXml = new XmlDocument();
                    var root = localXml.CreateElement("root");
                    localXml.AppendChild(root);

                    var task = localXml.SaveToFileAsync(file).AsTask();

                    return;
                }
            }

            _magazinesLocalUrl.Clear();
            var mags = localXml.SelectNodes("/root/mag");
            bool error = false;
            foreach (var mag in mags)
            {
                try
                {
                    _magazinesLocalUrl.Add(DownloadManager.GetLocalUrl(mag));
                }
                catch
                {
                    error = true;
                    break;
                }
            }

            if (error)
            {
                var file = await _folder.CreateFileAsync("magazines.metadata", CreationCollisionOption.ReplaceExisting);

                localXml = new XmlDocument();
                var root = localXml.CreateElement("root");
                localXml.AppendChild(root);

                var task = localXml.SaveToFileAsync(file).AsTask();

                _magazinesLocalUrl.Clear();
            }
        }
예제 #17
0
        /// <summary>
        /// Appends a wide tile with a big block of text. Used to display up-coming buses.
        /// </summary>
        public void AppendTileWithBlockTextAndLines(DateTimeOffset scheduledTime, string blockText, string subBlockText, string text1 = null, string text2 = null, string text3 = null, string text4 = null)
        {
            //<tile>
            //  <visual>
            //    <binding template="TileWideBlockAndText01">
            //      <text id="1">Text Field 1</text>
            //      <text id="2">Text Field 2</text>
            //      <text id="3">Text Field 3</text>
            //      <text id="4">Text Field 4</text>
            //      <text id="5">T5</text>
            //      <text id="6">Text Field 6</text>
            //    </binding>  
            //  </visual>
            //</tile>
            var document = new XmlDocument();
            var rootElement = document.CreateElement("tile");
            document.AppendChild(rootElement);

            XmlElement visualElement = document.CreateElement("visual");
            rootElement.AppendChild(visualElement);

            XmlElement wideBindingElement = document.CreateElement("binding");
            wideBindingElement.SetAttribute("template", "TileWideBlockAndText01");
            visualElement.AppendChild(wideBindingElement);

            string[] wideTexts = new string[]
            {
                text1,
                text2,
                text3,
                text4,
                blockText,
                subBlockText,
            };

            for (int i = 0; i < wideTexts.Length; i++)
            {
                string text = wideTexts[i];
                if (!string.IsNullOrEmpty(text))
                {
                    XmlElement textElement = document.CreateElement("text");
                    textElement.SetAttribute("id", (i + 1).ToString());
                    textElement.InnerText = text;
                    wideBindingElement.AppendChild(textElement);
                }
            }

            // Unfortunately, there is only one small tile template that supports block text.
            //<tile>
            //  <visual>
            //    <binding template="TileSquareBlock">
            //      <text id="1">Text Field 1</text>
            //      <text id="2">Text Field 2</text>
            //    </binding>  
            //  </visual>
            //</tile>
            XmlElement smallBindingElement = document.CreateElement("binding");
            smallBindingElement.SetAttribute("template", "TileSquareBlock");
            visualElement.AppendChild(smallBindingElement);

            XmlElement smallBlockTextElement = document.CreateElement("text");
            smallBlockTextElement.SetAttribute("id", "1");
            smallBlockTextElement.InnerText = blockText;
            smallBindingElement.AppendChild(smallBlockTextElement);

            XmlElement smallSubTextElement = document.CreateElement("text");
            smallSubTextElement.SetAttribute("id", "2");
            smallSubTextElement.InnerText = text1;
            smallBindingElement.AppendChild(smallSubTextElement);

            if ((scheduledTime - DateTime.Now).TotalMinutes < 1)
            {
                var notification = new TileNotification(document);
                notification.ExpirationTime = scheduledTime.AddMinutes(1);
                notification.Tag = (text1 + text2 + text3 + scheduledTime.ToString("hh:mm")).GetHashCode().ToString("X");
                this.tileUpdater.Update(notification);
            }
            else
            {
                var notification = new ScheduledTileNotification(document, scheduledTime);
                notification.ExpirationTime = scheduledTime.AddMinutes(1);
                notification.Tag = (text1 + text2 + text3 + scheduledTime.ToString("hh:mm")).GetHashCode().ToString("X");
                this.tileUpdater.AddToSchedule(notification);
            }
        }
예제 #18
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            StorageFile localFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("usersettings.xml", CreationCollisionOption.ReplaceExisting);

            XmlDocument xmlDoc = new XmlDocument();

            XmlElement root = xmlDoc.CreateElement("Categories");
            xmlDoc.AppendChild(root);

            foreach (Bill bill in selectedBills)
            {
                XmlElement xmlElement = xmlDoc.CreateElement("Bill");
                xmlElement.SetAttribute("Type", bill.BillType.ToString());
                xmlElement.SetAttribute("Title", bill.Title);
                xmlElement.SetAttribute("SubTitle", bill.SubTitle);
                xmlElement.SetAttribute("ImagePath", bill.ImagePath);
                xmlElement.SetAttribute("PortalUrl", bill.PortalUrl);

                XmlElement dueDate = xmlDoc.CreateElement("DueDate");
                dueDate.InnerText = bill.DueDate.ToString();

                XmlElement isPaid = xmlDoc.CreateElement("IsPaid");
                isPaid.InnerText = bill.IsPaid.ToString();

                xmlElement.AppendChild(dueDate);
                xmlElement.AppendChild(isPaid);

                root.AppendChild(xmlElement);
            }

            await xmlDoc.SaveToFileAsync(localFile);

            this.Frame.Navigate(typeof(HomePage));
        }
예제 #19
0
 public async Task checkFileSystem()
 {
     StorageFile file;
     bool there = true;
     try
     {
         file = await ApplicationData.Current.LocalFolder.GetFileAsync("logdata.xml");
     }
     catch (FileNotFoundException)
     {
         Debug.WriteLine("No file found");
         there = false;
     }
     if (there == false)
     {
         //Debug.WriteLine("Creating File");
         XmlDocument doc = new XmlDocument();
         XmlElement root = doc.CreateElement("LOG");
         doc.AppendChild(root);
         file = await ApplicationData.Current.LocalFolder.CreateFileAsync("logdata.xml");
         await FileIO.WriteTextAsync(file, doc.GetXml());
         Debug.WriteLine("Done creating file.");
         //await doc.SaveToFileAsync(st);
     }
 }
예제 #20
0
        async private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;
            //获取记事本的文件夹对象NoteList
            StorageFolder storage = await ApplicationData.Current.LocalFolder.GetFolderAsync("CityList");


            //创建一个XML对象
            XmlDocument _doc = new XmlDocument();
            //使用记事本名字创建一个XML元素作为根节点
            XmlElement _item = _doc.CreateElement(btn.Content.ToString());

            //使用属性来作为信息的标识符,使用属性值来存储相关的信息
            //_item.SetAttribute("city", t.Text );
            _doc.AppendChild(_item);
            //创建一个应用文件
            StorageFile file = await storage.CreateFileAsync(btn.Content.ToString() + ".xml", CreationCollisionOption.ReplaceExisting);
            //把XML的信息保存到文件中去
            await _doc.SaveToFileAsync(file);




            (Window.Current.Content as Frame).Navigate(typeof(CollectionCity));
        }
예제 #21
0
        // Write project to project xml file
        public async void Save()
        {
            XmlDocument doc = new XmlDocument();
            XmlElement root = doc.CreateElement("TranscriberProject");
            root.SetAttribute("Name", Name);

            XmlElement utterancesEl = doc.CreateElement("Utterances");
            foreach (Utterance u in Utterances)
            {
                XmlElement utteranceEl = u.ToXmlElement(doc);
                utterancesEl.AppendChild(utteranceEl);
            }

            root.AppendChild(utterancesEl);
            doc.AppendChild(root);
            await doc.SaveToFileAsync(ProjectFile);

            foreach (Utterance u in Utterances)
            {
                u.Modified = false;
            }
        }
예제 #22
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e != null && e.Parameter != null)
            {
                CurrentCode = e.Parameter as Code;
                if (CurrentCode != null)
                {
                    Report = new XmlDocument();
                    CodeElement = Report.CreateElement("Code");
                    CodeElement.SetAttribute("CPRStartTime", CurrentCode.CPRStartTime.ToString());
                    CodeElement.SetAttribute("CPREndTime", CurrentCode.CPREndTime.ToString());
                    DefibElement = Report.CreateElement("Defibrillation");
                    PatientInfoElement = Report.CreateElement("PatientInformation");
                    CodeElement.AppendChild(DefibElement);
                    CodeElement.AppendChild(PatientInfoElement);
                    Report.AppendChild(CodeElement);
                }
            }

            if (CurrentDefibrillation == null)
            {
                CurrentDefibrillation = new Defibrillation();
            }
            if (CurrentPatientInfo == null)
            {
                CurrentPatientInfo = new PatientInformation();
            }
            base.OnNavigatedTo(e);
        }
예제 #23
0
        public async Task <string> NewPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, PostResult postResult)
        {
            if (!publish && !Options.SupportsPostAsDraft)
            {
                //Debug.Fail("Post to draft not supported on this provider");
                throw new BlogClientPostAsDraftUnsupportedException();
            }

            Login();

            FixupBlogId(ref blogId);

            XmlDocument doc       = new XmlDocument();
            XmlElement  entryNode = doc.CreateElementNS(_atomNS.Uri, _atomNS.Prefix + ":entry");

            doc.AppendChild(entryNode);
            Populate(post, null, entryNode, publish);

            string slug = null;

            if (Options.SupportsSlug)
            {
                slug = post.Slug;
            }

            XmlRestRequestHelper.XmlRequestResult xmlResult2 = new XmlRestRequestHelper.XmlRequestResult();
            xmlResult2.uri = new Uri(blogId);
            XmlDocument result = await xmlRestRequestHelper.Post(
                new HttpAsyncRequestFilter(new NewPostRequest(this, slug).RequestFilter),
                ENTRY_CONTENT_TYPE,
                doc,
                _clientOptions.CharacterSet,
                xmlResult2);

            postResult.ETag = FilterWeakEtag(xmlResult2.responseHeaders["ETag"]);
            string location = xmlResult2.responseHeaders["Location"];

            if (string.IsNullOrEmpty(location))
            {
                throw new BlogClientInvalidServerResponseException("POST", "The HTTP response was missing the required Location header.", "");
            }
            if (location != xmlResult2.responseHeaders["Content-Location"] || result == null)
            {
                XmlRestRequestHelper.XmlRequestResult xmlResult = new XmlRestRequestHelper.XmlRequestResult();
                xmlResult.uri = new Uri(location);
                result        = await xmlRestRequestHelper.Get(RequestFilter, xmlResult);

                postResult.ETag = FilterWeakEtag(xmlResult.responseHeaders["ETag"]);
            }

            postResult.AtomRemotePost = (XmlDocument)result.CloneNode(true);
            Parse(result.DocumentElement, true, xmlResult2.uri);

            if (Options.SupportsNewCategories)
            {
                foreach (BlogPostCategory category in post.NewCategories)
                {
                    newCategoryContext.NewCategoryAdded(category);
                }
            }

            return(PostUriToPostId(location));
        }
예제 #24
0
        /// <summary>
        /// Appends TileWideImageAndText01 to the document.
        /// </summary>
        public async Task AppendTileWithLargePictureAndTextAsync(string tileId, double latitude, double longitude, string text)
        {
            string wideTileImageFile = await CreateTileMapImageAsync(tileId, latitude, longitude, 310, 160, true);

            //<visual>
            //  <binding template="TileWideImageAndText01">
            //    <image id="1" src="image1.png" alt="alt text"/>
            //    <text id="1">Text Field 1</text>
            //  </binding>  
            //</visual>
            var document = new XmlDocument();
            var rootElement = document.CreateElement("tile");
            document.AppendChild(rootElement);

            XmlElement visualElement = document.CreateElement("visual");
            rootElement.AppendChild(visualElement);

            XmlElement wideBindingElement = document.CreateElement("binding");
            wideBindingElement.SetAttribute("template", "TileWideImageAndText01");
            visualElement.AppendChild(wideBindingElement);

            XmlElement wideImageElement = document.CreateElement("image");
            wideImageElement.SetAttribute("id", "1");
            wideImageElement.SetAttribute("src", string.Format(@"ms-appdata:///local/Tiles/{0}", wideTileImageFile));
            wideImageElement.SetAttribute("alt", text);
            wideBindingElement.AppendChild(wideImageElement);

            XmlElement wideTextElement = document.CreateElement("text");
            wideTextElement.SetAttribute("id", "1");
            wideTextElement.InnerText = text;
            wideBindingElement.AppendChild(wideTextElement);

            // Also add the small tile image:
            //<tile>
            //  <visual>
            //    <binding template="TileSquareImage">
            //      <image id="1" src="image1" alt="alt text"/>
            //    </binding>  
            //  </visual>
            //</tile>
            string smallTileImageFile = await CreateTileMapImageAsync(tileId, latitude, longitude, 160, 160, false);
            
            XmlElement smallBindingElement = document.CreateElement("binding");
            smallBindingElement.SetAttribute("template", "TileSquareImage");
            visualElement.AppendChild(smallBindingElement);

            XmlElement smallImageElement = document.CreateElement("image");
            smallImageElement.SetAttribute("id", "1");
            smallImageElement.SetAttribute("src", string.Format(@"ms-appdata:///local/Tiles/{0}", smallTileImageFile));
            smallImageElement.SetAttribute("alt", text);
            smallBindingElement.AppendChild(smallImageElement);

            TileNotification notification = new TileNotification(document);
            notification.Tag = tileId.GetHashCode().ToString("X");
            this.tileUpdater.Update(notification);
        }
예제 #25
0
        private async Task LoadLocalMetadataDownloaded()
        {
            if (localDownloadedXml == null)
            {
                var file = await _folder.CreateFileAsync("magazines_downloaded.metadata", CreationCollisionOption.OpenIfExists);
                Task task = null;
                try
                {
                    localDownloadedXml = await XmlDocument.LoadFromFileAsync(file);
                }
                catch
                {
                    localDownloadedXml = new XmlDocument();
                    var root = localDownloadedXml.CreateElement("root");
                    localDownloadedXml.AppendChild(root);

                    task = localDownloadedXml.SaveToFileAsync(file).AsTask();
                }

                if (task != null)
                    await task;
            }

            _magazinesLocalUrlDownloaded.Clear();
            var mags = localDownloadedXml.SelectNodes("/root/mag");
            bool error = false;
            foreach (var mag in mags)
            {
                try
                {
                    _magazinesLocalUrlDownloaded.Add(DownloadManager.GetLocalUrl(mag));
                }
                catch
                {
                    error = true;
                    break;
                }
            }

            if (error)
            {
                var file = await _folder.CreateFileAsync("magazines_downloaded.metadata", CreationCollisionOption.ReplaceExisting);

                localDownloadedXml = new XmlDocument();
                var root = localDownloadedXml.CreateElement("root");
                localDownloadedXml.AppendChild(root);

                var task = localDownloadedXml.SaveToFileAsync(file).AsTask();

                _magazinesLocalUrlDownloaded.Clear();
            }

            foreach (var item in _magazinesLocalUrlDownloaded)
            {
                var items = _magazinesLocalUrl.Where(magazine => magazine.FullName.Equals(item.FullName));

                if (items != null && items.Count() > 0)
                {
                    var magazine = items.First();
                    var index = _magazinesLocalUrl.IndexOf(magazine);
                    if (index == -1) continue; 
                    _magazinesLocalUrl[index] = item;
                }
            }
        }
예제 #26
0
        private async void GenerateGpx(LondonBicycles.Data.Models.Point myLocation, LondonBicycles.Data.Models.Point destination)
        {
            if (this.route.RoutePoints.Count() > 0)
            {
                XmlDocument doc = new XmlDocument();
                XmlElement gpx = doc.CreateElement("gpx");

                gpx.SetAttribute("xmlns", "http://www.topografix.com/GPX/1/1");
                gpx.SetAttribute("version", "1.1");
                gpx.SetAttribute("creator", "London Bicycles");
                gpx.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");

                XmlElement wptStart = doc.CreateElement("wpt");

                wptStart.SetAttribute("lon", myLocation.Longitude.ToString());
                wptStart.SetAttribute("lat", myLocation.Latitude.ToString());

                gpx.AppendChild(wptStart);

                XmlElement wptEnd = doc.CreateElement("wpt");

                wptEnd.SetAttribute("lon", destination.Longitude.ToString());
                wptEnd.SetAttribute("lat", destination.Latitude.ToString());

                gpx.AppendChild(wptEnd);

                XmlElement track = doc.CreateElement("trk");
                XmlElement trackSegment = doc.CreateElement("trkseg");

                foreach (var point in this.route.RoutePoints)
                {
                    XmlElement trackPoint = doc.CreateElement("trkpt");
                    XmlAttribute lonTrack = doc.CreateAttribute("lon");
                    lonTrack.Value = point.Longitude.ToString();
                    XmlAttribute latTrack = doc.CreateAttribute("lat");
                    latTrack.Value = point.Latitude.ToString();

                    trackPoint.SetAttribute("lon", point.Longitude.ToString());
                    trackPoint.SetAttribute("lat", point.Latitude.ToString());
                    trackSegment.AppendChild(trackPoint);
                }

                track.AppendChild(trackSegment);
                gpx.AppendChild(track);
                doc.AppendChild(gpx);

                string text = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
                text += doc.GetXml();

                StorageFolder sf = Windows.Storage.ApplicationData.Current.RoamingFolder;
                StorageFile file = await sf.CreateFileAsync("route.gpx", CreationCollisionOption.ReplaceExisting);
                Windows.Storage.FileIO.WriteTextAsync(file, text);

                this.gpxFile = file;
                this.RegisterForShare();
            }
        }
예제 #27
0
        private async void nextButton_Click_1(object sender, RoutedEventArgs e)
        {
            if ("Exit".Equals(nextButton.Content.ToString()))
            {
                StorageFile st = null;
                bool exists = true;
                XmlNodeList _names = null, _scores = null;
                try
                {
                    st = await ApplicationData.Current.LocalFolder.GetFileAsync("score.xml");
                    dom = await XmlDocument.LoadFromFileAsync(st);
                    _names = dom.GetElementsByTagName("name");
                    _scores = dom.GetElementsByTagName("highscore");
                }
                catch (Exception)
                {
                    exists = false;
                }

                if (!exists)
                {
                    st = await ApplicationData.Current.LocalFolder.CreateFileAsync("score.xml");
                }

                ObservableCollection<Player> playerTable = new ObservableCollection<Player>();
                if (_names != null)
                {
                    for (int i = 0; i < _names.Count; i++)
                    {
                        string tempName = _names.ElementAt(i).InnerText;
                        int tempScore = Int32.Parse(_scores.ElementAt(i).InnerText);
                        playerTable.Add(new Player(tempName, tempScore));
                    }
                }

                playerTable.Add(new Player(playerName, score));

                dom = new XmlDocument();
                x = dom.CreateElement("users");
                dom.AppendChild(x);
                foreach (var elem in playerTable)
                {
                    XmlElement x1 = dom.CreateElement("user");
                    XmlElement x11 = dom.CreateElement("name");
                    x11.InnerText = elem.Name;
                    x1.AppendChild(x11);
                    XmlElement x12 = dom.CreateElement("highscore");
                    x12.InnerText = elem.Score.ToString();
                    x1.AppendChild(x12);
                    x.AppendChild(x1);
                }

                await dom.SaveToFileAsync(st);

                Frame.Navigate(typeof(MainPage));
            }
            else
            {
                var param = new Parameters();
                param.Score = this.score + 10 + this.levelCount;
                param.Name = this.playerName;
                param.Level = this.levelCount + 1;
                param.Counter = this.futureCounter;
                Frame.Navigate(typeof(Level), param);
            }
        }
예제 #28
0
        //private void Button_Holding(object sender, HoldingRoutedEventArgs e)
        //{
          
        //    Button btn  = (Button) sender;
        //    TextBlock tb = new TextBlock();
        //    tb.Text ="删除";
        //    Flyout flyout = new Flyout();
        //    flyout.Content = tb;
        //    flyout.ShowAt(btn);
        //}

        async private void DeleteAppBarButton_Click(object sender, RoutedEventArgs e)
        {
            foreach (Citys city2 in Files.SelectedItems)
            {
                cityName.Remove(city2);
            }
            //获取记事本的文件夹对象NoteList
            StorageFolder storage1 = await ApplicationData.Current.LocalFolder.CreateFolderAsync("CityList",CreationCollisionOption.ReplaceExisting);

            foreach (Citys city3 in cityName)
            {
                //创建一个XML对象
                XmlDocument _doc = new XmlDocument();
                //使用记事本名字创建一个XML元素作为根节点
                XmlElement _item = _doc.CreateElement(city3.city.ToString ());

                //使用属性来作为信息的标识符,使用属性值来存储相关的信息
                //_item.SetAttribute("city", t.Text );
                _doc.AppendChild(_item);
                //创建一个应用文件
                StorageFile file = await storage1.CreateFileAsync(city3.city.ToString() + ".xml", CreationCollisionOption.ReplaceExisting);
                //把XML的信息保存到文件中去
                await _doc.SaveToFileAsync(file);
            }
            (Window.Current.Content as Frame).Navigate(typeof(CollectionCity));
        }
예제 #29
0
#pragma warning disable 1998
        public override async Task ShowNotification(string notification, NotificationType notificationType)
#pragma warning restore 1998
        {
            var notifier = ToastNotificationManager.CreateToastNotifier();
            if (notifier.Setting == NotificationSetting.Enabled && Service.Current != null)
            {
                var toastXml = new XmlDocument();

                var toast = toastXml.CreateElement("toast");
                toastXml.AppendChild(toast);

                var visual = toastXml.CreateElement("visual");
                visual.SetAttribute("version", "1");
                visual.SetAttribute("lang", "en-US");
                toast.AppendChild(visual);

                var binding = toastXml.CreateElement("binding");
                binding.SetAttribute("template", "ToastImageAndText02");
                visual.AppendChild(binding);

                var image = toastXml.CreateElement("image");
                image.SetAttribute("id", "1");
                image.SetAttribute("src", @"Assets/Notification" + Service.Current.Messages[notificationType.ToString()] + ".png");
                binding.AppendChild(image);

                var notificationTypeText = toastXml.CreateElement("text");
                notificationTypeText.SetAttribute("id", "1");
                notificationTypeText.InnerText = notificationType.ToString();
                binding.AppendChild(notificationTypeText);

                var notificationText = toastXml.CreateElement("text");
                notificationText.SetAttribute("id", "2");
                notificationText.InnerText = notification;
                binding.AppendChild(notificationText);

                var toastNotification = new ToastNotification(toastXml);
                toastNotification.Activated += (sender, args) => ShowNotificationAsDialog(notification, notificationType);
                notifier.Show(toastNotification);
            }
            else
                ShowNotificationAsDialog(notification, notificationType);
        }