// closest is SortedList of string (name) by key=double (distance meters) public DlgFavoritesAddTo(CamPos camPos, SortedList closest, MenuItem parentMenuItem, EventHandler eventHandler) { m_camPos = camPos; m_parentMenuItem = parentMenuItem; m_eventHandler = eventHandler; InitializeComponent(); GeoCoord loc = new GeoCoord(m_camPos); Distance camHD = new Distance(m_camPos.H); int unitsCompl = camHD.UnitsCompl; locationLabel.Text = "Location: " + loc.ToString() + " / Camera at " + camHD.ToString(unitsCompl); nameComboBox.Text = m_camPos.Name; for(int i=0; i < closest.Count && i < 20 ;i++) { string name = ((LiveObject)closest.GetByIndex(i)).Name; nameComboBox.Items.Add(name); } Project.setDlgIcon(this); }
public GeoCoord(CamPos camPos) { m_X = camPos.Lng; m_Y = camPos.Lat; m_H = camPos.Elev; }
private static void AddFavOption(XmlDocument xmlDoc, XmlNode favNode, CamPos camPos) { XmlNode node = xmlDoc.CreateElement("campos"); node.InnerText = camPos.Name; XmlAttribute attr = xmlDoc.CreateAttribute("lon"); attr.InnerText = "" + camPos.Lng; node.Attributes.Append(attr); attr = xmlDoc.CreateAttribute("lat"); attr.InnerText = "" + camPos.Lat; node.Attributes.Append(attr); attr = xmlDoc.CreateAttribute("elev"); attr.InnerText = "" + camPos.Elev; node.Attributes.Append(attr); attr = xmlDoc.CreateAttribute("type"); attr.InnerText = "" + camPos.Type; node.Attributes.Append(attr); favNode.AppendChild(node); }
public static void ReadOptions() { bool favoritesDirty = false; string optionsFilePath = GetMiscPath(OPTIONS_FILE_NAME); #if DEBUG LibSys.StatusBar.Trace("IP: Project:ReadOptions() path=" + optionsFilePath); #endif DateTime startedRead = DateTime.Now; try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(optionsFilePath); // we want to traverse XmlDocument fast, as tile load operations can be numerous // and come in pack. So we avoid using XPath and rely mostly on "foreach child": foreach(XmlNode nnode in xmlDoc.ChildNodes) { if(nnode.Name.Equals("options")) { foreach(XmlNode node in nnode.ChildNodes) { string nodeName = node.Name; try { if(nodeName.Equals("cameraLat")) { cameraLat = Convert.ToDouble(node.InnerText); } else if(nodeName.Equals("cameraLng")) { cameraLng = Convert.ToDouble(node.InnerText); } else if(nodeName.Equals("cameraElev")) { cameraElev = Convert.ToDouble(node.InnerText); } #if DEBUG else if(nodeName.Equals("enableTrace")) { enableTrace = node.InnerText.ToLower().Equals("true"); } #endif else if(nodeName.Equals("mappingCacheLocation")) { mappingCacheLocation = node.InnerText; } else if(nodeName.Equals("gpsMakeIndex")) { gpsMakeIndex = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("gpsModelIndex")) { gpsModelIndex = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("gpsInterfaceIndex")) { gpsInterfaceIndex = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("gpsRtToleranceIndex")) { gpsRtToleranceIndex = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("gpsMaxPointsPerRoute")) { gpsMaxPointsPerRoute = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("gpsMagellanRouteNameConversionMethod")) { gpsMagellanRouteNameConversionMethod = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("mainFormWidth")) { mainFormWidth = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("mainFormHeight")) { mainFormHeight = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("mainFormX")) { mainFormX = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("mainFormY")) { mainFormY = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("mainFormMaximized")) { mainFormMaximized = "true".Equals(node.InnerText.ToLower()); } else if(nodeName.Equals("wptManagerWidth")) { wptManagerWidth = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("wptManagerHeight")) { wptManagerHeight = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("cmManagerWidth")) { cmManagerWidth = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("cmManagerHeight")) { cmManagerHeight = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("symbolColWidth")) { symbolColWidth = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("nameColWidth")) { nameColWidth = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("nameColWidthCm")) { nameColWidthCm = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("urlNameColWidth")) { urlNameColWidth = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("descColWidth")) { descColWidth = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("descColWidthCm")) { descColWidthCm = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("sourceColWidthCm")) { sourceColWidthCm = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("commentColWidth")) { commentColWidth = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("eqManagerWidth")) { eqManagerWidth = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("eqManagerHeight")) { eqManagerHeight = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("photoFullSizeWidth")) { photoFullSizeWidth = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("photoFullSizeHeight")) { photoFullSizeHeight = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("photoFullSizeX")) { photoFullSizeX = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("photoFullSizeY")) { photoFullSizeY = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("photoManagerDlgWidth")) { photoManagerWidth = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("photoManagerDlgHeight")) { photoManagerHeight = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("photoManagerDlgX")) { photoManagerX = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("photoManagerDlgY")) { photoManagerY = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("pmLastTabMode")) { pmLastTabMode = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("preloadDoProgress")) { preloadDoProgress = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("preloadScale1")) { preloadScale1 = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("preloadScale2")) { preloadScale2 = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("pdaExportDoAerial")) { pdaExportDoAerial = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("pdaExportDoTopo")) { pdaExportDoTopo = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("pdaExportDoColor")) { pdaExportDoColor = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("kmlShowInPopup")) { kmlOptions.kmlShowInPopup = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("kmlWptsClampToGround")) { kmlOptions.kmlWptsClampToGround = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("kmlTrksClampToGround")) { kmlOptions.kmlTrksClampToGround = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("fileInitialDirectory")) { fileInitialDirectory = node.InnerText; } else if(nodeName.Equals("imageInitialDirectory")) { imageInitialDirectory = node.InnerText; } else if(nodeName.Equals("photoSaveInitialDirectory")) { photoSaveInitialDirectory = node.InnerText; } else if(nodeName.Equals("pdaInitialDirectory")) { pdaInitialDirectory = node.InnerText; } else if(nodeName.Equals("exportDestFolder")) { exportDestFolder = node.InnerText; } else if(nodeName.Equals("pdaWellDiagonale")) { pdaWellDiagonale = Convert.ToDouble(node.InnerText); } else if(nodeName.Equals("pdaExportImageFormat")) { pdaExportImageFormat = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("pdaExportUseWebsafeGrayscalePalette")) { pdaExportUseWebsafeGrayscalePalette = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("pdaExportWrapPdb")) { pdaExportWrapPdb = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("findKeyword")) { findKeyword = node.InnerText; } else if (nodeName.Equals("zipcode")) { zipcode = node.InnerText; } else if (nodeName.Equals("waypointNameStyle")) { waypointNameStyle = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("trackNameStyle")) { trackNameStyle = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("earthquakeStyle")) { earthquakeStyle = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("printTextFont")) { printTextFont = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("mouseWheelAction")) { mouseWheelAction = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("distortionFactor")) { distortionFactor = Convert.ToDouble(node.InnerText); } else if(nodeName.Equals("cameraHeightMin")) { cameraHeightMin = Convert.ToDouble(node.InnerText); } else if(nodeName.Equals("coordStyle")) { coordStyle = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("unitsDistance")) { unitsDistance = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("earthquakeStyleFillHowRecentIndex")) { earthquakeStyleFillHowRecentIndex = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("allowMapPopups")) { allowMapPopups = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("drawRelief")) { drawRelief = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("serverMessageLast")) { serverMessageLast = node.InnerText; } else if(nodeName.Equals("drawGrid")) { drawGrid = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("drawCentralPoint")) { drawCentralPoint = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("drawCornerArrows")) { drawCornerArrows = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("drawCities")) { drawCities = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("drawLandmarks")) { drawLandmarks = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("drawEarthquakes")) { drawEarthquakes = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("drawWaypoints")) { drawWaypoints = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("drawTrackpoints")) { drawTrackpoints = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("useWaypointIcons")) { useWaypointIcons = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("showHelpAtStart")) { showHelpAtStart = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("gpsWptDescrAsName")) { gpsWptDescrAsName = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("gpsVehicleIcon")) { gpsVehicleIcon = node.InnerText; } else if(nodeName.Equals("showTrackpointNumbers")) { showTrackpointNumbers = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("drawVehicles")) { drawVehicles = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("eqUseOldData")) { eqUseOldData = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("eqFetchOnStart")) { eqFetchOnStart = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("earthquakeStyleFillRecent")) { earthquakeStyleFillRecent = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("terraserverUseServices")) { terraserverUseServices = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("sanityFilter")) { sanityFilter = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("gpsRtTrackOnMap")) { gpsRtTrackOnMap = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("gpsZoomIntoTracks")) { gpsZoomIntoTracks = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("gpsRtTrackLog")) { gpsRtTrackLog = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("gpsRtKeepInView")) { gpsRtKeepInView = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("gpsMagellanHandshake")) { gpsMagellanHandshake = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("terraLayerOpacity")) { terraLayerOpacity = Convert.ToDouble(node.InnerText); // protect from "disappearing aerial", when transparency goes to 0: if(terraLayerOpacity < 0.5d || terraLayerOpacity > 1.0d) { terraLayerOpacity = 0.5d; } } else if(nodeName.Equals("terraLayerOpacity2")) { terraLayerOpacity2 = Convert.ToDouble(node.InnerText); // protect from "disappearing aerial", when transparency goes to 0: if(terraLayerOpacity2 < 0.15d || terraLayerOpacity2 > 1.0d) { terraLayerOpacity2 = 0.5d; } } else if(nodeName.Equals("terraLayerOpacity3")) { terraLayerOpacity3 = Convert.ToDouble(node.InnerText); // protect from "disappearing aerial", when transparency goes to 0: if(terraLayerOpacity3 < 0.25d || terraLayerOpacity3 > 1.0d) { terraLayerOpacity3 = 1.0d; } } else if(nodeName.Equals("terraUseOverlay")) { //terraUseOverlay = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("breakTimeMinutes")) { breakTimeMinutes = Convert.ToDouble(node.InnerText); } else if(nodeName.Equals("drawTerraserver")) { drawTerraserver = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("makeWhitishTransparent")) { makeWhitishTransparent = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("drawTerraserverMode")) { drawTerraserverMode = node.InnerText; } else if(nodeName.Equals("photoGalleryPictureSize")) { photoGalleryPictureSize = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("photoFolderPath")) { photoFolderPath = node.InnerText; } else if(nodeName.Equals("photoTimeShiftYourCamera")) { long ticks = Convert.ToInt64(node.InnerText); photoTimeShiftYourCamera = new TimeSpan(ticks); } else if(nodeName.Equals("photoTimeZoneIdYourCamera")) { photoTimeZoneIdYourCamera = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("photoTimeZoneIdFile")) { photoTimeZoneIdFile = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("photoTimeZoneIdTemp")) { photoTimeZoneIdTemp = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("togeotiffFolderPath")) { togeotiffFolderPath = node.InnerText; } else if(nodeName.Equals("togeotiffFileName")) { togeotiffFileName = node.InnerText; } else if(nodeName.Equals("photoFileName")) { photoFileName = node.InnerText; } else if(nodeName.Equals("photoAnalyzeOnLoad")) { photoAnalyzeOnLoad = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("photoAnalyzeOnLoadReminder")) { photoAnalyzeOnLoadReminder = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("photoDoPreview")) { photoDoPreview = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("thumbDoDisplay")) { thumbDoDisplay = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("thumbWidth")) { thumbWidth = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("thumbHeight")) { thumbHeight = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("thumbPosition")) { thumbPosition = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("photoPreserveSize")) { photoPreserveSize = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("photoFitToSize")) { photoFitToSize = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("photoSaveQuality")) { photoSaveQuality = Convert.ToInt64(node.InnerText.Trim()); } else if(nodeName.Equals("useProxy")) { useProxy = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("suspendKeepAlive")) { suspendKeepAlive = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("forceEmptyProxy")) { forceEmptyProxy = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("proxyServer")) { proxyServer = node.InnerText; } else if(nodeName.Equals("proxyPort")) { proxyPort = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("webTimeoutMs")) { webTimeoutMs = Convert.ToInt32(node.InnerText); } else if(nodeName.Equals("geocachingLogin")) { geocachingLogin = node.InnerText; } else if(nodeName.Equals("penTrackThickness")) { TrackPalette.penTrackThickness = (float)Convert.ToDouble(node.InnerText); } else if(nodeName.Equals("penRouteThickness")) { TrackPalette.penRouteThickness = (float)Convert.ToDouble(node.InnerText); } else if(nodeName.Equals("webPageTemplate")) { webPageTemplate = node.InnerText; } else if(nodeName.Equals("webPageDestinationFolder")) { webPageDestinationFolder = node.InnerText; } else if(nodeName.Equals("webPagePhotoStorageUrlBase")) { webPagePhotoStorageUrlBase = node.InnerText; } else if(nodeName.Equals("webPageLinksUsePopup")) { webPageLinksUsePopup = node.InnerText.ToLower().Equals("true"); } else if(nodeName.Equals("trackPalette")) { int i = 0; foreach(XmlNode nnnode in node.ChildNodes) { try { string sRGB = nnnode.InnerText; string[] split = sRGB.Split(new Char[] {','}); int r = Convert.ToInt32(split[0]); int g = Convert.ToInt32(split[1]); int b = Convert.ToInt32(split[2]); Color color = Color.FromArgb(r, g, b); TrackPalette.setColor(i, color); } catch {} i++; } } else if(nodeName.Equals("fileDescrList")) { foreach(XmlNode nnnode in node.ChildNodes) { string filename = nnnode.Attributes.GetNamedItem("path").InnerText.Trim(); string formatName = nnnode.Attributes.GetNamedItem("format").InnerText; FormattedFileDescr ffd = new FormattedFileDescr(filename, formatName, true); Project.FileDescrList.Add(ffd); } } else if(nodeName.Equals("favorites")) { // this is here only for backwards compatibility. It takes favorites from options.xml // there is no save block back to options.xml, favorites go into favorites.xml now foreach(XmlNode nnnode in node.ChildNodes) { string name = nnnode.InnerText; string sLng = nnnode.Attributes.GetNamedItem("lon").InnerText; string sLat = nnnode.Attributes.GetNamedItem("lat").InnerText; string sElev = nnnode.Attributes.GetNamedItem("elev").InnerText; XmlNode tNode = nnnode.Attributes.GetNamedItem("type"); string type = tNode == null ? "aerial" : tNode.InnerText.Trim(); double lng = Convert.ToDouble(sLng); double lat = Convert.ToDouble(sLat); double elev = Convert.ToDouble(sElev); CamPos camPos = new CamPos(lng, lat, elev, name, type); Project.favorites.Add(camPos); favoritesDirty = true; // provoke SaveFavorites into favorites.xml } } else if(nodeName.Equals("recentFiles")) { foreach(XmlNode nnnode in node.ChildNodes) { string filename = nnnode.Attributes.GetNamedItem("path").InnerText.Trim(); filename = Project.GetLongPathName(filename); FileInfo fi = new FileInfo(filename); if(fi.Exists) { Project.recentFiles.Add(filename); } else { DirectoryInfo di = new DirectoryInfo(filename); if(di.Exists) { Project.recentFiles.Add(filename); } } } } } catch (Exception ee) { // bad node - not a big deal... LibSys.StatusBar.Error("Project:ReadOptions() node=" + nodeName + " " + ee.Message); } } } } } catch (Exception e) { LibSys.StatusBar.Error("Project:ReadOptions() " + e.Message); } LibSys.StatusBar.Trace("ReadOptions: " + Math.Round((DateTime.Now - startedRead).TotalMilliseconds) + " ms"); // restore gpsPortSettings from the file or fill it with default values: restoreOrDefaultGpsSettings(); if(cameraHeightMin < 0.04d || cameraHeightMin > CAMERA_HEIGHT_MIN_DEFAULT) { cameraHeightMin = CAMERA_HEIGHT_MIN_DEFAULT; } if(cameraElev < cameraHeightMin * 1000.0d || cameraElev > CAMERA_HEIGHT_MAX * 1000.0d) { cameraElev = CAMERA_HEIGHT_SAFE * 1000.0d; } // restore Tools from the file or fill it with default values: string toolsFilePath = GetMiscPath(TOOLS_FILE_NAME); Project.tools.Restore(toolsFilePath); if(favoritesDirty) { LibSys.StatusBar.Trace("ReadOptions: saving favorites"); SaveFavorites(); // in case the old format was read in SaveOptions(); // without the favorites part } else { ReadFavorites(); } LibSys.StatusBar.Trace("ReadOptions: finished in " + Math.Round((DateTime.Now - startedRead).TotalMilliseconds) + " ms"); }
public static void ReadFavorites() { string favoritesFilePath = GetMiscPath(FAVORITES_FILE_NAME); #if DEBUG LibSys.StatusBar.Trace("IP: Project:ReadFavorites() path=" + favoritesFilePath); #endif try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(favoritesFilePath); // we want to traverse XmlDocument fast, as tile load operations can be numerous // and come in pack. So we avoid using XPath and rely mostly on "foreach child": foreach(XmlNode nnode in xmlDoc.ChildNodes) { if(nnode.Name.Equals("favorites")) { foreach(XmlNode node in nnode.ChildNodes) { string nodeName = node.Name; try { if(nodeName.Equals("favorites")) { foreach(XmlNode nnnode in node.ChildNodes) { string name = nnnode.InnerText; string sLng = nnnode.Attributes.GetNamedItem("lon").InnerText; string sLat = nnnode.Attributes.GetNamedItem("lat").InnerText; string sElev = nnnode.Attributes.GetNamedItem("elev").InnerText; XmlNode tNode = nnnode.Attributes.GetNamedItem("type"); string type = tNode == null ? "aerial" : tNode.InnerText.Trim(); double lng = Convert.ToDouble(sLng); double lat = Convert.ToDouble(sLat); double elev = Convert.ToDouble(sElev); CamPos camPos = new CamPos(lng, lat, elev, name, type); Project.favorites.Add(camPos); } } } catch (Exception ee) { // bad node - not a big deal... LibSys.StatusBar.Error("Project:ReadFavorites() node=" + nodeName + " " + ee.Message); } } } } } catch (Exception e) { LibSys.StatusBar.Error("Project:ReadFavorites() " + e.Message); } if(Project.favorites.Count <= 1) { // something may have gone wrong with the favorites, repopulate. EnsureFavorites(); } }
// special case that doesn't require KmlDocument: public static void runGoogleEarthAtPoint(CamPos campos, string name, string labelHtml) { double camElev = campos.Elev; // meters double tilt = 0.0d; // 0.0 - looking straight down, 90.0 - along the surface double heading = 0.0d; // 0.0 - map is North up 90.0 - East up int visibility = 0; // 0 - label not visible, 1 - visible string kmlPoint = String.Format(kmlPointFmt, name, labelHtml, campos.Lng, campos.Lat, camElev, tilt, heading, visibility); runKml(kmlPoint); }
private void DlgFavoritesOrganize_Closing(object sender, System.ComponentModel.CancelEventArgs e) { // rebuild the Project.favorites list: Project.favorites.Clear(); foreach(DataRow row in favoritesDataSet.Tables["favoritesTable"].Rows) { try { if(row.RowState != DataRowState.Deleted) { string type = (string)row["type"]; string name = (string)row["name"]; double lat = (double)row["lat"]; double lng = (double)row["lng"]; double elev = (double)row["elev"]; CamPos camPos = new CamPos(lng, lat, elev, name, type); Project.favorites.Add(camPos); } } catch { } } }
private void goButton_Click(object sender, System.EventArgs e) { GeoCoord location = TileCache.ZipcodeServer.getCoord(placesListBox); if(location != null) { Cursor.Current = Cursors.WaitCursor; m_cameraManager.SpoilPicture(); m_cameraManager.Location = location; Cursor.Current = Cursors.Default; if(m_firstTime) { // first time, make this point a home in favorites: CamPos camPos = new CamPos(location.Lng, location.Lat, location.Elev); camPos.Name = "Home - " + placesListBox.SelectedItem; if(Project.favorites.Count > 0) { Project.favorites.Insert(0, camPos); Project.SaveFavorites(); } else { Project.favorites.Add(camPos); Project.EnsureFavorites(); } } this.Close(); } else if(m_firstTime) { this.Close(); } }
private void addToFavoritesMenuItem_Click(object sender, System.EventArgs e) { CamPos camPos = new CamPos(m_cameraManager.Location.Lng, m_cameraManager.Location.Lat, m_cameraManager.Location.Elev); string name = "new item - " + this.favMainMenuItem.MenuItems.Count; // try to be smart with the new name, get the closest waypoint or city name: double searchRadius = m_cameraManager.Location.Elev / 5; SortedList closest = m_pictureManager.getCloseObjects(m_cameraManager.Location, searchRadius); if(closest.Count > 0) { LiveObject lo = (LiveObject)closest.GetByIndex(0); if(lo.Name.Length > 0) { name = lo.Name; } } camPos.Name = name; camPos.Type = Project.drawTerraserverMode; new DlgFavoritesAddTo(camPos, closest, this.favMainMenuItem, new System.EventHandler(favoriteItemClick)).ShowDialog(); }
// called from fileProcessor: private static void insertFavorite(CreateInfo createInfo) { switch(createInfo.type) { case "trk": case "rte": return; } string name = ("" + createInfo.name).Trim(); if(createInfo.urlName != null && createInfo.urlName.Length > 0) { name += " - " + createInfo.urlName.Trim(); } else if(createInfo.desc != null && createInfo.desc.Length > 0) { name += " - " + createInfo.desc.Trim(); } if(name.StartsWith(" - ")) { name = name.Substring(3); } name = name.Replace("\r", " ").Replace("\n", " ").Trim().Replace(" ", " "); if(name != null && name.Length > 0) { CamPos favPos = new CamPos(createInfo.lng, createInfo.lat, createInfo.elev, name.Trim(), Project.drawTerraserverMode); Project.favorites.Add(favPos); fvCount++; } }