public bool OnBeforeBrowse(IWebBrowser browser, IRequest request, bool isRedirect) { if (request.Url.ToLower() != "http://www.google.com/") { try { if (PluginSettings.Instance.OpenInInternalBrowser) { _parent.BeginInvoke((Action)(() => { Utils.BasePlugin.Plugin p = Utils.PluginSupport.PluginByName(_core, "GlobalcachingApplication.Plugins.Browser.BrowserPlugin") as Utils.BasePlugin.Plugin; if (p != null) { var m = p.GetType().GetMethod("OpenNewBrowser"); m.Invoke(p, new object[] { request.Url.ToString() }); } })); } else { System.Diagnostics.Process.Start(request.Url.ToString()); } return(true); } catch { } } return(false); }
void importButton_Click(object sender, EventArgs e) { try { string name = null; HtmlElement el = Browser.Document.GetElementById("ctl00_ContentBody_lbHeading"); if (el != null && Browser.Url != null) { name = el.InnerText.Trim(); string url = Browser.Url.OriginalString; var m = _bookmarkImportPlugin.GetType().GetMethod("ImportBookmark"); m.Invoke(_bookmarkImportPlugin, new object[] { name, url }); } } catch { } }
public async override Task <bool> ActionAsync(string action) { bool result = base.Action(action); if (result) { if (action == ACTION_EXPORT_ALL || action == ACTION_EXPORT_SELECTED || action == ACTION_EXPORT_ACTIVE) { if (action == ACTION_EXPORT_ALL) { _gcList = (from Framework.Data.Geocache a in Core.Geocaches select a).ToList(); } else if (action == ACTION_EXPORT_SELECTED) { _gcList = Utils.DataAccess.GetSelectedGeocaches(Core.Geocaches); } else { if (Core.ActiveGeocache != null) { _gcList = new List <Framework.Data.Geocache>(); _gcList.Add(Core.ActiveGeocache); } } if (_gcList == null || _gcList.Count == 0) { System.Windows.Forms.MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_NOGEOCACHESELECTED), Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } else { using (SelectDeviceForm dlg = new SelectDeviceForm()) { if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (PluginSettings.Instance.CreateGGZFile) { Utils.BasePlugin.Plugin p = Utils.PluginSupport.PluginByName(Core, "GlobalcachingApplication.Plugins.ExportGPX.GgzExport") as Utils.BasePlugin.Plugin; if (p != null) { var m = p.GetType().GetMethod("ExportToGGZ"); if (m != null) { Utils.GPXGenerator gpxGenerator = new Utils.GPXGenerator(Core, _gcList, string.IsNullOrEmpty(PluginSettings.Instance.GPXVersionStr) ? Utils.GPXGenerator.V101 : Version.Parse(PluginSettings.Instance.GPXVersionStr)); gpxGenerator.UseNameForGCCode = _useName; gpxGenerator.AddAdditionWaypointsToDescription = PluginSettings.Instance.AddWaypointsToDescription; gpxGenerator.UseHintsForDescription = PluginSettings.Instance.UseHintsForDescription; gpxGenerator.AddFieldnotesToDescription = PluginSettings.Instance.AddFieldNotesToDescription; gpxGenerator.MaxNameLength = PluginSettings.Instance.MaxGeocacheNameLength; gpxGenerator.MinStartOfname = PluginSettings.Instance.MinStartOfGeocacheName; gpxGenerator.ExtraCoordPrefix = PluginSettings.Instance.CorrectedNamePrefix; gpxGenerator.AddExtraInfoToDescription = PluginSettings.Instance.AddExtraInfoToDescription; gpxGenerator.MaxLogCount = PluginSettings.Instance.MaximumNumberOfLogs; string filename = "geocaches.ggz"; if (PluginSettings.Instance.UseDatabaseNameForFileName) { Framework.Interfaces.IPluginInternalStorage storage = (from Framework.Interfaces.IPluginInternalStorage a in Core.GetPlugin(Framework.PluginType.InternalStorage) select a).FirstOrDefault(); if (storage != null) { var si = storage.ActiveStorageDestination; if (si != null) { string s = storage.ActiveStorageDestination.Name; int pos = s.LastIndexOf('.'); if (pos < 0) { filename = string.Format("{0}.ggz", s); } else { filename = string.Format("{0}.ggz", s.Substring(0, pos)); } } } } try { if (!System.IO.Directory.Exists(System.IO.Path.Combine(new string[] { dlg.SelectedDrive, "garmin", "ggz" }))) { System.IO.Directory.CreateDirectory(System.IO.Path.Combine(new string[] { dlg.SelectedDrive, "garmin", "ggz" })); } } catch { } m.Invoke(p, new object[] { System.IO.Path.Combine(new string[] { dlg.SelectedDrive, "garmin", "ggz", filename }), _gcList, gpxGenerator }); } } } else { _oneGeocachePerFile = !dlg.SeperateFilePerGeocache; _drive = dlg.SelectedDrive; _addChildWaypoints = dlg.AddChildWaypoints; _useName = dlg.UseName; if (!string.IsNullOrEmpty(_drive)) { await PerformExport(); } } if (PluginSettings.Instance.AddImages) { Utils.BasePlugin.Plugin p = Utils.PluginSupport.PluginByName(Core, "GlobalcachingApplication.Plugins.ImgGrab.ImageGrabber") as Utils.BasePlugin.Plugin; if (p != null) { var m = p.GetType().GetMethod("CreateImageFolderForGeocaches"); if (m != null) { m.Invoke(p, new object[] { _gcList, System.IO.Path.Combine(new string[] { dlg.SelectedDrive, "garmin" }) }); } } } } } } } } return(result); }