Example #1
0
        public static Geocache convertFromWaypoint(Waypoint original)
        {
            Geocache cache = new Geocache();

            cache.Name        = original.Name;
            cache.Time        = original.Time;
            cache.Lat         = original.Lat;
            cache.Lon         = original.Lon;
            cache.Desc        = original.Desc;
            cache.Symbol      = original.Symbol;
            cache.URL         = original.URL;
            cache.URLName     = original.URLName;
            cache.Type        = original.Type;
            cache.Updated     = original.Updated;
            cache.CacheName   = original.Desc;
            cache.Available   = true;
            cache.Archived    = false;
            cache.TypeOfCache = Geocache.CacheType.GENERIC;
            cache.ShortDesc   = "";
            if (cache.URL != null)
            {
                cache.LongDesc = "<a href=\"" + cache.URL.ToString() + "\">View Online</a>";
            }
            return(cache);
        }
Example #2
0
 protected void FireReadEvent(Geocache cache)
 {
     if (this.ReadCache != null)
     {
         this.ReadCache(this, new ReadCacheArgs(cache));
     }
 }
Example #3
0
        private void ParseTerraLog(ref Geocache cache, XmlReader reader, ref bool logsChecked)
        {
            CacheLog log       = new CacheLog();
            bool     breakLoop = false;

            log.LogID  = reader.GetAttribute("id");
            log.LogKey = cache.Name + log.LogID;
            while (!breakLoop && reader.Read())
            {
                if (reader.LocalName == "date")
                {
                    log.LogDate = reader.ReadElementContentAsDateTime();
                }
                else if (reader.LocalName == "type")
                {
                    log.LogStatus = reader.ReadElementContentAsString();
                }
                else if (reader.LocalName == "user")
                {
                    log.FinderID = reader.GetAttribute("id");
                    log.LoggedBy = reader.ReadElementContentAsString();
                    if (m_ownid.Contains(log.FinderID) && log.LogStatus == "find")
                    {
                        cache.Symbol = "Geocache Found";
                    }
                    else if (m_ownid.Contains(log.LoggedBy) && log.LogStatus == "find")
                    {
                        cache.Symbol = "Geocache Found";
                    }
                }
                else if (reader.LocalName == "entry")
                {
                    log.Encoded    = false;
                    log.LogMessage = reader.ReadElementContentAsString();
                    log.LogMessage = log.LogMessage.Replace("&gt;", ">");
                    log.LogMessage = log.LogMessage.Replace("&lt;", "<");
                    log.LogMessage = log.LogMessage.Replace("&amp;", "&");
                }
                else if (reader.LocalName == "log")
                {
                    breakLoop = true;
                }
            }
            if (!logsChecked)
            {
                if (log.LogStatus == "Didn't find it" || log.LogStatus == "Needs Maintenance" || log.LogStatus == "no_find")
                {
                    cache.CheckNotes = true;
                    logsChecked      = true;
                }
                else if (log.LogStatus != "Write Note" && log.LogStatus != "Note")
                {
                    cache.CheckNotes = false;
                    logsChecked      = true;
                }
            }
            m_store.AddLog(cache.Name, log);
        }
Example #4
0
 public override bool Equals(object obj)
 {
     if (obj is Geocache)
     {
         Geocache target = obj as Geocache;
         return(target.Name == this.Name);
     }
     return(false);
 }
 public void LogCache(Geocache cache)
 {
     if (cache.URL.ToString().Contains("opencaching"))
         cacheLog.LoadUri(cache.URL.ToString().Replace("viewcache.php", "log.php"));
     else if (cache.URL.ToString().Contains("geocaching"))
         cacheLog.LoadUri("http://www.geocaching.com/seek/log.aspx?ID=" + cache.CacheID);
     else
         cacheLog.LoadUri(cache.URL.ToString());
     this.Maximize();
 }
Example #6
0
        private void ParseNaviCache(Waypoint pt)
        {
            Geocache cache = pt as Geocache;

            cache.Symbol = "NaviCache";
            String[] lines = pt.Desc.Split('\n');
            for (int i = 0; i < lines.Length; i++)
            {
                if (i == 0)
                {
                    cache.CacheName = lines[0];
                }
                else if (i == 1)
                {
                    continue;
                }
                else
                {
                    String[] details = lines[i].Split(':');
                    String   detail  = details[1].Trim();
                    if (i == 2)
                    {
                        ParseCacheType(detail, ref cache);
                    }
                    else if (i == 3)
                    {
                        if (detail == "Normal")
                        {
                            cache.Container = "Regular";
                        }
                        else if (detail == "Virtual" || detail == "Unknown")
                        {
                            cache.Container = "Not chosen";
                        }
                        else
                        {
                            cache.Container = detail;
                        }
                    }
                    else if (i == 4)
                    {
                        cache.Difficulty = float.Parse(detail, CultureInfo.InvariantCulture);
                    }
                    else if (i == 5)
                    {
                        cache.Terrain = float.Parse(detail, CultureInfo.InvariantCulture);
                    }
                }
            }
            cache.Desc = cache.CacheName + " (" + cache.Difficulty + "/" + cache.Terrain + ")";
        }
Example #7
0
 private void ParseTravelBugs(ref Geocache cache, XmlReader reader)
 {
     while (reader.Read())
     {
         if (reader.LocalName == "travelbug")
         {
             parseTravelBug(ref cache, reader);
         }
         if (reader.LocalName == "travelbugs")
         {
             return;
         }
     }
 }
Example #8
0
        private void ParseCacheLogs(ref Geocache cache, XmlReader reader)
        {
            bool logsChecked = false;

            while (reader.Read())
            {
                if (reader.LocalName == "log")
                {
                    ParseCacheLog(ref cache, reader, ref logsChecked);
                }
                if (reader.LocalName == "logs")
                {
                    return;
                }
            }
        }
 public void SetCache(Geocache cache)
 {
     this.geocache = cache;
     if (cache == null)
     {
         descWidget.HTML = Catalog.GetString("<b>NO CACHE SELECTED</b>");
         return;
     }
     SetDescription (cache);
     SetTravelBugs(m_App.CacheStore.GetTravelBugs(cache.Name));
     if (String.IsNullOrEmpty (cache.Hint) || String.IsNullOrEmpty(cache.Hint.Trim())) {
         hintButton.Sensitive = false;
     } else {
         hintWidget.HTML = "<div style='font-family:sans-serif;font-size:10pt; background-color:#FFFFFF'>" + cache.Hint  + "</div>";
         hintButton.Sensitive = true;
     }
 }
Example #10
0
 private void parseCacheAttrs(ref Geocache cache, XmlReader reader)
 {
     if (reader.IsEmptyElement)
     {
         return;
     }
     while (reader.Read())
     {
         if (reader.LocalName == "attribute")
         {
             parseCacheAttribute(ref cache, reader);
         }
         if (reader.LocalName == "attributes")
         {
             return;
         }
     }
 }
