CreateAttribute() public method

public CreateAttribute ( [ name ) : XmlAttribute
name [
return XmlAttribute
Exemplo n.º 1
0
        private static void SetSilent(bool useSound, XmlDocument toastXml)
        {
            var audio = toastXml.GetElementsByTagName("audio").FirstOrDefault();

            if (audio == null)
            {
                audio = toastXml.CreateElement("audio");
                var toastNode = ((XmlElement)toastXml.SelectSingleNode("/toast"));

                if (toastNode != null)
                {
                    toastNode.AppendChild(audio);
                }
            }

            var attribute = toastXml.CreateAttribute("silent");
            attribute.Value = (!useSound).ToString().ToLower();
            audio.Attributes.SetNamedItem(attribute);
        }
Exemplo n.º 2
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();
            }
        }