public void SelecteWaypointByName(string code) { try { if (code == null) { wptView.Selection.UnselectAll(); return; } TreeIter itr; TreeModel model = wptView.Model; wptView.Model.GetIterFirst(out itr); do { Waypoint pt = (Waypoint)model.GetValue(itr, 0); if (pt.Name == code) { wptView.Selection.SelectIter(itr); TreePath path = wptView.Model.GetPath(itr); wptView.ScrollToCell(path, wptView.Columns[0], true, 0, 0); return; } }while (model.IterNext(ref itr)); } catch (Exception e) { OCMApp.ShowException(e); } }
/// <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); } }
public void Refresh() { try { if (null != this.RefreshStart) { RefreshStart(this, new EventArgs()); } Geocache selected = SelectedCache; m_disabledOrArchivedCount = 0; m_visibleCount = 0; m_mineCount = 0; m_foundCount = 0; if (m_app.AppConfig.ImperialUnits) { m_distanceColumn.Title = Catalog.GetString("Mi"); distanceLabel.Text = Catalog.GetString("Mi"); } else { m_distanceColumn.Title = Catalog.GetString("km"); distanceLabel.Text = Catalog.GetString("km"); } UpdateStatus(); CacheStore.GlobalFilters.AddFilterCriteria(FilterList.KEY_STATUS, new bool[] { foundCheck.Active, notFoundCheck.Active, mineCheck.Active, availCheck.Active, notAvailCheck.Active, archiveCheck.Active }); cacheListTree.Model = null; if (m_list == null) { m_list = new CacheStoreModel(); } else { m_list.Clear(); } if (m_sort == null) { m_sort = new TreeModelSort(new TreeModelAdapter(m_list)); m_sort.SetSortFunc(3, TitleCompare); m_sort.SetSortFunc(2, DistanceCompare); m_sort.SetSortFunc(0, SymbolCompare); m_sort.DefaultSortFunc = DistanceCompare; } CacheStore.ReadCache += HandleCacheStoreReadCache; CacheStore.Complete += HandleCacheStoreComplete; CacheStore.GetUnfilteredCaches(m_app.CentreLat, m_app.CentreLon, m_app.OwnerIDs.ToArray()); CacheStore.ReadCache -= HandleCacheStoreReadCache; CacheStore.Complete -= HandleCacheStoreComplete; } catch (Exception e) { OCMApp.ShowException(e); } }
protected virtual void OnOpenButtonClicked(object sender, System.EventArgs e) { FileChooserDialog dlg = null; try { dlg = new FileChooserDialog(Catalog.GetString("Open Map Description File"), null, FileChooserAction.Open, Catalog.GetString("Cancel"), ResponseType.Cancel, Catalog.GetString("Open"), ResponseType.Accept); //dlg.SetCurrentFolder (m_conf.DataDirectory); FileFilter filter = new FileFilter(); filter.Name = Catalog.GetString("OCM Map Files"); filter.AddPattern("*.xml"); dlg.AddFilter(filter); if (dlg.Run() == (int)ResponseType.Accept) { dlg.Hide(); m_maps.AddRange(MapManager.GetMapsFromFile(dlg.Filename)); ReloadMaps(); dlg.Destroy(); } else { dlg.Hide(); dlg.Destroy(); } } catch (Exception exception) { OCMApp.ShowException(exception); if (dlg != null) { dlg.Hide(); dlg.Destroy(); } } }
/// <summary> /// Starts downloading a list of files /// </summary> /// <param name="files"> /// A list of file urls<see cref="List<System.String>"/> /// </param> /// <param name="destFolder"> /// The destination directory <see cref="System.String"/> /// </param> public void Start(List <string> files, string destFolder) { try { int iCount = 1; int total = files.Count; this.Show(); OCMApp.UpdateGUIThread(); foreach (string url in files) { if (m_cancel) { break; } DownloadFile(url, destFolder, total, ref iCount); } if (m_cancel) { progBar.Text = Catalog.GetString("Cancelled"); } else { progBar.Text = Catalog.GetString("Complete"); } buttonOk.Show(); buttonCancel.Hide(); } catch (Exception e) { this.Hide(); OCMApp.ShowException(e); } }
/// <summary> /// Updates the current cache and field notes file /// </summary> void SaveLogChanges() { try { m_currLog.LogMessage = logEntry.Buffer.Text; m_Win.App.CacheStore.AddLog(m_currLog.CacheCode, m_currLog); if (m_caches.ContainsKey(m_currLog.CacheCode)) { m_Win.App.CacheStore.AddWaypointOrCache(m_caches[m_currLog.CacheCode], false, false); } UpdateFNFile(); } catch (Exception e) { OCMApp.ShowException(e); } }
protected virtual void DoEdit(object sender, System.EventArgs e) { try { Gtk.TreeIter itr; Gtk.TreeModel model; if (wptView.Selection.GetSelected(out model, out itr)) { Waypoint wpt = (Waypoint)model.GetValue(itr, 0); if (wpt is Geocache) { m_App.EditCache(); return; } m_App.EditChildWaypoint(wpt); } } catch (Exception ex) { OCMApp.ShowException(ex); } }
protected virtual void OnDeleteAllClick(object sender, System.EventArgs e) { MessageDialog dlg = new MessageDialog(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo, Catalog.GetString("Are you sure you want to remove all field notes?")); try { if ((int)ResponseType.Yes == dlg.Run()) { FieldNotesHandler.ClearFieldNotes(m_Win.App.AppConfig.FieldNotesFile); m_Logs.Clear(); PopulateLogs(m_Logs); } dlg.Hide(); dlg.Dispose(); } catch (Exception e1) { dlg.Hide(); OCMApp.ShowException(e1); } }
public void Start(String filename, ACacheStore store) { this.Show(); try { m_parser.StartUpdate(store); FileStream stream = File.OpenRead(filename); m_total = m_parser.PreParseForSingle(stream, store); stream.Close(); stream = File.OpenRead(filename); m_progress = 0; m_progressCount = 0; m_timeStart = DateTime.Now; ParseFile(stream, store); stream.Close(); if (!m_parser.Cancel) { m_parser.EndUpdate(store); } } catch (Exception e) { this.Hide(); OCMApp.ShowException(e); this.Dispose(); } }
/// <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); } }