Example #11
0
        private void parseGeocacheElement(ref Waypoint pt, XmlReader reader)
        {
            Geocache cache = pt as Geocache;

            if (m_source == "opencaching")
            {
                cache = ParseOpenCache(reader, ref cache);
            }
            else if (reader.NamespaceURI.StartsWith("http://www.groundspeak.com/cache") ||
                     reader.NamespaceURI.StartsWith("http://www.gsak.net/xmlv1/5"))
            {
                cache = ParseGroundSpeakCache(reader, ref cache);
            }
            else if (reader.NamespaceURI.StartsWith("http://www.TerraCaching.com"))
            {
                cache = ParseTerraCache(reader, ref cache);
            }
        }
 public void setCacheIcon(Geocache.CacheType type)
 {
     switch (type) {
         case Geocache.CacheType.TRADITIONAL:
             cacheIcon.Pixbuf = TRADICON;
             break;
         case Geocache.CacheType.MYSTERY:
             cacheIcon.Pixbuf = MYSTERYICON;
             break;
         case Geocache.CacheType.MULTI:
             cacheIcon.Pixbuf = MULTIICON;
             break;
         case Geocache.CacheType.LETTERBOX:
             cacheIcon.Pixbuf = LETTERICON;
             break;
         case Geocache.CacheType.EARTH:
             cacheIcon.Pixbuf = EARTHICON;
             break;
         case Geocache.CacheType.CITO:
             cacheIcon.Pixbuf = CITOICON;
             break;
         case Geocache.CacheType.EVENT:
             cacheIcon.Pixbuf = EVENT;
             break;
         case Geocache.CacheType.MEGAEVENT:
             cacheIcon.Pixbuf = MEGAEVENT;
             break;
         case Geocache.CacheType.VIRTUAL:
             cacheIcon.Pixbuf = VIRTUAL;
             break;
         case Geocache.CacheType.WEBCAM:
             cacheIcon.Pixbuf = WEBCAM;
             break;
         case Geocache.CacheType.WHERIGO:
             cacheIcon.Pixbuf = WHERIGO;
             break;
         case Geocache.CacheType.GENERIC:
             cacheIcon.Pixbuf = GENERIC;
             break;
         default:
             cacheIcon.Pixbuf = OTHERICON;
             break;
     }
 }
Example #13
0
        private void parseCacheAttribute(ref Geocache cache, XmlReader reader)
        {
            CacheAttribute attr = new CacheAttribute();

            attr.ID = reader.GetAttribute("id");
            string inc = reader.GetAttribute("inc");

            if (inc == "1")
            {
                attr.Include = true;
            }
            else
            {
                attr.Include = false;
            }
            attr.AttrValue = reader.ReadElementContentAsString();
            m_store.AddAttribute(cache.Name, attr);
            return;
        }
 public void SetCache(Geocache cache)
 {
     descriptionPane.SetCache(cache);
     cacheNotes.SetCache(cache);
     imageWidget.SetCache(cache);
     if (cache == null)
         logViewer.SetCacheLogs(null);
     else
         logViewer.SetCacheLogs(m_App.CacheStore.GetCacheLogs(cache.Name));
     if (cache == null)
         waypointWidget.SetCacheAndPoints(null, null);
     else
         waypointWidget.SetCacheAndPoints(cache, m_App.CacheStore.GetChildWaypoints(new string[]{cache.Name}));
     quickInfoPane.SetCache(cache);
     if (imageWidget.HasImages)
         imageLabel.Markup = "<b>" + Catalog.GetString("Images") + "</b>";
     else
         imageLabel.Text = Catalog.GetString("Images");
 }
Example #15
0
        private void parseTravelBug(ref Geocache cache, XmlReader reader)
        {
            TravelBug bug = new TravelBug();

            bug.ID  = reader.GetAttribute("id");
            bug.Ref = reader.GetAttribute("ref");
            while (reader.Read())
            {
                if (reader.LocalName == "travelbug")
                {
                    m_store.AddTravelBug(cache.Name, bug);
                    return;
                }
                if (reader.LocalName == "name")
                {
                    bug.Name = reader.ReadElementContentAsString();
                }
            }
        }
 public void SetCache(Geocache cache, bool isDirect)
 {
     m_cache = cache;
     if (isDirect)
         coordEntry.SetDirectMode();
     SetActual(cache.OrigLat, cache.OrigLon);
     if (cache.HasCorrected)
     {
         coordEntry.Latitude = cache.CorrectedLat;
         coordEntry.Longitude = cache.CorrectedLon;
         resetButton.Sensitive = true;
     }
     else
     {
         coordEntry.Latitude = cache.Lat;
         coordEntry.Longitude = cache.Lon;
     }
     m_IsCorrected = cache.HasCorrected;
     coordEntry.Changed += HandleCoordEntryChanged;
 }
Example #17
0
        public void WriteToGPX(XmlWriter writer, GPXWriter gpx)
        {
            writer.WriteStartElement("wpt", GPXWriter.NS_GPX);
            WriteWPTDetails(writer, gpx);
            writer.WriteEndElement();
            if (!gpx.IncludeChildWaypoints)
            {
                return;
            }

            if ((this is Geocache) && ((this as Geocache).HasCorrected))
            {
                Geocache cache = this as Geocache;
                Waypoint orig  = new Waypoint();
                orig.Name   = cache.Name + "-ORIG";
                orig.Lat    = cache.OrigLat;
                orig.Lon    = cache.OrigLon;
                orig.Symbol = "Reference Point";
                orig.Type   = "Waypoint|Reference Point";
                orig.Desc   = Catalog.GetString("Original Location") + " - " + cache.CacheName;
                orig.WriteToGPX(writer, gpx);
            }
        }
Example #18
0
 public void SetCache(Geocache cache)
 {
     if (saveButton.Sensitive == true)
     {
         MessageDialog dlg = new MessageDialog(null, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo, Catalog.GetString("You have unsaved notes, do you wish to save them?"));
         if ((int)ResponseType.Yes ==  dlg.Run())
         {
             SaveNotes();
         }
         dlg.Hide();
     }
     current = cache;
     if (cache != null)
     {
         editorWidget.Text = cache.Notes;
         editorWidget.Sensitive = true;
     }
     else
     {
         editorWidget.Sensitive = false;
         editorWidget.Text = String.Empty;
     }
     saveButton.Sensitive = false;
 }
        public void ProcessOfflineLog(Geocache cache, CacheLog log, bool ftf)
        {
            FieldNotesHandler.WriteToFile (log, Config.FieldNotesFile);

            if (cache == null)
                return;
            m_app.CacheStore.AddLog (log.CacheCode, log);
            if (log.LogStatus == "Found it") {
                cache.DNF = false;
                cache.FTF = ftf;
                cache.Symbol = "Geocache Found";
                m_app.CacheStore.AddWaypointOrCache (cache, false, false);
            } else if (log.LogStatus == "Didn't find it") {
                cache.DNF = true;
                cache.FTF = false;
                cache.Symbol = "Geocache";
                m_app.CacheStore.AddWaypointOrCache (cache, false, false);
            } else if (log.LogStatus == "Needs Maintenance") {
                cache.CheckNotes = true;
            }
        }
 public void setCacheIcon(Geocache.CacheType type)
 {
     Pixbuf icon = IconManager.GetLargeCacheIcon(type);
     cacheIcon.Pixbuf = icon;
 }
 private void setCacheType(Geocache.CacheType ctype)
 {
     switch (ctype) {
     case Geocache.CacheType.APE:
         cacheTypeLabel.Text = Catalog.GetString ("Project A.P.E");
         break;
     case Geocache.CacheType.CITO:
         cacheTypeLabel.Text = Catalog.GetString ("Cache In Trash Out Event");
         break;
     case Geocache.CacheType.EARTH:
         cacheTypeLabel.Text = Catalog.GetString ("Earth Cache");
         break;
     case Geocache.CacheType.EVENT:
         cacheTypeLabel.Text = Catalog.GetString ("Event Cache");
         break;
     case Geocache.CacheType.LETTERBOX:
         cacheTypeLabel.Text = Catalog.GetString ("Letterbox Hybrid");
         break;
     case Geocache.CacheType.MAZE:
         cacheTypeLabel.Text = Catalog.GetString ("Geo Adventures Maze");
         break;
     case Geocache.CacheType.MEGAEVENT:
         cacheTypeLabel.Text = Catalog.GetString ("Mega Event");
         break;
     case Geocache.CacheType.MULTI:
         cacheTypeLabel.Text = Catalog.GetString ("Multi Cache");
         break;
     case Geocache.CacheType.MYSTERY:
         cacheTypeLabel.Text = Catalog.GetString ("Unknown Cache");
         break;
     case Geocache.CacheType.OTHER:
         cacheTypeLabel.Text = Catalog.GetString ("Undefined Cache Type");
         break;
     case Geocache.CacheType.REVERSE:
         cacheTypeLabel.Text = Catalog.GetString ("Locationless Cache");
         break;
     case Geocache.CacheType.TRADITIONAL:
         cacheTypeLabel.Text = Catalog.GetString ("Traditional Cache");
         break;
     case Geocache.CacheType.VIRTUAL:
         cacheTypeLabel.Text = Catalog.GetString ("Virtual Cache");
         break;
     case Geocache.CacheType.WEBCAM:
         cacheTypeLabel.Text = Catalog.GetString ("Webcam Cache");
         break;
     case Geocache.CacheType.WHERIGO:
         cacheTypeLabel.Text = Catalog.GetString ("Wherigo Cache");
         break;
     case Geocache.CacheType.GENERIC:
         cacheTypeLabel.Text = Catalog.GetString ("Geocache");
         break;
     default:
         cacheTypeLabel.Text = "NOT_DEFINED";
         break;
     }
 }
 public ReadCacheArgs(Geocache message)
     : base()
 {
     m_cache = message;
 }
 private void SetUserDataFields(Geocache cache)
 {
     if (!String.IsNullOrEmpty (cache.User1))
         uData1.Text = cache.User1;
     else
         uData1.Text = Catalog.GetString ("None");
     if (!String.IsNullOrEmpty (cache.User2))
         uData2.Text = cache.User2;
     else
         uData2.Text = Catalog.GetString ("None");
     if (!String.IsNullOrEmpty (cache.User3))
         uData3.Text = cache.User3;
     else
         uData3.Text = Catalog.GetString ("None");
     if (!String.IsNullOrEmpty (cache.User4))
         uData4.Text = cache.User4;
     else
         uData4.Text = Catalog.GetString ("None");
 }
