Exemplo n.º 1
0
 private void processWptElement(ref Waypoint pt, XmlReader reader)
 {
     if (pt is Geocache)
     {
         parseGeocacheElement(ref pt, reader);
     }
     else if (reader.LocalName == "name")
     {
         pt.Name = reader.ReadString();
         this.ParseWaypoint(this, new ParseEventArgs(String.Format("Processing Waypoint {0}", pt.Name)));
         pt.Parent = "GC" + pt.Name.Substring(2);
     }
     else if (reader.LocalName == "url")
     {
         String url = reader.ReadString().Trim();
         if (!String.IsNullOrEmpty(url))
         {
             pt.URL = new Uri(url);
         }
     }
     else if (String.Equals(reader.LocalName, "parent", StringComparison.InvariantCultureIgnoreCase))
     {
         pt.Parent = reader.ReadString();
     }
     else if (reader.LocalName == "desc")
     {
         pt.Desc = reader.ReadElementContentAsString();
     }
     else if (reader.LocalName == "time")
     {
         string strVal = reader.ReadString();
         pt.Time = DateTime.Parse(strVal);
     }
     else if (reader.LocalName == "link")
     {
         pt.URL     = new Uri(reader.GetAttribute("href"));
         pt.URLName = pt.Name;
     }
     else if (reader.LocalName == "urlname")
     {
         pt.URLName = reader.ReadString();
     }
     else if (reader.LocalName == "sym")
     {
         pt.Symbol = reader.ReadString();
     }
     else if (reader.LocalName == "type")
     {
         pt.Type = reader.ReadString();
         if (pt.Type.StartsWith("Geocache") || pt.Type.StartsWith("TerraCache"))
         {
             pt = Geocache.convertFromWaypoint(pt);
         }
         else if (pt.Symbol == "Waymark")
         {
             // TEMP: For now, convert Waymark into a virtual cache
             pt = Geocache.convertFromWaypoint(pt);
             Geocache cache = pt as Geocache;
             cache.ShortDesc = pt.Type + "\n\n";
             cache.CacheName = pt.Type + ":  " + pt.URLName;
             // Need to give it a unique ID for Oregon/Colorado.
             Random rand = new Random();
             cache.CacheID     = rand.Next(50000000).ToString();
             cache.TypeOfCache = Geocache.CacheType.VIRTUAL;
             cache.Type        = "Geocache";
             cache.LongDesc    = cache.Desc;
             cache.Container   = "Virtual";
             cache.Difficulty  = 1.0f;
             cache.Terrain     = 1.0f;
             pt.Desc           = cache.CacheName;
             pt.Symbol         = "Geocache";
             pt.Type           = "Geocache|Virtual Cache";
             cache.PlacedBy    = "Unknown";
         }
     }
 }
Exemplo n.º 2
0
 public void processLocWpt(ref Waypoint pt, XmlReader reader)
 {
     if (reader.Name == "name")
     {
         pt.Name = reader.GetAttribute("id");
         pt.Desc = reader.ReadElementContentAsString().Trim();
         this.ParseWaypoint(this, new ParseEventArgs(String.Format("Processing Waypoint {0}", pt.Name)));
     }
     else if (reader.Name == "coord")
     {
         pt.Lat = double.Parse(reader.GetAttribute("lat"), CultureInfo.InvariantCulture);
         pt.Lon = double.Parse(reader.GetAttribute("lon"), CultureInfo.InvariantCulture);
     }
     else if (reader.Name == "terrain")
     {
         (pt as Geocache).Terrain = float.Parse(reader.ReadString());
     }
     else if (reader.Name == "difficulty")
     {
         (pt as Geocache).Difficulty = float.Parse(reader.ReadString());
     }
     else if (reader.Name == "container")
     {
         string val = reader.ReadString().Trim();
         if (val == "2")
         {
             (pt as Geocache).Container = "Micro";
         }
         else if (val == "8")
         {
             (pt as Geocache).Container = "Small";
         }
         else if (val == "3")
         {
             (pt as Geocache).Container = "Regular";
         }
         else if (val == "4")
         {
             (pt as Geocache).Container = "Large";
         }
         else if (val == "5")
         {
             (pt as Geocache).Container = "Virtual";
         }
         else
         {
             (pt as Geocache).Container = "Not Chosen";
         }
     }
     else if (reader.Name == "type")
     {
         pt.Symbol = reader.ReadElementContentAsString();
         pt.Type   = pt.Symbol;
         if (pt.Type == "Geocache")
         {
             if (pt.URL == null)
             {
                 pt.URL = new Uri("http://geocaching.com");
             }
             pt = Geocache.convertFromWaypoint(pt);
             if (m_source == "NaviCache")
             {
                 ParseNaviCache(pt);
             }
         }
     }
     else if (reader.Name == "link")
     {
         pt.URLName = reader.GetAttribute("text");
         pt.URL     = new Uri(reader.ReadElementContentAsString());
         ((Geocache)pt).LongDesc = "<a href=\"" + pt.URL.ToString() + "\">View Online</a>";
     }
 }