/// <summary> /// Sends Geocaches to a device /// </summary> /// <param name="caches"> /// A list of geocaches <see cref="List<Geocache>"/> /// </param> /// <param name="profile"> /// A gps profiles <see cref="GPSProfile"/> /// </param> /// <param name="includeChildren"> /// If true, include child waypoints<see cref="System.Boolean"/> /// </param> /// <param name="store"> /// The source cache store <see cref="ACacheStore"/> /// </param> public void Start(List <Geocache> caches, GPSProfile profile, bool includeChildren, ACacheStore store) { try { total = caches.Count + 1; if (profile.CacheLimit != -1 && profile.CacheLimit < caches.Count) { total = profile.CacheLimit + 1; } writer.Limit = profile.CacheLimit; writer.BabelFile = profile.OutputFile; writer.BabelFormat = profile.BabelFormat; writer.DescMode = profile.DescMode; writer.NameMode = profile.NameMode; writer.LogLimit = profile.LogLimit; writer.IncludeAttributes = profile.IncludeAttributes; writer.OtherBabelParams = profile.OtherProperties; writer.IncludeChildren = includeChildren; writer.ForcePlainText = profile.ForcePlainText; OCMApp.UpdateGUIThread(); writer.WriteToGPS(caches, profile.WaypointMappings, store); this.Show(); } catch (Exception e) { this.Hide(); OCMApp.ShowException(e); } }
/// <summary> /// Connect to the specified profile and download all field notes /// </summary> /// <param name="profile"> /// The GPS Profile to use <see cref="GPSProfile"/> /// </param> /// <param name="latestScan"> /// Logs older then this date will be ignored <see cref="DateTime"/> /// </param> /// <param name="ownerId"> /// The owner ID to use for marking the logs in the OCM DB <see cref="String"/> /// </param> /// <returns> /// The new datetime of the latest scan <see cref="DateTime"/> /// </returns> public DateTime ProcessFieldNotes(GPSProfile profile, DateTime latestScan, String ownerId) { try { statusLabel.Markup = Catalog.GetString("<i>Receiving from device...</i>"); OCMApp.UpdateGUIThread(); List<CacheLog> logs = FieldNotesHandler.GetLogs(profile.FieldNotesFile, ownerId); int iCount = 0; int iProgCount = 0; int iTotal = logs.Count; statusLabel.Markup = Catalog.GetString("<i>Processing Field Notes...</i>"); m_Win.App.CacheStore.StartUpdate(); DateTime newLatest = DateTime.MinValue; foreach(CacheLog log in logs) { if (m_cancel) { m_Win.App.CacheStore.CancelUpdate(); return DateTime.MinValue; } double prog = (double)((double) iProgCount/ (double) iTotal); loadProgress.Fraction = prog; loadProgress.Text = prog.ToString("0%"); iProgCount ++; OCMApp.UpdateGUIThread(); if (log.LogDate <= latestScan) { System.Console.WriteLine("Skipping" + latestScan); continue; } List<Geocache> cache = m_Win.App.CacheStore.GetCachesByName(new string[]{log.CacheCode}); if (cache.Count > 0) UpdateCache(cache[0], log); if (newLatest < log.LogDate) newLatest = log.LogDate; iCount ++; } if (!m_cancel) { UpdateFNFile(logs); m_Win.App.CacheStore.CompleteUpdate(); } else m_Win.App.CacheStore.CancelUpdate(); buttonCancel.Visible = false; buttonClose.Visible = true; buttonView.Visible = true; loadProgress.Fraction = 1; statusLabel.Markup = String.Format(Catalog.GetString("<i>Scanned {0} Field Notes, {1} new.</i>"), iProgCount, iCount); loadProgress.Text = Catalog.GetString("Complete"); return newLatest; } catch (Exception e) { m_Win.App.CacheStore.CancelUpdate(); this.Hide(); OCMApp.ShowException(e); return DateTime.MinValue; } }
private void UpgradeWaypointMappings(GPSProfile profile) { Dictionary <string, string> mappings = new Dictionary <string, string>(); mappings.Add("Geocache|Traditional Cache", this.Get("/apps/ocm/wmappings/Geocache_Traditional_Cache", "Geocache") as string); mappings.Add("Geocache|Unknown Cache", this.Get("/apps/ocm/wmappings/Geocache_Unknown_Cache", "Geocache") as string); mappings.Add("Geocache|Virtual Cache", this.Get("/apps/ocm/wmappings/Geocache_Virtual_Cache", "Geocache") as string); mappings.Add("Geocache|Multi-cache", this.Get("/apps/ocm/wmappings/Geocache_Multi-cache", "Geocache") as string); mappings.Add("Geocache|Project APE Cache", this.Get("/apps/ocm/wmappings/Geocache_Project_APE_Cache", "Geocache") as string); mappings.Add("Geocache|Cache In Trash Out Event", this.Get("/apps/ocm/wmappings/Geocache_Cache_In_Trash_Out_Event", "Geocache") as string); mappings.Add("Geocache|Earthcache", this.Get("/apps/ocm/wmappings/Geocache_Earthcache", "Geocache") as string); mappings.Add("Geocache|Event Cache", this.Get("/apps/ocm/wmappings/Geocache_Event_Cache", "Geocache") as string); mappings.Add("Geocache|Letterbox Hybrid", this.Get("/apps/ocm/wmappings/Geocache_Letterbox_Hybrid", "Geocache") as string); mappings.Add("Geocache|GPS Adventures Exhibit", this.Get("/apps/ocm/wmappings/Geocache_GPS_Adventures_Exhibit", "Geocache") as string); mappings.Add("Geocache|Mega-Event Cache", this.Get("/apps/ocm/wmappings/Geocache_Mega-Event_Cache", "Geocache") as string); mappings.Add("Geocache|Locationless Cache", this.Get("/apps/ocm/wmappings/Geocache_Locationless_Cache", "Geocache") as string); mappings.Add("Geocache|Webcam Cache", this.Get("/apps/ocm/wmappings/Geocache_Webcam_Cache", "Geocache") as string); mappings.Add("Geocache|Wherigo Cache", this.Get("/apps/ocm/wmappings/Geocache_Wherigo_Cache", "Geocache") as string); mappings.Add("Geocache", this.Get("/apps/ocm/wmappings/Geocache", "Geocache") as string); mappings.Add("Geocache Found", this.Get("/apps/ocm/wmappings/Geocache_Found", "Geocache Found") as string); mappings.Add("Waypoint|Final Location", this.Get("/apps/ocm/wmappings/Waypoint_Final_Location", "Pin, Blue") as string); mappings.Add("Waypoint|Parking Area", this.Get("/apps/ocm/wmappings/Waypoint_Parking_Area", "Parking Area") as string); mappings.Add("Waypoint|Reference Point", this.Get("/apps/ocm/wmappings/Waypoint_Reference_Point", "Pin, Green") as string); mappings.Add("Waypoint|Question to Answer", this.Get("/apps/ocm/wmappings/Waypoint_Question_to_Answer", "Pin, Red") as string); mappings.Add("Waypoint|Stages of a Multicache", this.Get("/apps/ocm/wmappings/Waypoint_Stages_of_a_Multicache", "Pin, Red") as string); mappings.Add("Waypoint|Trailhead", this.Get("/apps/ocm/wmappings/Waypoint_Trailhead", "Trail Head") as string); mappings.Add("Waypoint|Other", this.Get("/apps/ocm/wmappings/Waypoint_Other", "Pin, Green") as string); profile.WaypointMappings = mappings; //Cleanup legacy keys UnsetKey("/apps/ocm/wmappings/Geocache_Traditional_Cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Unknown_Cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Virtual_Cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Multi-cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Project_APE_Cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Cache_In_Trash_Out_Event"); UnsetKey("/apps/ocm/wmappings/Geocache_Earthcache"); UnsetKey("/apps/ocm/wmappings/Geocache_Event_Cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Letterbox_Hybrid"); UnsetKey("/apps/ocm/wmappings/Geocache_GPS_Adventures_Exhibit"); UnsetKey("/apps/ocm/wmappings/Geocache_Mega-Event_Cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Locationless_Cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Webcam_Cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Webcam_cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Wherigo_Cache"); UnsetKey("/apps/ocm/wmappings/Geocache"); UnsetKey("/apps/ocm/wmappings/Geocache_Found"); UnsetKey("/apps/ocm/wmappings/Waypoint_Final_Location"); UnsetKey("/apps/ocm/wmappings/Waypoint_Parking_Area"); UnsetKey("/apps/ocm/wmappings/Waypoint_Reference_Point"); UnsetKey("/apps/ocm/wmappings/Waypoint_Stages_of_a_Multicache"); UnsetKey("/apps/ocm/wmappings/Waypoint_Question_to_Answer"); UnsetKey("/apps/ocm/wmappings/Waypoint_Trailhead"); UnsetKey("/apps/ocm/wmappings/Waypoint_Other"); }
public void CheckForDefaultGPS(GPSProfileList list, OCMMainWindow win) { string defName = this.GPSProf; string defType = this.Get("/apps/ocm/gps/type", null) as string; if (defName == null && defType != null) { // Check for legacy GPS Config (pre 0.23) or use Garmin GPX as // default config. GPSProfile profile = new GPSProfile(); profile.Name = "Default"; profile.CacheLimit = (int)this.Get("/apps/ocm/gps/limit", -1); profile.BabelFormat = this.Get("/apps/ocm/gps/type", "OCM_GPX") as string; string nm = this.Get("/apps/ocm/gps/namemode", WaypointNameMode.CODE.ToString()) as string; profile.NameMode = (WaypointNameMode)Enum.Parse(typeof(WaypointNameMode), nm); string dm = this.Get("/apps/ocm/gps/descmode", WaypointDescMode.DESC.ToString()) as string; profile.DescMode = (WaypointDescMode)Enum.Parse(typeof(WaypointDescMode), dm); profile.LogLimit = (int)this.Get("/apps/ocm/gps/loglimit", -1); profile.IncludeAttributes = (bool)this.Get("/apps/ocm/gps/incattr", false); profile.OutputFile = this.Get("/apps/ocm/gps/file", "/media/GARMIN/Garmin/GPX/geocaches.gpx") as string; if (profile.BabelFormat == "delgpx") { profile.FieldNotesFile = "/media/EM_USERMAPS/FieldNotes.txt"; } else if (profile.BabelFormat == "OCM_GPX") { profile.FieldNotesFile = "/media/GARMIN/Garmin/geocache_visits.txt"; } UpgradeWaypointMappings(profile); list.AddProfile(profile); GPSProf = profile.Name; win.RebuildProfiles(); //Cleanup legacy keys UnsetKey("/apps/ocm/gps/limit"); UnsetKey("/apps/ocm/gps/type"); UnsetKey("/apps/ocm/gps/namemode"); UnsetKey("/apps/ocm/gps/descmode"); UnsetKey("/apps/ocm/gps/loglimit"); UnsetKey("/apps/ocm/gps/incattr"); UnsetKey("/apps/ocm/gps/file"); } }
public void AddProfile(GPSProfile prof) { if (m_profiles.ContainsKey(prof.Name)) { MessageDialog dlg = new MessageDialog(null, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, String.Format(Catalog.GetString("Are you sure you wish to " + "overwrite \"{0}\"?"), prof.Name)); if ((int)ResponseType.Yes != dlg.Run()) { dlg.Hide(); return; } else { dlg.Hide(); m_profiles.Remove(prof.Name); } } m_profiles.Add(prof.Name, prof); UpdateProfFile(); }
public void Start(List<Geocache> caches, GPSProfile profile, bool includeChildren) { try { if (profile.CacheLimit == -1) total = caches.Count + 1; else total = profile.CacheLimit + 1; writer.Limit = profile.CacheLimit; writer.BabelFile = profile.OutputFile; writer.BabelFormat = profile.BabelFormat; writer.DescMode = profile.DescMode; writer.NameMode = profile.NameMode; writer.LogLimit = profile.LogLimit; writer.IncludeAttributes = profile.IncludeAttributes; writer.OtherBabelParams = profile.OtherProperties; writer.IncludeChildren = includeChildren; writer.ForcePlainText = profile.ForcePlainText; writer.WriteToGPS (caches, profile.WaypointMappings); this.Show (); } catch (Exception e) { this.Hide (); UIMonitor.ShowException (e); } }
public void CheckForDefaultGPS(GPSProfileList list, MainWindow win) { string defName = this.GPSProf; string defType = this.Get("/apps/ocm/gps/type", null) as string; if (defName == null && defType != null) { // Check for legacy GPS Config (pre 0.23) or use Garmin GPX as // default config. GPSProfile profile = new GPSProfile(); profile.Name = "Default"; profile.CacheLimit = (int) this.Get("/apps/ocm/gps/limit", -1); profile.BabelFormat = this.Get("/apps/ocm/gps/type", "OCM_GPX") as string; string nm = this.Get("/apps/ocm/gps/namemode", WaypointNameMode.CODE.ToString()) as string; profile.NameMode = (WaypointNameMode) Enum.Parse(typeof(WaypointNameMode), nm); string dm = this.Get("/apps/ocm/gps/descmode", WaypointDescMode.DESC.ToString()) as string; profile.DescMode = (WaypointDescMode) Enum.Parse(typeof(WaypointDescMode), dm); profile.LogLimit = (int) this.Get("/apps/ocm/gps/loglimit", -1); profile.IncludeAttributes = (bool) this.Get("/apps/ocm/gps/incattr", false); profile.OutputFile = this.Get("/apps/ocm/gps/file", "/media/GARMIN/Garmin/GPX/geocaches.gpx") as string; if (profile.BabelFormat == "delgpx") profile.FieldNotesFile = "/media/EM_USERMAPS/FieldNotes.txt"; else if (profile.BabelFormat == "OCM_GPX") profile.FieldNotesFile = "/media/GARMIN/Garmin/geocache_visits.txt"; UpgradeWaypointMappings(profile); list.AddProfile(profile); GPSProf = profile.Name; win.RebuildProfEditMenu(list); win.RebuildProfilesMenu(list); //Cleanup legacy keys UnsetKey("/apps/ocm/gps/limit"); UnsetKey("/apps/ocm/gps/type"); UnsetKey("/apps/ocm/gps/namemode"); UnsetKey("/apps/ocm/gps/descmode"); UnsetKey("/apps/ocm/gps/loglimit"); UnsetKey("/apps/ocm/gps/incattr"); UnsetKey("/apps/ocm/gps/file"); } }
/// <summary> /// Sends Geocaches to a device, always including child waypoints /// </summary> /// <param name="caches"> /// A list of geocaches <see cref="List<Geocache>"/> /// </param> /// <param name="profile"> /// A GPS profile <see cref="GPSProfile"/> /// </param> /// <param name="store"> /// The source CacheStore <see cref="ACacheStore"/> /// </param> public void Start(List <Geocache> caches, GPSProfile profile, ACacheStore store) { Start(caches, profile, true, store); }
public void UpdateProfile(GPSProfile prof) { m_profiles.Remove(prof.Name); m_profiles.Add(prof.Name, prof); UpdateProfFile(); }
/// <summary> /// Sends Geocaches to a device /// </summary> /// <param name="caches"> /// A list of geocaches <see cref="List<Geocache>"/> /// </param> /// <param name="profile"> /// A gps profiles <see cref="GPSProfile"/> /// </param> /// <param name="includeChildren"> /// If true, include child waypoints<see cref="System.Boolean"/> /// </param> /// <param name="store"> /// The source cache store <see cref="ACacheStore"/> /// </param> public void Start(List<Geocache> caches, GPSProfile profile, bool includeChildren, ACacheStore store) { try { total = caches.Count + 1; if (profile.CacheLimit != -1 && profile.CacheLimit < caches.Count) total = profile.CacheLimit + 1; writer.Limit = profile.CacheLimit; writer.BabelFile = profile.OutputFile; writer.BabelFormat = profile.BabelFormat; writer.DescMode = profile.DescMode; writer.NameMode = profile.NameMode; writer.LogLimit = profile.LogLimit; writer.IncludeAttributes = profile.IncludeAttributes; writer.OtherBabelParams = profile.OtherProperties; writer.IncludeChildren = includeChildren; writer.ForcePlainText = profile.ForcePlainText; OCMApp.UpdateGUIThread(); writer.WriteToGPS (caches, profile.WaypointMappings, store); this.Show (); } catch (Exception e) { this.Hide (); OCMApp.ShowException(e); } }
/// <summary> /// Sends Geocaches to a device, always including child waypoints /// </summary> /// <param name="caches"> /// A list of geocaches <see cref="List<Geocache>"/> /// </param> /// <param name="profile"> /// A GPS profile <see cref="GPSProfile"/> /// </param> /// <param name="store"> /// The source CacheStore <see cref="ACacheStore"/> /// </param> public void Start(List<Geocache> caches, GPSProfile profile, ACacheStore store) { Start(caches, profile, true, store); }
void HandleActionActivated(object sender, EventArgs e) { GPSProfile prof = m_profiles[((sender) as Gtk.Action).Name]; m_Win.EditProfile(prof); }
public void ExportGarminPOI() { ExportPOIDialog dlg = new ExportPOIDialog (Config); if ((int)ResponseType.Ok == dlg.Run ()) { GPSProfile poiProfile = new GPSProfile (); poiProfile.BabelFormat = "garmin_gpi"; poiProfile.NameMode = dlg.NameMode; poiProfile.DescMode = dlg.DescMode; poiProfile.OutputFile = dlg.FileName; poiProfile.CacheLimit = dlg.CacheLimit; poiProfile.LogLimit = dlg.LogLimit; poiProfile.FieldNotesFile = null; poiProfile.IncludeAttributes = false; poiProfile.ForcePlainText = dlg.UsePlainText; poiProfile.Name = "POI"; StringBuilder builder = new StringBuilder (); // Build other properties if (dlg.BMPFile != null) { builder.Append ("bitmap=\""); builder.Append (dlg.BMPFile); builder.Append ("\""); } else { builder.Append ("hide"); } if (dlg.ProximityDistance > 0) { builder.Append (",proximity="); builder.Append (dlg.ProximityDistance.ToString (CultureInfo.InvariantCulture)); builder.Append (",units="); builder.Append (dlg.ProximityUnits); } builder.Append (","); builder.Append ("category=\""); builder.Append (dlg.Category); builder.Append ("\""); poiProfile.OtherProperties = builder.ToString (); SendWaypointsDialog edlg = new SendWaypointsDialog (); edlg.Icon = this.Icon; edlg.AutoClose = Config.AutoCloseWindows; edlg.Start (CacheList.UnfilteredCaches, poiProfile, m_app.CacheStore); } dlg.Dispose (); }
private void UpgradeWaypointMappings(GPSProfile profile) { Dictionary<string, string> mappings = new Dictionary<string, string>(); mappings.Add("Geocache|Traditional Cache", this.Get("/apps/ocm/wmappings/Geocache_Traditional_Cache", "Geocache") as string); mappings.Add("Geocache|Unknown Cache",this.Get("/apps/ocm/wmappings/Geocache_Unknown_Cache", "Geocache") as string); mappings.Add("Geocache|Virtual Cache", this.Get("/apps/ocm/wmappings/Geocache_Virtual_Cache", "Geocache") as string); mappings.Add("Geocache|Multi-cache", this.Get("/apps/ocm/wmappings/Geocache_Multi-cache", "Geocache") as string); mappings.Add("Geocache|Project APE Cache", this.Get("/apps/ocm/wmappings/Geocache_Project_APE_Cache", "Geocache") as string); mappings.Add("Geocache|Cache In Trash Out Event", this.Get("/apps/ocm/wmappings/Geocache_Cache_In_Trash_Out_Event", "Geocache") as string); mappings.Add("Geocache|Earthcache", this.Get("/apps/ocm/wmappings/Geocache_Earthcache", "Geocache") as string); mappings.Add("Geocache|Event Cache", this.Get("/apps/ocm/wmappings/Geocache_Event_Cache", "Geocache") as string); mappings.Add("Geocache|Letterbox Hybrid", this.Get("/apps/ocm/wmappings/Geocache_Letterbox_Hybrid", "Geocache") as string); mappings.Add("Geocache|GPS Adventures Exhibit",this.Get("/apps/ocm/wmappings/Geocache_GPS_Adventures_Exhibit", "Geocache") as string); mappings.Add("Geocache|Mega-Event Cache", this.Get("/apps/ocm/wmappings/Geocache_Mega-Event_Cache", "Geocache") as string); mappings.Add("Geocache|Locationless Cache",this.Get("/apps/ocm/wmappings/Geocache_Locationless_Cache", "Geocache") as string); mappings.Add("Geocache|Webcam Cache", this.Get("/apps/ocm/wmappings/Geocache_Webcam_Cache", "Geocache") as string); mappings.Add("Geocache|Wherigo Cache", this.Get("/apps/ocm/wmappings/Geocache_Wherigo_Cache", "Geocache") as string); mappings.Add("Geocache", this.Get("/apps/ocm/wmappings/Geocache", "Geocache") as string); mappings.Add("Geocache Found", this.Get("/apps/ocm/wmappings/Geocache_Found", "Geocache Found") as string); mappings.Add("Waypoint|Final Location", this.Get("/apps/ocm/wmappings/Waypoint_Final_Location", "Pin, Blue") as string); mappings.Add("Waypoint|Parking Area", this.Get("/apps/ocm/wmappings/Waypoint_Parking_Area", "Parking Area") as string); mappings.Add("Waypoint|Reference Point", this.Get("/apps/ocm/wmappings/Waypoint_Reference_Point", "Pin, Green") as string); mappings.Add("Waypoint|Question to Answer", this.Get("/apps/ocm/wmappings/Waypoint_Question_to_Answer", "Pin, Red") as string); mappings.Add("Waypoint|Stages of a Multicache", this.Get("/apps/ocm/wmappings/Waypoint_Stages_of_a_Multicache", "Pin, Red") as string); mappings.Add("Waypoint|Trailhead", this.Get("/apps/ocm/wmappings/Waypoint_Trailhead", "Trail Head") as string); mappings.Add("Waypoint|Other", this.Get("/apps/ocm/wmappings/Waypoint_Other", "Pin, Green") as string); profile.WaypointMappings = mappings; //Cleanup legacy keys UnsetKey("/apps/ocm/wmappings/Geocache_Traditional_Cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Unknown_Cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Virtual_Cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Multi-cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Project_APE_Cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Cache_In_Trash_Out_Event"); UnsetKey("/apps/ocm/wmappings/Geocache_Earthcache"); UnsetKey("/apps/ocm/wmappings/Geocache_Event_Cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Letterbox_Hybrid"); UnsetKey("/apps/ocm/wmappings/Geocache_GPS_Adventures_Exhibit"); UnsetKey("/apps/ocm/wmappings/Geocache_Mega-Event_Cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Locationless_Cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Webcam_Cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Webcam_cache"); UnsetKey("/apps/ocm/wmappings/Geocache_Wherigo_Cache"); UnsetKey("/apps/ocm/wmappings/Geocache"); UnsetKey("/apps/ocm/wmappings/Geocache_Found"); UnsetKey("/apps/ocm/wmappings/Waypoint_Final_Location"); UnsetKey("/apps/ocm/wmappings/Waypoint_Parking_Area"); UnsetKey("/apps/ocm/wmappings/Waypoint_Reference_Point"); UnsetKey("/apps/ocm/wmappings/Waypoint_Stages_of_a_Multicache"); UnsetKey("/apps/ocm/wmappings/Waypoint_Question_to_Answer"); UnsetKey("/apps/ocm/wmappings/Waypoint_Trailhead"); UnsetKey("/apps/ocm/wmappings/Waypoint_Other"); }
public void Start(List<Geocache> caches, GPSProfile profile) { Start(caches, profile, true); }
public GPSConfiguration(GPSProfile profile) { this.Build(); profileEntry.Text = profile.Name; if ((profile.BabelFormat == "garmin") && (profile.OutputFile == "usb:")) { gusbwidet.SetCacheLimit(profile.CacheLimit); gusbwidet.SetNameMode(profile.NameMode); gusbwidet.SetDescMode(profile.DescMode); deviceCombo.Active = 1; } else if (profile.BabelFormat == "garmin") { garswidget.SetCacheLimit(profile.CacheLimit); garswidget.SetOutputFile(profile.OutputFile); garswidget.SetNameMode(profile.NameMode); deviceCombo.Active = 2; } else if (profile.BabelFormat == "OCM_GPX") { gpxwidget.SetCacheLimit(profile.CacheLimit); gpxwidget.SetOutputFile(profile.OutputFile); gpxwidget.SetLogLimit(profile.LogLimit); gpxwidget.SetIncludeAttributes(profile.IncludeAttributes); gpxwidget.FieldNotesFile = profile.FieldNotesFile; deviceCombo.Active = 0; ShowDeviceConfig(); } else if (profile.BabelFormat.StartsWith("delbin")) { delwidget.SetCacheLimit(profile.CacheLimit); delwidget.SetLogLimit(profile.LogLimit); delwidget.SetIncludeAttributes(profile.IncludeAttributes); deviceCombo.Active = 4; } else if (profile.BabelFormat == "edge") { edgeWidget.SetCacheLimit(profile.CacheLimit); edgeWidget.SetOutputFile(profile.OutputFile); edgeWidget.SetDescMode(profile.DescMode); edgeWidget.SetNameMode(profile.NameMode); deviceCombo.Active = 3; } else if (profile.BabelFormat == "delgpx") { delgpxwidget.SetCacheLimit(profile.CacheLimit); delgpxwidget.SetOutputFile(profile.OutputFile); delgpxwidget.SetLogLimit(profile.LogLimit); delgpxwidget.SetIncludeAttributes(profile.IncludeAttributes); delgpxwidget.FieldNotesFile = profile.FieldNotesFile; deviceCombo.Active = 5; } else { gpswidget.SetCacheLimit(profile.CacheLimit); gpswidget.SetOutputFile(profile.OutputFile); gpswidget.SetBabelFormat(profile.BabelFormat); gpswidget.SetDescMode(profile.DescMode); gpswidget.SetNameMode(profile.NameMode); deviceCombo.Active = 6; } waypointWidget.PopulateMappings(profile.WaypointMappings); this.ShowAll(); }
/// <summary> /// Connect to the specified profile and download all field notes /// </summary> /// <param name="profile"> /// The GPS Profile to use <see cref="GPSProfile"/> /// </param> /// <param name="latestScan"> /// Logs older then this date will be ignored <see cref="DateTime"/> /// </param> /// <param name="ownerId"> /// The owner ID to use for marking the logs in the OCM DB <see cref="String"/> /// </param> /// <returns> /// The new datetime of the latest scan <see cref="DateTime"/> /// </returns> public DateTime ProcessFieldNotes(GPSProfile profile, DateTime latestScan, String ownerId) { try { statusLabel.Markup = Catalog.GetString("<i>Receiving from device...</i>"); OCMApp.UpdateGUIThread(); List <CacheLog> logs = FieldNotesHandler.GetLogs(profile.FieldNotesFile, ownerId); int iCount = 0; int iProgCount = 0; int iTotal = logs.Count; statusLabel.Markup = Catalog.GetString("<i>Processing Field Notes...</i>"); m_Win.App.CacheStore.StartUpdate(); DateTime newLatest = DateTime.MinValue; foreach (CacheLog log in logs) { if (m_cancel) { m_Win.App.CacheStore.CancelUpdate(); return(DateTime.MinValue); } double prog = (double)((double)iProgCount / (double)iTotal); loadProgress.Fraction = prog; loadProgress.Text = prog.ToString("0%"); iProgCount++; OCMApp.UpdateGUIThread(); if (log.LogDate <= latestScan) { System.Console.WriteLine("Skipping" + latestScan); continue; } List <Geocache> cache = m_Win.App.CacheStore.GetCachesByName(new string[] { log.CacheCode }); if (cache.Count > 0) { UpdateCache(cache[0], log); } if (newLatest < log.LogDate) { newLatest = log.LogDate; } iCount++; } if (!m_cancel) { UpdateFNFile(logs); m_Win.App.CacheStore.CompleteUpdate(); } else { m_Win.App.CacheStore.CancelUpdate(); } buttonCancel.Visible = false; buttonClose.Visible = true; buttonView.Visible = true; loadProgress.Fraction = 1; statusLabel.Markup = String.Format(Catalog.GetString("<i>Scanned {0} Field Notes, {1} new.</i>"), iProgCount, iCount); loadProgress.Text = Catalog.GetString("Complete"); return(newLatest); } catch (Exception e) { m_Win.App.CacheStore.CancelUpdate(); this.Hide(); OCMApp.ShowException(e); return(DateTime.MinValue); } }
public void AddProfile(GPSProfile prof) { if (m_profiles.ContainsKey(prof.Name)) { MessageDialog dlg = new MessageDialog(null, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, String.Format(Catalog.GetString("Are you sure you wish to " + "overwrite \"{0}\"?"), prof.Name)); if ((int) ResponseType.Yes != dlg.Run()) { dlg.Hide(); return; } else { dlg.Hide(); m_profiles.Remove(prof.Name); } } m_profiles.Add(prof.Name, prof); UpdateProfFile(); }
public void AddGPSProfile() { GPSConfiguration dlg = new GPSConfiguration (); dlg.Parent = this; dlg.Icon = this.Icon; if ((int)ResponseType.Ok == dlg.Run ()) { GPSProfile prof = new GPSProfile (); prof.Name = dlg.ProfileName; prof.BabelFormat = dlg.GPSConfig.GetBabelFormat (); prof.CacheLimit = dlg.GPSConfig.GetCacheLimit (); prof.NameMode = dlg.GPSConfig.GetNameMode (); prof.DescMode = dlg.GPSConfig.GetDescMode (); prof.LogLimit = dlg.GPSConfig.GetLogLimit (); prof.IncludeAttributes = dlg.GPSConfig.IncludeAttributes (); prof.OutputFile = dlg.GPSConfig.GetOutputFile (); prof.FieldNotesFile = dlg.GPSConfig.FieldNotesFile; prof.WaypointMappings = dlg.GPSMappings; if (Config.GPSProf == null) Config.GPSProf = prof.Name; m_app.Profiles.AddProfile (prof); RebuildProfiles(); } }
public GPSConfiguration(GPSProfile profile) { this.Build (); profileEntry.Text = profile.Name; if ((profile.BabelFormat == "garmin") && (profile.OutputFile == "usb:")) { gusbwidet.SetCacheLimit(profile.CacheLimit); gusbwidet.SetNameMode(profile.NameMode); gusbwidet.SetDescMode(profile.DescMode); deviceCombo.Active = 1; } else if (profile.BabelFormat == "garmin") { garswidget.SetCacheLimit(profile.CacheLimit); garswidget.SetOutputFile(profile.OutputFile); garswidget.SetNameMode(profile.NameMode); deviceCombo.Active = 2; } else if (profile.BabelFormat== "OCM_GPX") { gpxwidget.SetCacheLimit(profile.CacheLimit); gpxwidget.SetOutputFile(profile.OutputFile); gpxwidget.SetLogLimit(profile.LogLimit); gpxwidget.SetIncludeAttributes(profile.IncludeAttributes); gpxwidget.FieldNotesFile = profile.FieldNotesFile; deviceCombo.Active = 0; ShowDeviceConfig(); } else if (profile.BabelFormat.StartsWith("delbin")) { delwidget.SetCacheLimit(profile.CacheLimit); delwidget.SetLogLimit(profile.LogLimit); delwidget.SetIncludeAttributes(profile.IncludeAttributes); deviceCombo.Active = 4; } else if (profile.BabelFormat == "edge") { edgeWidget.SetCacheLimit(profile.CacheLimit); edgeWidget.SetOutputFile(profile.OutputFile); edgeWidget.SetDescMode(profile.DescMode); edgeWidget.SetNameMode(profile.NameMode); deviceCombo.Active = 3; } else if (profile.BabelFormat == "delgpx") { delgpxwidget.SetCacheLimit(profile.CacheLimit); delgpxwidget.SetOutputFile(profile.OutputFile); delgpxwidget.SetLogLimit(profile.LogLimit); delgpxwidget.SetIncludeAttributes(profile.IncludeAttributes); delgpxwidget.FieldNotesFile = profile.FieldNotesFile; deviceCombo.Active = 5; } else { gpswidget.SetCacheLimit(profile.CacheLimit); gpswidget.SetOutputFile(profile.OutputFile); gpswidget.SetBabelFormat(profile.BabelFormat); gpswidget.SetDescMode(profile.DescMode); gpswidget.SetNameMode(profile.NameMode); deviceCombo.Active = 6; } waypointWidget.PopulateMappings(profile.WaypointMappings); this.ShowAll(); }
public void EditProfile(GPSProfile prof) { GPSConfiguration dlg = new GPSConfiguration (prof); dlg.Parent = this; dlg.Icon = this.Icon; dlg.Title = Catalog.GetString ("Edit GPS Profile..."); if ((int)ResponseType.Ok == dlg.Run ()) { string origName = prof.Name; bool isActive = false; if ((m_app.Profiles.GetActiveProfile ()) != null && (m_app.Profiles.GetActiveProfile ().Name == origName)) isActive = true; prof.Name = dlg.ProfileName; prof.BabelFormat = dlg.GPSConfig.GetBabelFormat (); prof.CacheLimit = dlg.GPSConfig.GetCacheLimit (); prof.NameMode = dlg.GPSConfig.GetNameMode (); prof.DescMode = dlg.GPSConfig.GetDescMode (); prof.LogLimit = dlg.GPSConfig.GetLogLimit (); prof.IncludeAttributes = dlg.GPSConfig.IncludeAttributes (); prof.OutputFile = dlg.GPSConfig.GetOutputFile (); prof.WaypointMappings = dlg.GPSMappings; prof.FieldNotesFile = dlg.GPSConfig.FieldNotesFile; if (origName == prof.Name) { m_app.Profiles.UpdateProfile (prof); } else { m_app.Profiles.DeleteProfile (origName); m_app.Profiles.AddProfile (prof); if (isActive) Config.GPSProf = prof.Name; } RebuildProfiles(); } }