Example #24
0
 public static string GetStatusIcon(Geocache cache, OCMApp app, bool ignoreFound)
 {
     if (cache.Found && !ignoreFound)
     {
         if (cache.FTF)
             return FTF_MI;
         return FOUND_MI;
     }
     if ((app.OwnerIDs.Contains(cache.OwnerID)) ||(app.OwnerIDs.Contains(cache.CacheOwner)))
         return OWNED_MI;
     if ((cache.HasCorrected || cache.HasFinal))
     {
         if (app.AppConfig.SolvedModeState == SolvedMode.ALL)
             return CORRECTED_MI;
         else if (app.AppConfig.SolvedModeState == SolvedMode.PUZZLES &&
                  cache.TypeOfCache == Geocache.CacheType.MYSTERY)
             return CORRECTED_MI;
     }
     else if (cache.DNF && app.AppConfig.ShowDNFIcon)
     {
         return DNF_MI;
     }
     return null;
 }
Example #25
0
 private Geocache ParseOpenCache(XmlReader reader, ref Geocache cache)
 {
     if (reader.LocalName == "cache" || reader.LocalName == "geocache")
     {
         string avail = reader.GetAttribute("available");
         string arch  = reader.GetAttribute("archived");
         if (!String.IsNullOrEmpty(avail))
         {
             cache.Available = Boolean.Parse(avail);
         }
         else
         {
             cache.Available = true;
         }
         if (!String.IsNullOrEmpty(arch))
         {
             cache.Archived = Boolean.Parse(arch);
         }
         else
         {
             cache.Archived = false;
         }
         cache.CacheID = reader.GetAttribute("id");
     }
     else if (reader.LocalName == "name")
     {
         cache.CacheName = reader.ReadElementContentAsString();
     }
     else if (reader.LocalName == "owner")
     {
         cache.OwnerID    = reader.GetAttribute("id");
         cache.CacheOwner = reader.ReadElementContentAsString();
         cache.PlacedBy   = cache.CacheOwner;
     }
     else if (reader.LocalName == "type")
     {
         ParseCacheType(reader.ReadElementContentAsString(), ref cache);
     }
     else if (reader.LocalName == "difficulty")
     {
         string diff = reader.ReadElementContentAsString();
         cache.Difficulty = float.Parse(diff, CultureInfo.InvariantCulture);
     }
     else if (reader.LocalName == "terrain")
     {
         string terr = reader.ReadElementContentAsString();
         cache.Terrain = float.Parse(terr, CultureInfo.InvariantCulture);
     }
     else if (reader.LocalName == "short_description" || reader.LocalName == "summary")
     {
         string html = reader.GetAttribute("html");
         string val  = reader.ReadElementContentAsString();
         if (html.Equals("False", StringComparison.InvariantCultureIgnoreCase))
         {
             val = val.Replace("\n", "<br/>");
         }
         cache.ShortDesc = val;
     }
     else if (reader.LocalName == "long_description" || reader.LocalName == "description")
     {
         string html = reader.GetAttribute("html");
         string val  = reader.ReadElementContentAsString();
         if (html.Equals("False", StringComparison.InvariantCultureIgnoreCase))
         {
             val = val.Replace("\n", "<br/>");
         }
         cache.LongDesc = val;
     }
     else if (reader.LocalName == "encoded_hints" || reader.LocalName == "hints")
     {
         cache.Hint = reader.ReadElementContentAsString();
     }
     else if (reader.LocalName == "container")
     {
         cache.Container = reader.ReadElementContentAsString();
     }
     else if (reader.LocalName == "logs" && !reader.IsEmptyElement)
     {
         ParseCacheLogs(ref cache, reader);
     }
     else if (reader.LocalName == "travelbugs" && !reader.IsEmptyElement)
     {
         ParseTravelBugs(ref cache, reader);
     }
     else if (reader.LocalName == "country")
     {
         cache.Country = reader.ReadElementContentAsString();
     }
     else if (reader.LocalName == "state")
     {
         cache.State = reader.ReadElementContentAsString();
     }
     else if (reader.LocalName == "attributes")
     {
         parseCacheAttrs(ref cache, reader);
     }
     return(cache);
 }
 public void SetDescription(Geocache cache)
 {
     String baseURL = cache.URL.Scheme + "://" + cache.URL.Host;
     descWidget.SetHTML("<div style='font-family:sans-serif;font-size:10pt; background-color:#FFFFFF'>" + cache.ShortDesc + "\n\n"
         + cache.LongDesc + "</div>", baseURL);
 }
        private void ScanForImages(Dictionary<string, string[]> files, Geocache cache)
        {
            string baseURL = String.Empty;
            if (cache.URL != null)
                baseURL = cache.URL.Scheme + "://" + cache.URL.Host;
            const string IMG = "(<[Ii][Mm][Gg])([^sS][^rR]*)([Ss][Rr][Cc]\\s?=\\s?)\"([^\"]*)\"([^>]*>)";
            MatchCollection matches = Regex.Matches(cache.LongDesc, IMG);
            if (matches.Count == 0)
                return;

            string imagesFolder = GetImagesFolder(cache);
            if (!Directory.Exists(imagesFolder))
                Directory.CreateDirectory(imagesFolder);

            foreach(Match match in matches)
            {
                string url = match.Groups[4].Value;
                if (!url.Contains("://"))
                {
                    if (url.StartsWith("/"))
                        url = baseURL + url;
                    else
                        url = baseURL + "/" + url;
                }
                string key = cache.Name + url;
                if (!files.ContainsKey(key))
                    files.Add(key, new string[]{url, imagesFolder});
            }
            return;
        }
 void HandleEditorWidgetTextChanged(object sender, EventArgs args)
 {
     saveButton.Sensitive = true;
     current = UIMonitor.getInstance().SelectedCache;
 }
