public ExportProgressDialog(GPXWriter writer) { this.Build(); writer.WriteWaypoint += HandleWriterWriteWaypoint; writer.Complete += HandleWriterComplete; m_writer = writer; }
public void RunCommand(OCMMainWindow win) { string cmd = m_command; if (cmd.Contains("%gpxgc%")) { GPXWriter writer = new GPXWriter(); String tempPath = System.IO.Path.GetTempPath(); String tempFile = tempPath + "ocm_export.gpx"; ExportProgressDialog dlg = new ExportProgressDialog(writer); dlg.AutoClose = true; dlg.Title = Catalog.GetString("Preparing GPX File"); dlg.WaypointsOnly = false; dlg.CompleteCommand = m_command.Replace("%gpxgc%", tempFile); dlg.Start(tempFile, win.CacheList.UnfilteredCaches, GPSProfileList.GetDefaultMappings(), win.App.CacheStore); } else if (cmd.Contains("%gpx%")) { GPXWriter writer = new GPXWriter(); String tempPath = System.IO.Path.GetTempPath(); String tempFile = tempPath + "ocm_export.gpx"; ExportProgressDialog dlg = new ExportProgressDialog(writer); dlg.AutoClose = true; dlg.Title = Catalog.GetString("Preparing GPX File"); dlg.WaypointsOnly = true; dlg.CompleteCommand = m_command.Replace("%gpx%", tempFile); dlg.Start(tempFile, win.CacheList.UnfilteredCaches, GPSProfileList.GetDefaultMappings(), win.App.CacheStore); } else if (cmd.Contains("%selected%")) { if (win.CacheList.SelectedCache == null) { MessageDialog edlg = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, Catalog.GetString("No cache selected.")); edlg.Run(); edlg.Hide(); edlg.Dispose(); return; } GPXWriter writer = new GPXWriter(); String tempPath = System.IO.Path.GetTempPath(); String tempFile = tempPath + "ocm_export.gpx"; ExportProgressDialog dlg = new ExportProgressDialog(writer); dlg.AutoClose = true; dlg.Title = Catalog.GetString("Preparing GPX File"); dlg.WaypointsOnly = true; dlg.CompleteCommand = m_command.Replace("%selected%", tempFile); List <Geocache> cache = new List <Geocache>(); cache.Add(win.CacheList.SelectedCache); dlg.Start(tempFile, cache, GPSProfileList.GetDefaultMappings(), win.App.CacheStore); } else if (cmd.Contains("%names%") && win.CacheList.UnfilteredCaches.Count > 0) { String names = ""; foreach (Geocache cache in win.CacheList.UnfilteredCaches) { if (names.Length > 0) { names += ' '; } names += cache.Name; } Process.Start(Utilities.StringToStartInfo(cmd.Replace("%names%", names))); } else if (cmd.Contains("%selectedname%")) { if (win.CacheList.SelectedCache == null) { MessageDialog edlg = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, Catalog.GetString("No cache selected.")); edlg.Run(); edlg.Hide(); edlg.Dispose(); return; } Process.Start(Utilities.StringToStartInfo(cmd.Replace("%selectedname%", win.CacheList.SelectedCache.Name))); } else if (cmd.Contains("%finds%")) { GPXWriter writer = new GPXWriter(); writer.IsMyFinds = true; writer.MyFindsOwner = win.App.OwnerIDs[0]; String tempPath = System.IO.Path.GetTempPath(); String tempFile = tempPath + "ocm_finds.gpx"; ExportProgressDialog dlg = new ExportProgressDialog(writer); dlg.AutoClose = true; dlg.Title = Catalog.GetString("Preparing GPX File"); dlg.WaypointsOnly = true; dlg.CompleteCommand = m_command.Replace("%finds%", tempFile); //dlg.Start(tempFile, Engine.getInstance().Store.GetFinds(), GPSProfileList.GetDefaultMappings(), mon.CacheStore); } else { Process.Start(Utilities.StringToStartInfo(m_command)); } }