public string GetImagePath(Framework.Data.ImageSize imageSize, Framework.Data.GeocacheType geocacheType) { string result; string fn; if (imageSize == Framework.Data.ImageSize.Map) { fn = string.Format("{0}.png", geocacheType.ID); } else { fn = string.Format("{0}.gif", geocacheType.ID); } result = Path.Combine(new string[] { _baseImagePath, imageSize.ToString(), "cachetypes", fn }); if (!File.Exists(result)) { if (imageSize != Framework.Data.ImageSize.Default) { result = Path.Combine(new string[] { _baseImagePath, imageSize.ToString(), "cachetypes", fn }); if (!File.Exists(result)) { result = null; } } else { result = null; } } return(result); }
protected void addCacheType(int id, string name, string gpxTag) { Framework.Data.GeocacheType ct = new Framework.Data.GeocacheType(gpxTag); ct.ID = id; ct.Name = name; Core.GeocacheTypes.Add(ct); }
protected void addCacheType(int id, string name) { Framework.Data.GeocacheType ct = new Framework.Data.GeocacheType(); ct.ID = id; ct.Name = name; Core.GeocacheTypes.Add(ct); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Framework.Data.GeocacheType gct = value as Framework.Data.GeocacheType; if (gct != null) { return Utils.ImageSupport.Instance.GetImagePath(SimpleCacheListForm.FixedCore, Framework.Data.ImageSize.Small, gct); } return null; }
private void button17_Click(object sender, EventArgs e) { Framework.Data.GeocacheType gt = comboBoxCacheType1.SelectedItem as Framework.Data.GeocacheType; if (gt != null) { _core.Geocaches.BeginUpdate(); foreach (Framework.Data.Geocache g in _gcList) { g.GeocacheType = gt; } _core.Geocaches.EndUpdate(); } }
public static Framework.Data.GeocacheType GetGeocacheType(Framework.Data.GeocacheTypeCollection gtCollection, string keyWord, int minID) { Framework.Data.GeocacheType result = null; keyWord = keyWord.ToLower(); result = (from gt in gtCollection where gt.ID >= minID && gt.Name.ToLower().Contains(keyWord) orderby gt.ID select gt).FirstOrDefault(); if (result == null) { //take special ID result = GetGeocacheType(gtCollection, 01); } return(result); }
public static Framework.Data.GeocacheType GetGeocacheType(Framework.Data.GeocacheTypeCollection gtCollection, int typeId) { Framework.Data.GeocacheType result = null; result = (from gt in gtCollection where gt.ID == typeId select gt).FirstOrDefault(); if (result == null) { //take special ID result = (from gt in gtCollection where gt.ID == 0 select gt).FirstOrDefault(); } return(result); }
public string GetImagePath(Framework.Data.ImageSize imageSize, Framework.Data.GeocacheType geocacheType, bool corrected) { string result; string fn; if (imageSize == Framework.Data.ImageSize.Map) { fn = string.Format("{1}{0}.png", geocacheType.ID, corrected ? "c" : ""); } else { fn = string.Format("{1}{0}.gif", geocacheType.ID, corrected ? "c" : ""); } result = Path.Combine(new string[] { _baseImagePath, imageSize.ToString(), "cachetypes", fn }); if (!File.Exists(result)) { result = GetImagePath(imageSize, geocacheType); } return(result); }
public string GetImagePath(Framework.Interfaces.ICore core, Framework.Data.ImageSize imageSize, Framework.Data.GeocacheType geocacheType, bool corrected) { string result = null; foreach (Framework.Interfaces.IImageResource ir in _imageResourcePlugins) { result = ir.GetImagePath(imageSize, geocacheType, corrected); if (!string.IsNullOrEmpty(result)) { break; } } if (result == null && imageSize != Framework.Data.ImageSize.Default) { result = GetImagePath(core, Framework.Data.ImageSize.Default, geocacheType, corrected); } else if (string.IsNullOrEmpty(result)) { //select default result = GetDefaultImagePath(imageSize); } return(result); }
public Engine() { try { _settingsProvider = new SettingsProvider(null); string[] args = Environment.GetCommandLineArgs(); if (EnablePluginDataPathAtStartup || (args != null && args.Contains("/f"))) { using (SelectSettingsForm dlg = new SelectSettingsForm(this)) { _pluginDataFolderSelected = dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK; } } else { _pluginDataFolderSelected = true; } if (_pluginDataFolderSelected) { _geocachingAccountNames = new Framework.Data.GeocachingAccountNames(); var p = _settingsProvider.GetSettingsValueStringCollection("Core.GeocachingAccountNames", null); if (p != null) { foreach (string s in p) { string[] parts = s.Split("|".ToArray(), 2); if (parts.Length == 2) { _geocachingAccountNames.SetAccountName(parts[0], parts[1]); } } } _geocachingAccountNames.Changed += new Framework.EventArguments.GeocachingAccountNamesEventHandler(_geocachingAccountNames_Changed); _geocachingComAccount = new Framework.Data.GeocachingComAccountInfo(); _geocachingComAccount.AccountName = _settingsProvider.GetSettingsValue("Core.GCComAccountName", null); _geocachingComAccount.APIToken = _settingsProvider.GetSettingsValue("Core.GCComAccountToken", null); _geocachingComAccount.APITokenStaging = _settingsProvider.GetSettingsValue("Core.GCComAccountTokenStaging", null); _geocachingComAccount.MemberType = _settingsProvider.GetSettingsValue("Core.GCComAccountMemberType", null); _geocachingComAccount.MemberTypeId = _settingsProvider.GetSettingsValueInt("Core.GCComAccountMemberTypeId", 0); _geocachingComAccount.Changed += new Framework.EventArguments.GeocacheComAccountEventHandler(_geocachingComAccount_Changed); GeocachingAccountNames.SetAccountName("GC", _settingsProvider.GetSettingsValue("Core.GCComAccountName", null) ?? ""); _logs = new Framework.Data.LogCollection(); _userWaypoints = new Framework.Data.UserWaypointCollection(); _waypoints = new Framework.Data.WaypointCollection(); _geocaches = new Framework.Data.GeocacheCollection(this); _logImages = new Framework.Data.LogImageCollection(); _geocacheImages = new Framework.Data.GeocacheImageCollection(); _geocacheAttributes = new Framework.Data.GeocacheAttributeCollection(); _geocacheTypes = new Framework.Data.GeocacheTypeCollection(); _geocacheContainers = new Framework.Data.GeocacheContainerCollection(); _logTypes = new Framework.Data.LogTypeCollection(); _waypointTypes = new Framework.Data.WaypointTypeCollection(); _homeLocation = new Framework.Data.Location(); _centerLocation = new Framework.Data.Location(); _gpsLocation = new Framework.Data.GPSLocation(); _languageItems = new Framework.Data.LanguageItemCollection(); _detectedPlugins = new List<string>(); _internalStoragePlugins = new List<string>(); _selectedLanguage = System.Globalization.CultureInfo.CurrentCulture; _plugins = new List<Framework.Interfaces.IPlugin>(); _currentDomain = AppDomain.CurrentDomain; _currentDomain.AssemblyResolve += new ResolveEventHandler(LoadFromSameFolder); //set initial data //default location settings _centerLocation.SetLocation(_settingsProvider.GetSettingsValueDouble("Core.CenterLat", 51.5), _settingsProvider.GetSettingsValueDouble("Core.CenterLon", 5.5)); _centerLocation.Changed += new Framework.EventArguments.LocationEventHandler(_centerLocation_Changed); _homeLocation.SetLocation(_settingsProvider.GetSettingsValueDouble("Core.HomeLat", 51.5), _settingsProvider.GetSettingsValueDouble("Core.HomeLon", 5.5)); _homeLocation.Changed += new Framework.EventArguments.LocationEventHandler(_homeLocation_Changed); //default (unknown) cache- ,container etc. types. Position 0 means unknown Framework.Data.GeocacheType ct = new Framework.Data.GeocacheType(); ct.ID = 0; ct.Name = "Not present"; _geocacheTypes.Add(ct); Framework.Data.GeocacheAttribute attr = new Framework.Data.GeocacheAttribute(); attr.ID = 0; attr.Name = "Unknown"; _geocacheAttributes.Add(attr); Framework.Data.GeocacheContainer cont = new Framework.Data.GeocacheContainer(); cont.ID = 0; cont.Name = "Unknown"; _geocacheContainers.Add(cont); Framework.Data.LogType lt = new Framework.Data.LogType(); lt.ID = 0; lt.Name = "Unknown"; lt.AsFound = false; _logTypes.Add(lt); Framework.Data.WaypointType wpt = new Framework.Data.WaypointType(); wpt.ID = 0; wpt.Name = "Unknown"; _waypointTypes.Add(wpt); _shortcuts = new List<Framework.Data.ShortcutInfo>(); } } catch { RestoreDefaultSettings(); } }
public string GetImagePath(Framework.Data.ImageSize imageSize, Framework.Data.GeocacheType geocacheType, bool corrected) { return(null); }
public Engine() { try { _settingsProvider = new SettingsProvider(null); string[] args = Environment.GetCommandLineArgs(); if (EnablePluginDataPathAtStartup || (args != null && args.Contains("/f"))) { using (SelectSettingsForm dlg = new SelectSettingsForm(this)) { _pluginDataFolderSelected = dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK; } } else { _pluginDataFolderSelected = true; } if (_pluginDataFolderSelected) { _geocachingAccountNames = new Framework.Data.GeocachingAccountNames(); var p = _settingsProvider.GetSettingsValueStringCollection("Core.GeocachingAccountNames", null); if (p != null) { foreach (string s in p) { string[] parts = s.Split("|".ToArray(), 2); if (parts.Length == 2) { _geocachingAccountNames.SetAccountName(parts[0], parts[1]); } } } _geocachingAccountNames.Changed += new Framework.EventArguments.GeocachingAccountNamesEventHandler(_geocachingAccountNames_Changed); _geocachingComAccount = new Framework.Data.GeocachingComAccountInfo(); _geocachingComAccount.AccountName = _settingsProvider.GetSettingsValue("Core.GCComAccountName", null); _geocachingComAccount.APIToken = _settingsProvider.GetSettingsValue("Core.GCComAccountToken", null); _geocachingComAccount.APITokenStaging = _settingsProvider.GetSettingsValue("Core.GCComAccountTokenStaging", null); _geocachingComAccount.MemberType = _settingsProvider.GetSettingsValue("Core.GCComAccountMemberType", null); _geocachingComAccount.MemberTypeId = _settingsProvider.GetSettingsValueInt("Core.GCComAccountMemberTypeId", 0); _geocachingComAccount.Changed += new Framework.EventArguments.GeocacheComAccountEventHandler(_geocachingComAccount_Changed); GeocachingAccountNames.SetAccountName("GC", _settingsProvider.GetSettingsValue("Core.GCComAccountName", null) ?? ""); _logs = new Framework.Data.LogCollection(); _userWaypoints = new Framework.Data.UserWaypointCollection(); _waypoints = new Framework.Data.WaypointCollection(); _geocaches = new Framework.Data.GeocacheCollection(this); _logImages = new Framework.Data.LogImageCollection(); _geocacheImages = new Framework.Data.GeocacheImageCollection(); _geocacheAttributes = new Framework.Data.GeocacheAttributeCollection(); _geocacheTypes = new Framework.Data.GeocacheTypeCollection(); _geocacheContainers = new Framework.Data.GeocacheContainerCollection(); _logTypes = new Framework.Data.LogTypeCollection(); _waypointTypes = new Framework.Data.WaypointTypeCollection(); _homeLocation = new Framework.Data.Location(); _centerLocation = new Framework.Data.Location(); _gpsLocation = new Framework.Data.GPSLocation(); _languageItems = new Framework.Data.LanguageItemCollection(); _detectedPlugins = new List <string>(); _internalStoragePlugins = new List <string>(); _selectedLanguage = System.Globalization.CultureInfo.CurrentCulture; _plugins = new List <Framework.Interfaces.IPlugin>(); _currentDomain = AppDomain.CurrentDomain; _currentDomain.AssemblyResolve += new ResolveEventHandler(LoadFromSameFolder); //set initial data //default location settings _centerLocation.SetLocation(_settingsProvider.GetSettingsValueDouble("Core.CenterLat", 51.5), _settingsProvider.GetSettingsValueDouble("Core.CenterLon", 5.5)); _centerLocation.Changed += new Framework.EventArguments.LocationEventHandler(_centerLocation_Changed); _homeLocation.SetLocation(_settingsProvider.GetSettingsValueDouble("Core.HomeLat", 51.5), _settingsProvider.GetSettingsValueDouble("Core.HomeLon", 5.5)); _homeLocation.Changed += new Framework.EventArguments.LocationEventHandler(_homeLocation_Changed); //default (unknown) cache- ,container etc. types. Position 0 means unknown Framework.Data.GeocacheType ct = new Framework.Data.GeocacheType(); ct.ID = 0; ct.Name = "Not present"; _geocacheTypes.Add(ct); Framework.Data.GeocacheAttribute attr = new Framework.Data.GeocacheAttribute(); attr.ID = 0; attr.Name = "Unknown"; _geocacheAttributes.Add(attr); Framework.Data.GeocacheContainer cont = new Framework.Data.GeocacheContainer(); cont.ID = 0; cont.Name = "Unknown"; _geocacheContainers.Add(cont); Framework.Data.LogType lt = new Framework.Data.LogType(); lt.ID = 0; lt.Name = "Unknown"; lt.AsFound = false; _logTypes.Add(lt); Framework.Data.WaypointType wpt = new Framework.Data.WaypointType(); wpt.ID = 0; wpt.Name = "Unknown"; _waypointTypes.Add(wpt); _shortcuts = new List <Framework.Data.ShortcutInfo>(); } } catch { RestoreDefaultSettings(); } }
private bool addGeocaches(Utils.ProgressBlock progress, List <Framework.Data.Geocache> gcList, List <Framework.Data.GeocacheType> typeList, XmlDocument doc, XmlElement rootDoc, string folderName, string tempFolder, List <string> fileList) { bool result = true; // //folder XmlElement folder = doc.CreateElement("Folder"); rootDoc.AppendChild(folder); XmlElement el = doc.CreateElement("name"); XmlText txt = doc.CreateTextNode(Utils.LanguageSupport.Instance.GetTranslation(folderName)); el.AppendChild(txt); folder.AppendChild(el); foreach (Framework.Data.Geocache g in gcList) { //check if style exists Framework.Data.GeocacheType gt = g.GeocacheType; string imgIcon = Utils.ImageSupport.Instance.GetImagePath(Core, Framework.Data.ImageSize.Default, gt); string destImg = Path.Combine(tempFolder, Path.GetFileName(imgIcon)); if (!typeList.Contains(gt)) { typeList.Add(gt); string mapIcon = Utils.ImageSupport.Instance.GetImagePath(Core, Framework.Data.ImageSize.Map, gt); string destFile = Path.Combine(tempFolder, Path.GetFileName(mapIcon)); string mapIconC = Utils.ImageSupport.Instance.GetImagePath(Core, Framework.Data.ImageSize.Map, gt, true); string destFileC = Path.Combine(tempFolder, Path.GetFileName(mapIconC)); if (!File.Exists(destFile)) { File.Copy(mapIcon, destFile); } if (!File.Exists(destFileC)) { File.Copy(mapIconC, destFileC); } if (!File.Exists(destImg)) { File.Copy(imgIcon, destImg); } if (!fileList.Contains(destFile)) { fileList.Add(destFile); } if (!fileList.Contains(destFileC)) { fileList.Add(destFileC); } if (!fileList.Contains(destImg)) { fileList.Add(destImg); } //adding style /* * <Style id="TNA"> * <IconStyle id="iconTNA"> * <scale>1</scale> * <Icon> * <href>http://hulmgulm.de/gc/myGoogleEarth/mrk_traditional.png</href> * </Icon> * </IconStyle> * <LabelStyle id="labelTNA"> * <scale>1</scale> * </LabelStyle> * </Style> */ XmlElement style = doc.CreateElement("Style"); rootDoc.AppendChild(style); XmlAttribute attr = doc.CreateAttribute("id"); txt = doc.CreateTextNode(string.Format("id{0}", gt.ID)); attr.AppendChild(txt); style.Attributes.Append(attr); XmlElement iconstyle = doc.CreateElement("IconStyle"); style.AppendChild(iconstyle); attr = doc.CreateAttribute("id"); txt = doc.CreateTextNode(string.Format("iconid{0}", gt.ID)); attr.AppendChild(txt); iconstyle.Attributes.Append(attr); el = doc.CreateElement("scale"); txt = doc.CreateTextNode("1"); el.AppendChild(txt); iconstyle.AppendChild(el); XmlElement icon = doc.CreateElement("Icon"); iconstyle.AppendChild(icon); el = doc.CreateElement("href"); txt = doc.CreateTextNode(string.Format("Images/{0}", Path.GetFileName(mapIcon))); el.AppendChild(txt); icon.AppendChild(el); XmlElement labelstyle = doc.CreateElement("LabelStyle"); style.AppendChild(labelstyle); attr = doc.CreateAttribute("id"); txt = doc.CreateTextNode(string.Format("labelid{0}", gt.ID)); attr.AppendChild(txt); labelstyle.Attributes.Append(attr); el = doc.CreateElement("scale"); txt = doc.CreateTextNode("1"); el.AppendChild(txt); labelstyle.AppendChild(el); // //corrected // style = doc.CreateElement("Style"); rootDoc.AppendChild(style); attr = doc.CreateAttribute("id"); txt = doc.CreateTextNode(string.Format("idC{0}", gt.ID)); attr.AppendChild(txt); style.Attributes.Append(attr); iconstyle = doc.CreateElement("IconStyle"); style.AppendChild(iconstyle); attr = doc.CreateAttribute("id"); txt = doc.CreateTextNode(string.Format("iconidC{0}", gt.ID)); attr.AppendChild(txt); iconstyle.Attributes.Append(attr); el = doc.CreateElement("scale"); txt = doc.CreateTextNode("1"); el.AppendChild(txt); iconstyle.AppendChild(el); icon = doc.CreateElement("Icon"); iconstyle.AppendChild(icon); el = doc.CreateElement("href"); txt = doc.CreateTextNode(string.Format("Images/{0}", Path.GetFileName(mapIconC))); el.AppendChild(txt); icon.AppendChild(el); labelstyle = doc.CreateElement("LabelStyle"); style.AppendChild(labelstyle); attr = doc.CreateAttribute("id"); txt = doc.CreateTextNode(string.Format("labelidC{0}", gt.ID)); attr.AppendChild(txt); labelstyle.Attributes.Append(attr); el = doc.CreateElement("scale"); txt = doc.CreateTextNode("1"); el.AppendChild(txt); labelstyle.AppendChild(el); } XmlElement placemark = doc.CreateElement("Placemark"); folder.AppendChild(placemark); el = doc.CreateElement("name"); txt = doc.CreateTextNode(g.Name ?? ""); el.AppendChild(txt); placemark.AppendChild(el); el = doc.CreateElement("styleUrl"); if (g.ContainsCustomLatLon) { txt = doc.CreateTextNode(string.Format("#idC{0}", gt.ID)); } else { txt = doc.CreateTextNode(string.Format("#id{0}", gt.ID)); } el.AppendChild(txt); placemark.AppendChild(el); el = doc.CreateElement("description"); string descr = string.Format("<table width='250'><tr><td align='center'><a href='{0}'>{1}</a><br><font size='4'><b>{2}</b></font><br /><i>{3} {4}</i><br /><br /><img src='Images/{5}' /> <br /><br />{6}: {7}<br />{8}: {9}<br />{10}: {11}<br /><br />({12})<br><br></td></tr></table>", g.Url, g.Code, g.Name ?? "", HttpUtility.HtmlEncode(Utils.LanguageSupport.Instance.GetTranslation(STR_BY)), g.Owner ?? "", Path.GetFileName(destImg), HttpUtility.HtmlEncode(Utils.LanguageSupport.Instance.GetTranslation(STR_DIFFICULTY)), g.Difficulty.ToString("0.#"), HttpUtility.HtmlEncode(Utils.LanguageSupport.Instance.GetTranslation(STR_TERRAIN)), g.Terrain.ToString("0.#"), HttpUtility.HtmlEncode(Utils.LanguageSupport.Instance.GetTranslation(STR_CONTAINER)), HttpUtility.HtmlEncode(Utils.LanguageSupport.Instance.GetTranslation(g.Container.Name)), Utils.Conversion.GetCoordinatesPresentation(g.Lat, g.Lon)); txt = doc.CreateTextNode(descr); el.AppendChild(txt); placemark.AppendChild(el); el = doc.CreateElement("Snippet"); txt = doc.CreateTextNode(string.Format("<a href='{0}'>{1}</a> {2}<br>{3} {4}", g.Url, g.Code, g.Name ?? "", Utils.LanguageSupport.Instance.GetTranslation(STR_BY), g.Owner ?? "")); el.AppendChild(txt); placemark.AppendChild(el); XmlElement point = doc.CreateElement("Point"); placemark.AppendChild(point); el = doc.CreateElement("coordinates"); if (g.ContainsCustomLatLon) { txt = doc.CreateTextNode(string.Format("{0},{1}", g.CustomLon.ToString().Replace(',', '.'), g.CustomLat.ToString().Replace(',', '.'))); } else { txt = doc.CreateTextNode(string.Format("{0},{1}", g.Lon.ToString().Replace(',', '.'), g.Lat.ToString().Replace(',', '.'))); } el.AppendChild(txt); point.AppendChild(el); _indexDone++; if (_indexDone % 100 == 0) { if (!progress.UpdateProgress(STR_EXPORTINGGPX, STR_CREATINGFILE, _gcList.Count, _indexDone)) { result = false; break; } } } return(result); }