Example #29
0
        internal virtual void WriteWPTDetails(XmlWriter writer, GPXWriter gpx)
        {
            Geocache cache = null;

            if (this is Geocache)
            {
                cache = this as Geocache;
            }

            writer.WriteAttributeString("lat", this.Lat.ToString(CultureInfo.InvariantCulture));
            writer.WriteAttributeString("lon", this.Lon.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("time", this.Time.ToString("o"));
            if (cache != null && gpx.NameMode == WaypointNameMode.NAME)
            {
                writer.WriteElementString("name", cache.CacheName);
            }
            else if (cache != null && gpx.NameMode == WaypointNameMode.SHORTCODE)
            {
                writer.WriteElementString("name", this.Name.Substring(2));
            }
            else
            {
                writer.WriteElementString("name", this.Name);
            }
            if (cache != null && gpx.DescriptionMode == WaypointDescMode.CODESIZEANDHINT)
            {
                if (!String.IsNullOrEmpty(cache.Container))
                {
                    writer.WriteElementString("desc", cache.Name + "/" + cache.Container.Substring(0, 3) + "/" + cache.Hint);
                }
                else
                {
                    writer.WriteElementString("desc", cache.Name);
                }
            }
            else if (cache != null && gpx.DescriptionMode == WaypointDescMode.CODESIZETYPE)
            {
                if (!String.IsNullOrEmpty(cache.Container))
                {
                    writer.WriteElementString("desc", cache.Name + "/" + cache.Container.Substring(0, 3) + "/" + cache.TypeOfCache.ToString());
                }
                else
                {
                    writer.WriteElementString("desc", cache.Name + "/" + cache.TypeOfCache.ToString());
                }
            }
            else if (cache != null && gpx.DescriptionMode == WaypointDescMode.FULL)
            {
                StringBuilder builder = new StringBuilder();
                builder.Append("<br/><br/>" + cache.ShortDesc);
                builder.Append("<br/>" + cache.LongDesc);
                if (!String.IsNullOrEmpty(cache.Hint))
                {
                    builder.Append("<br/><br/>Hint: " + cache.Hint);
                }
                builder.Append("<br/><br/>Logs:<br/>");
                List <CacheLog> logs   = gpx.GetCacheLogs(cache.Name);
                int             iCount = 0;
                foreach (CacheLog log in logs)
                {
                    if (iCount >= gpx.LogLimit && gpx.LogLimit >= 0)
                    {
                        break;
                    }
                    builder.Append(log.toHTML());
                    iCount++;
                }

                writer.WriteStartElement("desc");
                if (gpx.HTMLOutput == HTMLMode.GARMIN)
                {
                    writer.WriteCData(Utilities.HTMLtoGarmin(builder.ToString()));
                }
                else if (gpx.HTMLOutput == HTMLMode.PLAINTEXT)
                {
                    writer.WriteCData(Utilities.HTMLtoText(builder.ToString()));
                }
                else
                {
                    writer.WriteCData(builder.ToString());
                }

                writer.WriteEndElement();
            }
            else
            {
                writer.WriteElementString("desc", this.Desc);
                writer.WriteElementString("cmt", this.Desc);
            }
            if (this.URL != null)
            {
                writer.WriteElementString("url", this.URL.ToString());
            }
            if (!String.IsNullOrEmpty(this.URLName))
            {
                writer.WriteElementString("urlname", this.URLName);
            }
            if (gpx.DescriptionMode == WaypointDescMode.FULL)
            {
                writer.WriteElementString("sym", "Information");
            }
            else if (!gpx.UseOCMPtTypes)
            {
                writer.WriteElementString("sym", this.Symbol);
            }
            else
            {
                System.Console.WriteLine(this.Name);
                if (cache != null && cache.Symbol == "Geocache Found")
                {
                    writer.WriteElementString("sym", gpx.Mappings[this.Symbol]);
                }
                else if (cache != null && cache.TypeOfCache != Geocache.CacheType.GENERIC)
                {
                    string key = "Geocache|" + Geocache.GetCTypeString(cache.TypeOfCache);
                    writer.WriteElementString("sym", gpx.Mappings[key]);
                }
                else if (gpx.Mappings.ContainsKey(this.Type))
                {
                    writer.WriteElementString("sym", gpx.Mappings[this.Type]);
                }
                else
                {
                    writer.WriteElementString("sym", this.Symbol);
                }
            }
            writer.WriteElementString("type", this.Type);
            if (this.Parent != null)
            {
                writer.WriteElementString("parent", "http://opencachemanage.sourceforge.net/schema1", this.Parent);
            }
            if (cache != null && gpx.DescriptionMode == WaypointDescMode.FULL)
            {
                writer.WriteStartElement("extensions");
                writer.WriteStartElement("gpxx", "WaypointExtension", "http://www.garmin.com/xmlschemas/GpxExtensions/v3");
                writer.WriteElementString("gpxx:DisplayMode", "SymbolAndName");
                writer.WriteStartElement("gpxx:Address");
                StringBuilder builder = new StringBuilder();
                builder.Append(Geocache.GetCTypeString(cache.TypeOfCache) + "\nBy: " + cache.PlacedBy);
                builder.Append("\n" + cache.Name + ":" + cache.CacheName);
                builder.Append("\n" + Utilities.getCoordString(cache.Lat, cache.Lon));
                builder.Append("\nT:" + cache.Terrain.ToString() + " D:" + cache.Difficulty.ToString() + " S:" + cache.Container);
                writer.WriteElementString("gpxx:PostalCode", builder.ToString());
                writer.WriteEndElement();
                writer.WriteEndElement();
                writer.WriteEndElement();
            }
            else if (gpx.DescriptionMode == WaypointDescMode.FULL)
            {
                writer.WriteStartElement("extensions");
                writer.WriteStartElement("gpxx", "WaypointExtension", "http://www.garmin.com/xmlschemas/GpxExtensions/v3");
                writer.WriteElementString("gpxx:DisplayMode", "SymbolAndName");
                writer.WriteStartElement("gpxx:Address");
                StringBuilder builder = new StringBuilder();
                builder.Append(this.Symbol + " for " + this.Parent);
                builder.Append("\n" + Utilities.getCoordString(this.Lat, this.Lon));
                writer.WriteElementString("gpxx:PostalCode", builder.ToString());
                writer.WriteEndElement();
                writer.WriteEndElement();
                writer.WriteEndElement();
            }
        }
        public void SetCache(Geocache cache)
        {
            m_cache = cache;
            if (cache == null) {
                SetInactive ();
                return;
            }
            this.Sensitive = true;
            cacheCodeLabel.Markup = START_BIG + cache.Name + ": " + END_BIG;
            cacheNameLabel.Markup = START_BIG + GLib.Markup.EscapeText (cache.CacheName) + END_BIG;
            setDifficulty (cache.Difficulty);
            setTerrain (cache.Terrain);
            setCacheIcon (cache.TypeOfCache);
            if ((m_app.AppConfig.ShowNewCaches) && ((DateTime.Now - cache.Time) <= (new TimeSpan(m_app.AppConfig.NewCacheInterval,0,0,0,0))))
            {
                    dateLabel.Markup = "<span background='light green'>" + cache.Time.ToShortDateString () + "</span>";
            }
            else
            {
                dateLabel.Text = cache.Time.ToShortDateString ();
            }

            if (m_app.AppConfig.ShowStaleCaches)
            {
                if ((DateTime.Now - cache.Updated) > (new TimeSpan(m_app.AppConfig.StaleCacheInterval,0,0,0,0)))
                    infoDateLabel.Markup = "<span background='gold'>" + cache.Updated.ToShortDateString () + "</span>";
                else
                    infoDateLabel.Text = cache.Updated.ToShortDateString ();
            }
            else
            {
                infoDateLabel.Text = cache.Updated.ToShortDateString ();
            }
            SetUserDataFields (cache);
            SetLastFoundByYou (cache);
            DateTime lastFound = m_Logs.GetLastFound();
            if (lastFound == DateTime.MinValue)
                lfoundLabel.Text = Catalog.GetString ("Unknown");
            else
                lfoundLabel.Text = lastFound.ToShortDateString ();
            DateTime lastFoundByYou = DateTime.MinValue;
            foreach (string ownerID in m_app.OwnerIDs) {
                lastFoundByYou = m_Logs.GetLastFoundBy(ownerID);
                if (lastFoundByYou != DateTime.MinValue)
                    break;
            }
            DateTime lastDNF = DateTime.MinValue;
            foreach (string ownerID in m_app.OwnerIDs) {
                lastDNF = m_Logs.GetLastDNFBy(ownerID);
                if (lastDNF != DateTime.MinValue)
                    break;
            }
            if (cache.Found && lastFoundByYou == DateTime.MinValue) {
                if (!cache.FTF)
                    statusLabel.Markup = FOUND;
                else
                    statusLabel.Markup = FTF;
            } else if (cache.Found) {
                if (!cache.FTF)
                    statusLabel.Markup = String.Format (FOUND_DATE, lastFoundByYou.ToShortDateString ());
                else
                    statusLabel.Markup = String.Format (FTF_DATE, lastFoundByYou.ToShortDateString ());
            } else if (cache.Archived)
                statusLabel.Markup = ARCHIVED; else if (!cache.Available)
                statusLabel.Markup = UNAVAILABLE; else if (cache.DNF && lastDNF == DateTime.MinValue)
                statusLabel.Markup = DNF; else if (cache.DNF)
                statusLabel.Markup = String.Format (DNF_DATE, lastDNF.ToShortDateString ()); else if (m_app.OwnerIDs.Contains (cache.OwnerID) || m_app.OwnerIDs.Contains (cache.CacheOwner))
                statusLabel.Markup = MINE; else if (cache.CheckNotes)
                statusLabel.Markup = CHECK_LOGS;
            else
                statusLabel.Markup = String.Empty;
            setCacheType (cache.TypeOfCache);
            placedByLabel.Text = cache.PlacedBy;
            cacheSizeLabel.Text = cache.Container;

            if (cache.State.Trim () != String.Empty) {
                countryLabel.Markup = String.Format (Catalog.GetString ("<b>Location: </b> {0},{1}"), cache.State, cache.Country);
            } else if (cache.Country.Trim () != String.Empty) {
                countryLabel.Markup = String.Format (Catalog.GetString ("<b>Location: </b> {0}"), cache.Country);
            } else {
                countryLabel.Text = String.Empty;
            }

            setCoordinate (cache);

            CacheAttribute[] attrs = CacheStore.GetAttributes (cache.Name);
            StringBuilder bldr = new StringBuilder ();
            Gtk.Table.TableChild props;
            foreach (Gtk.Widget child in attrTable.Children) {
                attrTable.Remove (child);
            }
            if (attrs.Length <= 0) {
                bldr.Append (Catalog.GetString ("None"));
                attrTable.Add (attrLabel);
                props = ((Gtk.Table.TableChild)(this.attrTable[attrLabel]));
                props.TopAttach = 0;
                props.LeftAttach = 0;
                props.RightAttach = 1;
                props.BottomAttach = 1;
                attrLabel.Markup = bldr.ToString ();
                attrLabel.Show ();
            } else {
                ShowAttrIcons (attrs, bldr);
            }
        }
 private string GetImagesFolder(Geocache cache)
 {
     string dbName = GetDBName ();
     return m_app.AppConfig.DataDirectory + "/ocm_images/" + dbName + "/" + cache.Name;
 }
Example #32
0
        private Geocache ParseTerraCache(XmlReader reader, ref Geocache cache)
        {
            if (reader.LocalName == "terracache")
            {
                cache.CacheID   = reader.GetAttribute("id");
                cache.Available = true;
                cache.Archived  = false;
            }
            else if (reader.LocalName == "name")
            {
                cache.CacheName = reader.ReadElementContentAsString();
                if (cache.CacheName.ToUpperInvariant().Contains("UNAVAILABLE"))
                {
                    cache.Available = false;
                }
            }
            else if (reader.LocalName == "description")
            {
                cache.LongDesc = reader.ReadElementContentAsString();
            }
            else if (reader.LocalName == "style")
            {
                ParseCacheType(reader.ReadElementContentAsString(), ref cache);
                if ((cache.TypeOfCache == Geocache.CacheType.TRADITIONAL) && cache.Name.StartsWith("LC"))
                {
                    cache.TypeOfCache = Geocache.CacheType.REVERSE;
                }
            }
            else if (reader.LocalName == "owner")
            {
                cache.OwnerID    = reader.GetAttribute("id");
                cache.PlacedBy   = reader.ReadElementContentAsString();
                cache.CacheOwner = cache.PlacedBy;
            }
            else if (reader.LocalName == "hint")
            {
                cache.Hint = reader.ReadElementContentAsString();
                cache.Hint = cache.Hint.Replace("&gt;", ">");
                cache.Hint = cache.Hint.Replace("&lt;", "<");
                cache.Hint = cache.Hint.Replace("&amp;", "&");
            }
            else if (reader.LocalName == "tps_points")
            {
                cache.ShortDesc += "<b>TPS Points: </b>";
                cache.ShortDesc += reader.ReadElementContentAsString();
                cache.ShortDesc += "<br>";
            }
            else if (reader.LocalName == "country")
            {
                cache.Country = reader.ReadElementContentAsString();
            }
            else if (reader.LocalName == "state")
            {
                cache.State = reader.ReadElementContentAsString();
            }
            else if (reader.LocalName == "mce_score")
            {
                cache.ShortDesc += "<b>MCE Score: </b>";
                cache.ShortDesc += reader.ReadElementContentAsString();
                cache.ShortDesc += "<br>";
            }
            else if (reader.LocalName == "physical_challenge")
            {
                cache.ShortDesc += "<b>Physical Challenge: </b>";
                cache.ShortDesc += reader.ReadElementContentAsString();
                cache.ShortDesc += "<br>";
            }
            else if (reader.LocalName == "mental_challenge")
            {
                cache.ShortDesc += "<b>Mental Challenge: </b>";
                cache.ShortDesc += reader.ReadElementContentAsString();
                cache.ShortDesc += "<br>";
            }
            else if (reader.LocalName == "camo_challenge")
            {
                cache.ShortDesc += "<b>Cammo Challenge: </b>";
                cache.ShortDesc += reader.ReadElementContentAsString();
                cache.ShortDesc += "<hr noshade>";
            }
            else if (reader.LocalName == "size")
            {
                string sizeVal = reader.ReadElementContentAsString();
                if (String.IsNullOrEmpty(sizeVal))
                {
                    cache.Container = "Not chosen";
                }
                else
                {
                    int size = int.Parse(sizeVal);
                    switch (size)
                    {
                    case 1:
                        cache.Container = "Large";
                        break;

                    case 2:
                        cache.Container = "Regular";
                        break;

                    case 3:
                        cache.Container = "Small";
                        break;

                    case 4:
                        cache.Container = "Micro";
                        break;

                    case 5:
                        cache.Container = "Micro";
                        break;
                    }
                }
            }
            else if (reader.LocalName == "logs" && !reader.IsEmptyElement)
            {
                ParseTerraLogs(ref cache, reader);
            }
            //TEMP FIX THIS
            cache.Difficulty = 1;
            cache.Terrain    = 1;
            return(cache);
        }
Example #33
0
 public ReadCacheArgs(Geocache message) : base()
 {
     m_cache = message;
 }
Example #34
0
 private Geocache ParseGroundSpeakCache(XmlReader reader, ref Geocache cache)
 {
     if (reader.LocalName == "cache")
     {
         string avail = reader.GetAttribute("available");
         string arch  = reader.GetAttribute("archived");
         if (!String.IsNullOrEmpty(avail))
         {
             cache.Available = Boolean.Parse(avail);
         }
         else
         {
             cache.Available = true;
         }
         if (!String.IsNullOrEmpty(arch))
         {
             cache.Archived = Boolean.Parse(arch);
         }
         else
         {
             cache.Archived = false;
         }
         cache.CacheID = reader.GetAttribute("id");
     }
     else if (reader.LocalName == "DNF" && !m_ignoreExtraFields)
     {
         cache.DNF = reader.ReadElementContentAsBoolean();
     }
     else if (reader.LocalName == "FirstToFind" && !m_ignoreExtraFields)
     {
         cache.FTF = reader.ReadElementContentAsBoolean();
     }
     else if (reader.LocalName == "UserData" && !m_ignoreExtraFields)
     {
         cache.User1 = reader.ReadElementContentAsString();
     }
     else if (reader.LocalName == "User2" && !m_ignoreExtraFields)
     {
         cache.User2 = reader.ReadElementContentAsString();
     }
     else if (reader.LocalName == "User3" && !m_ignoreExtraFields)
     {
         cache.User3 = reader.ReadElementContentAsString();
     }
     else if (reader.LocalName == "User4" && !m_ignoreExtraFields)
     {
         cache.User4 = reader.ReadElementContentAsString();
     }
     else if (reader.LocalName == "LatBeforeCorrect" && !m_ignoreExtraFields)
     {
         double corLat = cache.OrigLat;
         cache.Lat          = reader.ReadElementContentAsDouble();
         cache.CorrectedLat = corLat;
     }
     else if (reader.LocalName == "LonBeforeCorrect" && !m_ignoreExtraFields)
     {
         double corLon = cache.OrigLon;
         cache.Lon          = reader.ReadElementContentAsDouble();
         cache.CorrectedLon = corLon;
     }
     else if (reader.LocalName == "name")
     {
         cache.CacheName = reader.ReadElementContentAsString();
     }
     else if (reader.LocalName == "placed_by")
     {
         cache.PlacedBy = reader.ReadElementContentAsString();
     }
     else if (reader.LocalName == "owner")
     {
         cache.OwnerID    = reader.GetAttribute("id");
         cache.CacheOwner = reader.ReadElementContentAsString();
     }
     else if (reader.LocalName == "type")
     {
         ParseCacheType(reader.ReadElementContentAsString(), ref cache);
     }
     else if (reader.LocalName == "difficulty")
     {
         string diff = reader.ReadElementContentAsString();
         cache.Difficulty = float.Parse(diff, CultureInfo.InvariantCulture);
     }
     else if (reader.LocalName == "terrain")
     {
         string terr = reader.ReadElementContentAsString();
         cache.Terrain = float.Parse(terr, CultureInfo.InvariantCulture);
     }
     else if (reader.LocalName == "short_description")
     {
         string html = reader.GetAttribute("html");
         string val  = reader.ReadElementContentAsString();
         if (html.Equals("False", StringComparison.InvariantCultureIgnoreCase))
         {
             val = val.Replace("\n", "<br/>");
         }
         cache.ShortDesc = val;
     }
     else if (reader.LocalName == "long_description")
     {
         string html = reader.GetAttribute("html");
         string val  = reader.ReadElementContentAsString();
         if (html.Equals("False", StringComparison.InvariantCultureIgnoreCase))
         {
             val = val.Replace("\n", "<br/>");
         }
         cache.LongDesc = val;
     }
     else if (reader.LocalName == "encoded_hints")
     {
         cache.Hint = reader.ReadElementContentAsString();
     }
     else if (reader.LocalName == "container")
     {
         cache.Container = reader.ReadElementContentAsString();
     }
     else if (reader.LocalName == "logs" && !reader.IsEmptyElement)
     {
         ParseCacheLogs(ref cache, reader);
     }
     else if (reader.LocalName == "travelbugs" && !reader.IsEmptyElement)
     {
         ParseTravelBugs(ref cache, reader);
     }
     else if (reader.LocalName == "country")
     {
         cache.Country = reader.ReadElementContentAsString();
     }
     else if (reader.LocalName == "state")
     {
         cache.State = reader.ReadElementContentAsString();
     }
     else if (reader.LocalName == "attributes")
     {
         parseCacheAttrs(ref cache, reader);
     }
     return(cache);
 }
 public CacheEventArgs(Geocache geo)
 {
     Cache = geo;
 }
 /// <summary>
 /// Returns a PixBuf containing the 16x16 icon for the specified cache type
 /// </summary>
 /// <param name="type">
 /// Cache Type <see cref="Geocache.CacheType"/>
 /// </param>
 /// <returns>
 /// A pixbuf containing the icon <see cref="Pixbuf"/>
 /// </returns>
 public static Pixbuf GetSmallCacheIcon(Geocache.CacheType type)
 {
     switch (type) {
     case Geocache.CacheType.FOUND:
         return FOUNDICON_S;
     case Geocache.CacheType.TRADITIONAL:
         return TRADICON_S;
     case Geocache.CacheType.MYSTERY:
         return MYSTERYICON_S;
     case Geocache.CacheType.MULTI:
         return MULTIICON_S;
     case Geocache.CacheType.LETTERBOX:
         return LETTERICON_S;
     case Geocache.CacheType.EARTH:
         return EARTHICON_S;
     case Geocache.CacheType.CITO:
         return CITOICON_S;
     case Geocache.CacheType.VIRTUAL:
         return VIRTUAL_S;
     case Geocache.CacheType.MEGAEVENT:
         return MEGAEVENT_S;
     case Geocache.CacheType.EVENT:
         return EVENT_S;
     case Geocache.CacheType.WEBCAM:
         return WEBCAM_S;
     case Geocache.CacheType.WHERIGO:
         return WHERIGO_S;
     case Geocache.CacheType.MINE:
         return OWNED_S;
     case Geocache.CacheType.GENERIC:
         return GENERIC_S;
     default:
         return OTHERICON_S;
     }
 }
 private void SetLastFoundByYou(Geocache cache)
 {
     DateTime lastDate = DateTime.MinValue;
     foreach (string ownerId in m_app.OwnerIDs) {
         lastDate = m_Logs.GetLastFoundBy(ownerId);
         if (lastDate != DateTime.MinValue)
             break;
     }
     if (lastDate == DateTime.MinValue)
         lastFoundDateLabel.Text = Catalog.GetString ("Never");
     else
         lastFoundDateLabel.Text = lastDate.ToShortDateString ();
 }
Example #38
0
        private void ParseCacheLog(ref Geocache cache, XmlReader reader, ref bool logsChecked)
        {
            CacheLog log = new CacheLog();

            log.LogID  = reader.GetAttribute("id");
            log.LogKey = cache.Name + log.LogID;
            bool breakLoop = false;

            while (!breakLoop && reader.Read())
            {
                if ((reader.LocalName == "date" || reader.LocalName == "time"))
                {
                    string date = reader.ReadString();
                    if (date.Contains("/"))
                    {
                        log.LogDate = DateTime.ParseExact(date, "MM/dd/yyyy'T'HH:mm:ss", CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        log.LogDate = DateTime.Parse(date);
                    }
                }
                else if (reader.LocalName == "type")
                {
                    log.LogStatus = reader.ReadString();
                    if (m_ownid.Contains(log.FinderID) && log.LogStatus == "Found it")
                    {
                        cache.Symbol = "Geocache Found";
                        cache.DNF    = false;
                    }
                    else if (m_ownid.Contains(log.LoggedBy) && log.LogStatus == "Found it")
                    {
                        cache.Symbol = "Geocache Found";
                        cache.DNF    = false;
                    }
                    else if (m_ownid.Contains(log.FinderID) && (log.LogStatus == "Didn't find it" || log.LogStatus == "no_find") && !cache.Found)
                    {
                        cache.DNF = true;
                    }
                    else if (m_ownid.Contains(log.LoggedBy) && (log.LogStatus == "Didn't find it" || log.LogStatus == "no_find") && !cache.Found)
                    {
                        cache.DNF = true;
                    }
                }
                else if ((reader.LocalName == "finder" || reader.LocalName == "geocacher"))
                {
                    log.FinderID = reader.GetAttribute("id");
                    log.LoggedBy = reader.ReadString();
                    if (m_ownid.Contains(log.LoggedBy) && log.LogStatus == "Found it")
                    {
                        cache.Symbol = "Geocache Found";
                        cache.DNF    = false;
                    }
                    else if (m_ownid.Contains(log.FinderID) && log.LogStatus == "Found it")
                    {
                        cache.Symbol = "Geocache Found";
                        cache.DNF    = false;
                    }
                    else if (m_ownid.Contains(log.LoggedBy) && (log.LogStatus == "Didn't find it") && !cache.Found)
                    {
                        cache.DNF = true;
                    }
                    else if (m_ownid.Contains(log.FinderID) && (log.LogStatus == "Didn't find it") && !cache.Found)
                    {
                        cache.DNF = true;
                    }
                }
                else if (reader.LocalName == "text" && reader.IsStartElement())
                {
                    if (reader.GetAttribute("encoded") != null)
                    {
                        log.Encoded = Boolean.Parse(reader.GetAttribute("encoded"));
                    }
                    else
                    {
                        log.Encoded = false;
                    }
                    if (log.LogMessage == "Unknown")
                    {
                        log.LogMessage = reader.ReadString();
                    }
                    else
                    {
                        log.LogMessage += reader.ReadString();
                    }
                }
                else if (reader.LocalName == "log_wpt")
                {
                    double lat = double.Parse(reader.GetAttribute("lat"), CultureInfo.InvariantCulture);
                    double lon = double.Parse(reader.GetAttribute("lon"), CultureInfo.InvariantCulture);
                    if (log.LogMessage == "Unknown")
                    {
                        log.LogMessage = Utilities.getCoordString(lat, lon) + "\n";
                    }
                    else
                    {
                        log.LogMessage = Utilities.getCoordString(lat, lon) + "\n" + log.LogMessage;
                    }
                }
                else if (reader.LocalName == "log")
                {
                    breakLoop = true;
                }
            }
            if (log.LoggedBy == "GSAK" && log.LogStatus == "Other")
            {
                if (log.LogMessage.Trim() == "Notes:")
                {
                    // Empty note, ignore
                    return;
                }
                // Convert GSAK notes into OCM notes
                cache.Notes += log.LogMessage;
                cache.Notes += "----------\n";
                return;
            }

            m_store.AddLog(cache.Name, log);
            if (!logsChecked)
            {
                if (log.LogStatus == "Didn't find it" || log.LogStatus == "Needs Maintenance" || log.LogStatus == "no_find")
                {
                    cache.CheckNotes = true;
                    logsChecked      = true;
                }
                else if (log.LogStatus != "Write Note" && log.LogStatus != "Note")
                {
                    cache.CheckNotes = false;
                    logsChecked      = true;
                }
            }
        }
 public void SetCacheAndPoints(Geocache cache, List<Waypoint> points)
 {
     m_Cache = cache;
     m_childPoints.Clear ();
     if (cache == null)
     {
         addButton.Sensitive = false;
         grabButton.Sensitive = false;
         return;
     }
     else
     {
         addButton.Sensitive = true;
         grabButton.Sensitive = true;
     }
     m_ListSort.SetSortColumnId (1, SortType.Ascending);
     m_childPoints.AppendValues(cache);
     foreach(Waypoint pt in points)
     {
         m_childPoints.AppendValues(pt);
     }
 }
 void HandleCacheListTreeSelectionChanged(object sender, EventArgs e)
 {
     m_Selected = GetSelectedCache(sender as TreeSelection);
     if (this.SelectionChanged != null)
     {
         this.SelectionChanged(this, new CacheEventArgs(m_Selected));
     }
 }
 public void SetDescription(Geocache cache)
 {
     descWidget.HTML = "<div style='font-family:sans-serif;font-size:10pt; background-color:#FFFFFF'>" + cache.ShortDesc + "\n\n"
         + cache.LongDesc + "</div>";
 }
 /// <summary>
 /// Gets the icon name for the corresponding cache type
 /// </summary>
 /// <param name="type">
 /// A geocache type <see cref="Geocache.CacheType"/>
 /// </param>
 /// <returns>
 /// Icon file name <see cref="System.String"/>
 /// </returns>
 public static string GetMapIcon(Geocache cache, String ownerId, UIMonitor mon)
 {
     if (cache.Found)
     {
         if (cache.FTF)
             return FTF_MI;
         return FOUND_MI;
     }
     if ((cache.OwnerID == ownerId) ||(cache.CacheOwner == ownerId))
         return OWNED_MI;
     if ((cache.HasCorrected || cache.HasFinal))
     {
         if (mon.Configuration.SolvedModeState == SolvedMode.ALL)
             return CORRECTED_MI;
         else if (mon.Configuration.SolvedModeState == SolvedMode.PUZZLES &&
                  cache.TypeOfCache == Geocache.CacheType.MYSTERY)
             return CORRECTED_MI;
     }
     else if (cache.DNF && mon.Configuration.ShowDNFIcon)
     {
         return DNF_MI;
     }
     switch (cache.TypeOfCache) {
         case Geocache.CacheType.TRADITIONAL:
             return TRAD_MI;
         case Geocache.CacheType.MYSTERY:
             return UNKNOWN_MI;
         case Geocache.CacheType.MULTI:
             return MULTI_MI;
         case Geocache.CacheType.LETTERBOX:
             return LETTRBOX_MI;
         case Geocache.CacheType.EARTH:
             return EARH_MI;
         case Geocache.CacheType.CITO:
             return CITO_MI;
         case Geocache.CacheType.VIRTUAL:
             return VIRTUAL_MI;
         case Geocache.CacheType.MEGAEVENT:
             return MEGA_MI;
         case Geocache.CacheType.EVENT:
             return EVENT_MI;
         case Geocache.CacheType.WEBCAM:
             return WEBCAM_MI;
         case Geocache.CacheType.WHERIGO:
             return WHERIGO_MI;
         case Geocache.CacheType.GENERIC:
             return GENERIC_MI;
         default:
             return OTHER_MI;
     }
 }
        public void setCoordinate(Geocache cache)
        {
            coordinateLabel.Markup = "<span font='bold 10'>" + Utilities.getCoordString (cache.Lat, cache.Lon) + "</span>";
            if (cache.HasCorrected)
                origCoord.Markup = Catalog.GetString ("<i>Original: ") + Utilities.getCoordString (cache.OrigLat, cache.OrigLon) + "</i>";
            else
                origCoord.Markup = String.Empty;
            ;

            double distance = Utilities.calculateDistance (m_app.CentreLat, cache.Lat, m_app.CentreLon, cache.Lon);
            double bearing = Utilities.calculateBearing (m_app.CentreLat, cache.Lat, m_app.CentreLon, cache.Lon);

            string bmarker = Catalog.GetString ("N");
            if (bearing > 22.5 && bearing <= 67.5)
                bmarker = Catalog.GetString ("NE"); else if (bearing > 67.5 && bearing <= 112.5)
                bmarker = Catalog.GetString ("E"); else if (bearing > 112.5 && bearing <= 157.5)
                bmarker = Catalog.GetString ("SE"); else if (bearing > 157.5 && bearing <= 202.5)
                bmarker = Catalog.GetString ("S"); else if (bearing > 202.5 && bearing <= 247.5)
                bmarker = Catalog.GetString ("SW"); else if (bearing > 247.5 && bearing <= 292.5)
                bmarker = Catalog.GetString ("W"); else if (bearing > 292.5 && bearing <= 337.5)
                bmarker = Catalog.GetString ("NW");

            if (AppConfig.ImperialUnits) {
                distance = Utilities.KmToMiles (distance);
                distance_label.Markup = Catalog.GetString (String.Format (Catalog.GetString ("<span font='bold italic 10'>({0} miles {1} from {2})</span>"), distance.ToString ("0.00"), bmarker, m_app.CenterName));
            } else {
                distance_label.Markup = Catalog.GetString (String.Format (Catalog.GetString ("<span font='bold italic 10'>({0} km {1} from {2})</span>"), distance.ToString ("0.00"), bmarker, m_app.CenterName));
            }
        }
 public void ShowChildWaypoints(Geocache cache)
 {
     List<Waypoint> wpt = Engine.getInstance ().Store.GetChildren(cache.Name);
     IEnumerator<Waypoint> wptenum = wpt.GetEnumerator();
     m_childPoints.AppendValues (cache);
     m_mon.AddMapCache (cache);
     cache.Children = false;
     while (wptenum.MoveNext ()) {
         m_childPoints.AppendValues (wptenum.Current);
         m_mon.AddMapWayPoint (wptenum.Current, cache);
         cache.Children = true;
     }
 }
Example #45
0
 private void ParseCacheType(String type, ref Geocache cache)
 {
     if ((type == "Unknown Cache") || (type == "Other") || (type == "Puzzle") || (type == "Unknown"))
     {
         cache.TypeOfCache = Geocache.CacheType.MYSTERY;
     }
     else if ((type == "Traditional Cache") || (type == "Classic") || (type == "Normal") || (type == "Traditional"))
     {
         cache.TypeOfCache = Geocache.CacheType.TRADITIONAL;
     }
     else if ((type == "Multi-cache") || (type == "Offset") || (type == "Multi-Part") || (type == "Multi"))
     {
         cache.TypeOfCache = Geocache.CacheType.MULTI;
     }
     else if (type == "Letterbox Hybrid")
     {
         cache.TypeOfCache = Geocache.CacheType.LETTERBOX;
     }
     else if ((type == "EarthCache") || (type == "Earthcache"))
     {
         cache.TypeOfCache = Geocache.CacheType.EARTH;
     }
     else if (type == "Wherigo Cache")
     {
         cache.TypeOfCache = Geocache.CacheType.WHERIGO;
     }
     else if ((type == "Webcam Cache") || type == ("Webcam"))
     {
         cache.TypeOfCache = Geocache.CacheType.WEBCAM;
     }
     else if (type == "Cache In Trash Out Event")
     {
         cache.TypeOfCache = Geocache.CacheType.CITO;
     }
     else if (type == "GPS Adventures Exhibit")
     {
         cache.TypeOfCache = Geocache.CacheType.MAZE;
     }
     else if (type == "Mega-Event Cache")
     {
         cache.TypeOfCache = Geocache.CacheType.MEGAEVENT;
     }
     else if ((type == "Event Cache") || (type == "Event"))
     {
         cache.TypeOfCache = Geocache.CacheType.EVENT;
     }
     else if ((type == "Virtual Cache") || (type == "Virtual"))
     {
         cache.TypeOfCache = Geocache.CacheType.VIRTUAL;
     }
     else if (type == "Project APE Cache")
     {
         cache.TypeOfCache = Geocache.CacheType.APE;
     }
     else if (type == "Lost and Found Event Cache")
     {
         cache.TypeOfCache = Geocache.CacheType.EVENT;
     }
     else if (type == "Moving/Travelling")
     {
         cache.TypeOfCache = Geocache.CacheType.REVERSE;
     }
     else
     {
         System.Console.WriteLine("WARNING: TYPE UNKNOWN:" + type);
         cache.TypeOfCache = Geocache.CacheType.GENERIC;
     }
 }
 public void StartPrinting(Geocache cache, MainWindow win)
 {
     m_cache = cache;
     m_print.Run(PrintOperationAction.PrintDialog, win);
 }
Example #47
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>";
     }
 }
