Exemplo n.º 1
0
 void EditLocation_FormClosing(object sender, FormClosingEventArgs e)
 {
     // If point updated and we are warning then warn
     if (pointUpdated)
     {
         UserSavedPoint = false;
         DialogResult result = DialogResult.Yes;
         if (Application.UserAppDataRegistry.GetValue("Ask to update database", "True").Equals("True"))
         {
             result = MessageBox.Show("Do you want to save this new position", "Save changes",
                                      MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
         }
         if (result == DialogResult.Cancel)
         {
             e.Cancel = true;
             FactLocation.CopyLocationDetails(originalLocation, location);
         }
         else if (result == DialogResult.No)
         {
             FactLocation.CopyLocationDetails(originalLocation, location);
             pointUpdated = false;
         }
         else if (result == DialogResult.Yes)
         {
             UpdateDatabase();
             UserSavedPoint = true;
         }
     }
 }
Exemplo n.º 2
0
 public EditLocation(FactLocation location)
 {
     InitializeComponent();
     customMapLayers = new List <GdalRasterLayer>();
     mnuMapStyle.Setup(linkLabel1, mapBox1, tbOpacity);
     mapZoomToolStrip.Items.Add(mnuMapStyle);
     mapZoomToolStrip.Items[2].ToolTipText = "Zoom out of Map"; // fix bug in SharpMapUI component
     mapZoomToolStrip.Items[10].Visible    = false;
     this.location        = location;
     originalLocation     = FactLocation.TEMP;
     btnCustomMap.Visible = (Properties.MappingSettings.Default.CustomMapPath.Length > 0);
     FactLocation.CopyLocationDetails(location, originalLocation);
     Text           = "Editing : " + location.ToString();
     iconSelected   = false;
     pointUpdated   = false;
     dataUpdated    = false;
     UserSavedPoint = false;
     SetupMap();
     SetLocation();
 }
Exemplo n.º 3
0
 void GoogleLocationSearch()
 {
     if (txtSearch.Text.Length > 0)
     {
         FactLocation loc = FactLocation.LookupLocation(txtSearch.Text);
         if (!loc.IsGeoCoded(false)) // if not geocoded then try database
         {
             DatabaseHelper.GetLocationDetails(loc);
         }
         if (loc.IsGeoCoded(false))
         {
             FactLocation.CopyLocationDetails(loc, location);
             SetLocation();
             pointUpdated = true;
         }
         else
         {
             GeoResponse res = GoogleMap.GoogleGeocode(txtSearch.Text, 8);
             if (res.Status == "OK" && !(res.Results[0].Geometry.Location.Lat == 0 && res.Results[0].Geometry.Location.Long == 0))
             {
                 loc.Latitude  = res.Results[0].Geometry.Location.Lat;
                 loc.Longitude = res.Results[0].Geometry.Location.Long;
                 Coordinate mpoint = MapTransforms.TransformCoordinate(new Coordinate(loc.Longitude, loc.Latitude));
                 loc.LongitudeM    = mpoint.X;
                 loc.LatitudeM     = mpoint.Y;
                 loc.ViewPort      = MapTransforms.TransformViewport(res.Results[0].Geometry.ViewPort);
                 loc.GeocodeStatus = res.Results[0].PartialMatch ? FactLocation.Geocode.PARTIAL_MATCH : FactLocation.Geocode.MATCHED;
                 FactLocation.CopyLocationDetails(loc, location);
                 SetLocation();
                 pointUpdated = true;
             }
             else
             {
                 MessageBox.Show("Google didn't find " + txtSearch.Text, "Failed Google Lookup");
             }
         }
     }
 }
Exemplo n.º 4
0
 void ResetMap()
 {
     FactLocation.CopyLocationDetails(originalLocation, location);
     SetLocation();
 }