Example #48
0
 public static Geocache convertFromWaypoint(Waypoint original)
 {
     Geocache cache = new Geocache();
     cache.Name = original.Name;
     cache.Time = original.Time;
     cache.Lat = original.Lat;
     cache.Lon = original.Lon;
     cache.Desc = original.Desc;
     cache.Symbol = original.Symbol;
     cache.URL = original.URL;
     cache.URLName = original.URLName;
     cache.Type = original.Type;
     cache.Updated = original.Updated;
     cache.CacheName = original.Desc;
     cache.Available = true;
     cache.Archived = false;
     cache.TypeOfCache = Geocache.CacheType.GENERIC;
     cache.ShortDesc = "";
     if (cache.URL != null)
         cache.LongDesc = "<a href=\"" + cache.URL.ToString() + "\">View Online</a>";
     return cache;
 }
 private void GenerateFindLog(MarkFoundDialog dlg, Geocache cache, bool isDNF)
 {
     m_app.LoggingDate = dlg.LogDate;
     CacheLog log = new CacheLog ();
     log.FinderID = m_app.OwnerIDs[0];
     log.LogDate = dlg.LogDate;
     log.LoggedBy = "OCM";
     if (isDNF)
         log.LogStatus = "Didn't find it";
     else
         log.LogStatus = "Found it";
     log.LogMessage = "AUTO LOG: OCM";
     log.LogKey = cache.Name + log.LogDate.ToFileTime ().ToString ();
     m_app.CacheStore.AddLog (cache.Name, log);
 }
Example #50
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";
         }
     }
 }
 public void ModifyCache(Geocache cache)
 {
     cache.Distance = Utilities.calculateDistance(m_app.CentreLat, cache.Lat, m_app.CentreLon, cache.Lon);
     cacheList.Resort();
     m_app.CacheStore.AddWaypointOrCache(cache, false, false);
     HandleCacheListSelectionChanged(this, new CacheEventArgs(cache));
 }