public void OnEvent(object MapEvent) { if (_mapDocument == null || Device.GPS == null || _mapDocument.Application == null) { return; } IMap map = _mapDocument.FocusMap; if (map == null || map.Display == null) { return; } GPSDevice gps = Device.GPS; if (gps == null) { return; } if (_track == null) { _track = new GPSTrack(_mapDocument); _mapDocument.FocusMap.Display.GraphicsContainer.Elements.Add(_track); } else if (_track.IsConnected) { _track.Disconnect(); } else { _track.Connect(); } }
public static List<GPSDevice> GetSupportedGPSDevices() { var supportedGPSDevices = new List<GPSDevice>(); // Garmin Forerunner supportedGPSDevices.Add(new GPSDevice(new GarminForerunnerUSBImporter())); // GlobalSat GH-615M supportedGPSDevices.Add(new GPSDevice(new GlobalSatGH615MImporter())); // JJ-Connect Registrator SE supportedGPSDevices.Add(new GPSDevice(new JJConnectRegistratorSEImporter())); // Garmin ANT Agent GarminANTAgentImporter antImporter = new GarminANTAgentImporter(); antImporter.Path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\GARMIN\Devices\"; GPSDevice antDevice = new GPSDevice(antImporter); supportedGPSDevices.Add(antDevice); // Polar ProTrainer var polarProTrainerImporter = new PolarProTrainerImporter(); polarProTrainerImporter.Paths = new List<string> { GetProgramFilesPath() + @"\Polar\Polar ProTrainer\", Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\VirtualStore\Program Files\Polar\Polar ProTrainer\", }; GPSDevice polarProTrainerDevice = new GPSDevice(polarProTrainerImporter); supportedGPSDevices.Add(polarProTrainerDevice); return supportedGPSDevices; }
public void OnEvent(object MapEvent) { if (_mapDocument == null || Device.GPS == null || _mapDocument.Application == null) { return; } IMap map = _mapDocument.FocusMap; if (map == null || map.Display == null) { return; } GPSDevice gps = Device.GPS; if (gps == null) { return; } if (_gpspoint != null) // Punkt aus der Karte entfernen { gps.PositionReceived -= new GPSDevice.PositionReceivedEventHandler(gps_PositionReceived); map.Display.GraphicsContainer.Elements.Remove(_gpspoint); _gpspoint = null; if (_mapDocument.Application is IMapApplication) { ((IMapApplication)_mapDocument.Application).RefreshActiveMap(DrawPhase.Graphics); } return; } if (map.Display == null || map.Display.SpatialReference == null) { MessageBox.Show("No Spatialreference definded for current map..."); return; } IPoint point = GeometricTransformer.Transform2D(new Point(gps.Longitude, gps.Latitude), SpatialReference.FromID("EPSG:4326"), map.Display.SpatialReference) as IPoint; if (point != null) { double width = map.Display.Envelope.maxx - map.Display.Envelope.minx; double height = map.Display.Envelope.maxy - map.Display.Envelope.miny; map.Display.ZoomTo(new Envelope(point.X - width / 2, point.Y - height / 2, point.X + width / 2, point.Y + height / 2)); map.Display.GraphicsContainer.Elements.Add(_gpspoint = new GPSPoint(gps.Longitude, gps.Latitude, true)); if (_mapDocument.Application is IMapApplication) { ((IMapApplication)_mapDocument.Application).RefreshActiveMap(DrawPhase.All); } _timeStamp = DateTime.Now; gps.PositionReceived += new GPSDevice.PositionReceivedEventHandler(gps_PositionReceived); } }
public TrackPoint(GPSDevice sender, double deciLat, double deciLon) { _lat = deciLat; _lon = deciLon; _h = sender.EllipsoidHeight; _speed = sender.Speed; _pdop = sender.PDOP; _hdop = sender.HDOP; _vdop = sender.VDOP; }
void device_PDOPReceived(GPSDevice sender, double value) { if (this.InvokeRequired) { device_Callback d = new device_Callback(device_PDOPReceived); this.Invoke(d, new object[] { sender, value }); } else { txtPDOP.Text = value.ToString(); } }
void device_DateTimeChanged(GPSDevice sender, DateTime dateTime) { if (this.InvokeRequired) { device_DateTimeChangedCallback d = new device_DateTimeChangedCallback(device_DateTimeChanged); this.Invoke(d, new object[] { sender, dateTime }); } else { txtTime.Text = dateTime.ToLongTimeString(); } }
private void device_PositionReceived(GPSDevice sender, string Lon, string Lat, double deciLon, double deciLat) { if (this.InvokeRequired) { device_PositionReceivedCallback d = new device_PositionReceivedCallback(device_PositionReceived); this.Invoke(d, new object[] { sender, Lon, Lat, deciLon, deciLat }); } else { txtLon.Text = Lon; txtLat.Text = Lat; txtDLon.Text = deciLon.ToString(); txtDLat.Text = deciLat.ToString(); } }
public void SaveOrUpdate(GPSDevice district) { using (FLMSEntities entities = new FLMSEntities()) { if (district.Id == 0) { entities.GPSDevices.Add(district); entities.SaveChanges(); } else { entities.Entry(district).State = System.Data.Entity.EntityState.Modified; entities.SaveChanges(); } } }
void setTrackerHomeFromModule(object sender, EventArgs e) { GPSDevice gpsModule = getDevice(); if (gpsModule != null) { _Available = true; GPSPosition pos = gpsModule.GetCoordinates(); double alt = getGEAlt(pos.Lat, pos.Lng); Host.comPort.MAV.cs.TrackerLocation = new PointLatLngAlt(pos.Lat, pos.Lng, alt, "Tracker Home"); } else { _Available = false; CustomMessageBox.Show("No GPS Device connected. Please verify it is connected and try again."); } }
private void btnStart_Click(object sender, EventArgs e) { if (_device != null) { _device.Dispose(); _device = null; } if (btnStart.Text == "Start") { _device = new GPSDevice( cmbPortName.Text, int.Parse(cmbBaudRate.Text), (Parity)Enum.Parse(typeof(Parity), cmbParity.Text), int.Parse(cmbDataBits.Text), (StopBits)Enum.Parse(typeof(StopBits), cmbStopBits.Text)); _device.PositionReceived -= new GPSDevice.PositionReceivedEventHandler(device_PositionReceived); _device.PDOPReceived -= new GPSDevice.PDOPReceivedEventHandler(device_PDOPReceived); _device.VDOPReceived -= new GPSDevice.VDOPReceivedEventHandler(device_VDOPReceived); _device.HDOPReceived -= new GPSDevice.HDOPReceivedEventHandler(device_HDOPReceived); _device.SatelliteReceived -= new GPSDevice.SatelliteReceivedEventHandler(device_SatelliteReceived); _device.DateTimeChanged -= new GPSDevice.DateTimeChangedEventHandler(device_DateTimeChanged); _device.PositionReceived += new GPSDevice.PositionReceivedEventHandler(device_PositionReceived); _device.PDOPReceived += new GPSDevice.PDOPReceivedEventHandler(device_PDOPReceived); _device.VDOPReceived += new GPSDevice.VDOPReceivedEventHandler(device_VDOPReceived); _device.HDOPReceived += new GPSDevice.HDOPReceivedEventHandler(device_HDOPReceived); _device.SatelliteReceived += new GPSDevice.SatelliteReceivedEventHandler(device_SatelliteReceived); _device.DateTimeChanged += new GPSDevice.DateTimeChangedEventHandler(device_DateTimeChanged); if (_device.Start()) { btnStart.Text = "Stop"; } else { MessageBox.Show("Can't connect to port...\n" + _device.ErrorMessage); } } else { btnStart.Text = "Start"; } }
static void Main() { Phone p = new Phone(); GPSDevice gps = new GPSDevice(); Camera cam = new Camera(); Traveller _trav = new Traveller(); Person _per = ne Person(); Photographer _photo = new Photographer(); _trav.Navigate(gps); _per.Communicate(p); _photo.CaptureRealObjects(cam); SmartPhone _sm = new SmartPhone(); _trav.Navigate(sm); _per.Communicate(sm); _photo.CaptureRealObjects(sm); }
void GPS_PositionReceived(GPSDevice sender, string latitude, string longitude, double deciLat, double deciLon) { if (_polyline[0].PointCount > 0) { IPoint p = _polyline[0][_polyline[0].PointCount - 1]; if (Math.Abs(p.X - deciLon) < 1e-10 && Math.Abs(p.Y - deciLat) < 1e-10) { return; } } _polyline[_polyline.PathCount - 1].AddPoint( new TrackPoint(sender, deciLat, deciLon)); //if (_doc != null && _doc.FocusMap != null && _doc.FocusMap == _map && // _doc.Application is IMapApplication) //{ // ((IMapApplication)_doc.Application).RefreshActiveMap(DrawPhase.Graphics); //} }
// GET: GPSDevices public ActionResult Index(int?id) { GPSDeviceViewModel gpsDeviceViewModel = new GPSDeviceViewModel(); if (id != null) { GPSDevice gpsDevice = gpsDeviceService.GetGPSDeviceById(id); gpsDeviceViewModel = new GPSDeviceViewModel() { Id = gpsDevice.Id, IsActive = gpsDevice.IsActive, ModelNumber = gpsDevice.Model, SerialNumber = gpsDevice.SerialNumber, SupplierName = gpsDevice.Supplier.Name }; } ViewBag.SupplierList = new SelectList(genericService.GetList <Supplier>(), "Id", "Name"); return(View(gpsDeviceViewModel)); }
void deviceChanged(MainV2.WM_DEVICECHANGE_enum cause) { GPSDevice gpsModule = getDevice(); if ((gpsModule != null)) { if (_Available == false) { _Available = true; if (CustomMessageBox.Show("A GPS module was detected on your system. Would you like to use it to set your tracker home location?", "Tracker Home", MessageBoxButtons.YesNo) == DialogResult.Yes) { GPSPosition pos = gpsModule.GetCoordinates(); double alt = getGEAlt(pos.Lat, pos.Lng); Host.comPort.MAV.cs.TrackerLocation = new PointLatLngAlt(pos.Lat, pos.Lng, alt, "Tracker Home"); } } } else if (_Available == true) { _Available = false; } }
private void gps_PositionReceived(GPSDevice sender, string latitude, string longitude, double deciLat, double deciLon) { if (((TimeSpan)(DateTime.Now - _timeStamp)).TotalSeconds < 5) { return; } _timeStamp = DateTime.Now; if (_mapDocument == null || _mapDocument.FocusMap == null || Device.GPS == null || _mapDocument.Application == null || _gpspoint == null) { return; } if (!_mapDocument.FocusMap.Display.GraphicsContainer.Elements.Contains(_gpspoint)) { return; } IEnvelope env = _mapDocument.FocusMap.Display.Envelope; IPoint p = _gpspoint.Project(_mapDocument.FocusMap.Display); DrawPhase phase = DrawPhase.Graphics; if (p.X <= env.minx || p.X >= env.maxx || p.Y <= env.miny || p.Y >= env.maxy) { double width = env.maxx - env.minx; double height = env.maxy - env.miny; _mapDocument.FocusMap.Display.ZoomTo(new Envelope(p.X - width / 2, p.Y - height / 2, p.X + width / 2, p.Y + height / 2)); phase = DrawPhase.All; } if (_mapDocument.Application is IMapApplication) { ((IMapApplication)_mapDocument.Application).RefreshActiveMap(phase); } }
void device_SatelliteReceived(GPSDevice sender, int pseudoRandomCode, int azimuth, int elevation, int signalToNoiseRatio) { if (this.InvokeRequired) { device_SatelliteReceivedCallback d = new device_SatelliteReceivedCallback(device_SatelliteReceived); this.Invoke(d, new object[] { sender, pseudoRandomCode, azimuth, elevation, signalToNoiseRatio }); } else { if (!_satellites.ContainsKey(pseudoRandomCode)) { _satellites.Add(pseudoRandomCode, new Satellite(pseudoRandomCode, azimuth, elevation, signalToNoiseRatio)); } else { Satellite sat = _satellites[pseudoRandomCode]; sat.pseudoRandomCode = pseudoRandomCode; sat.azimuth = azimuth; sat.elevation = elevation; sat.signalToNoiseRatio = signalToNoiseRatio; } panelSatellites.Refresh(); } }
public void Navigate(GPSDevice gpd) { gpd.Navigate(); }
public ActionResult SaveOrUpdate(GPSDeviceViewModel model) { string newData = string.Empty, oldData = string.Empty; try { int id = model.Id; GPSDevice gpsDevice = null; GPSDevice oldGPSDevice = null; if (model.Id == 0) { gpsDevice = new GPSDevice { Model = model.ModelNumber, SerialNumber = model.SerialNumber, IsActive = true, SupplierId = model.SupplierId }; oldGPSDevice = new GPSDevice(); oldData = new JavaScriptSerializer().Serialize(oldGPSDevice); newData = new JavaScriptSerializer().Serialize(gpsDevice); } else { gpsDevice = genericService.GetList <GPSDevice>().Where(o => o.Id == model.Id).FirstOrDefault(); oldGPSDevice = genericService.GetList <GPSDevice>().Where(o => o.Id == model.Id).FirstOrDefault(); oldData = new JavaScriptSerializer().Serialize(new GPSDevice() { Id = oldGPSDevice.Id, SerialNumber = oldGPSDevice.SerialNumber, IsActive = oldGPSDevice.IsActive, SupplierId = model.SupplierId }); gpsDevice.SerialNumber = model.SerialNumber; gpsDevice.Model = model.ModelNumber; bool Example = Convert.ToBoolean(Request.Form["IsActive.Value"]); gpsDevice.IsActive = model.IsActive; gpsDevice.SupplierId = model.SupplierId; newData = new JavaScriptSerializer().Serialize(new GPSDevice() { Id = gpsDevice.Id, SerialNumber = gpsDevice.SerialNumber, IsActive = gpsDevice.IsActive }); } genericService.SaveOrUpdate <GPSDevice>(gpsDevice, gpsDevice.Id); //CommonService.SaveDataAudit(new DataAudit() //{ // Entity = "GPSDevices", // NewData = newData, // OldData = oldData, // UpdatedOn = DateTime.Now, // UserId = User.Identity.GetUserId() //}); TempData["Message"] = ResourceData.SaveSuccessMessage; } catch (Exception ex) { TempData["Message"] = string.Format(ResourceData.SaveErrorMessage, ex.InnerException); } return(RedirectToAction("Index", "GPSDevice")); }
private DialogResult Import() { // validate file names if (imageSourceType != SourceType.Url && mapImageFileName.Text != "" && !File.Exists(mapImageFileName.Text)) { MessageBox.Show(Strings.MapImageFileDoesNotExist, Strings.InvalidMapImage, MessageBoxButtons.OK, MessageBoxIcon.Error); return(DialogResult.Cancel); } if (routeFromFile.Checked && !File.Exists(routeFileName.Text)) { MessageBox.Show(Strings.RouteFileDoesNotExist, Strings.InvalidRoute, MessageBoxButtons.OK, MessageBoxIcon.Error); return(DialogResult.Cancel); } IRouteImporter routeImporter = null; if (routeFromFile.Checked) { IRouteFileImporter routeFileImporter = ((RouteFileFormat)routeFileFormatComboBox.SelectedItem).Importer; routeFileImporter.FileName = routeFileName.Text; routeImporter = routeFileImporter; } else if (routeFromGpsDevice.Checked) { GPSDevice gpsDevice = routeGpsDevice.SelectedItem as GPSDevice; if (gpsDevice == null) { MessageBox.Show(Strings.NoGPSDevicesConnectedMessageBox, Strings.InvalidRoute, MessageBoxButtons.OK, MessageBoxIcon.Error); return(DialogResult.Cancel); } routeImporter = gpsDevice.Importer; } routeImporter.BeginWork += routeImporter_BeginWork; routeImporter.WorkProgress += routeImporter_WorkProgress; routeImporter.EndWork += routeImporter_EndWork; DialogResult result; try { result = routeImporter.ShowPreImportDialogs(); } catch (Exception ex) { Cursor = Cursors.Default; Util.ShowExceptionMessageBox(ex, Strings.InvalidRoute); return(DialogResult.Cancel); } if (result == DialogResult.OK) { try { routeImporter.Import(); } catch (Exception ex) { routeImporter.ImportResult.Succeeded = false; routeImporter.ImportResult.Error = ImportError.Unknown; routeImporter.ImportResult.ErrorMessage = ex.Message; routeImporter.ImportResult.Exception = ex; } if (!routeImporter.ImportResult.Succeeded) { // an error occured, show relevant error info and cancel creation of new document. switch (routeImporter.ImportResult.Error) { case ImportError.NoWaypoints: routeImporter.ImportResult.ErrorMessage = Strings.RouteImportError_NoWaypoints; break; case ImportError.NoWaypointTimes: routeImporter.ImportResult.ErrorMessage = Strings.RouteImportError_NoWaypointTimes; break; } Cursor = Cursors.Default; if (routeImporter.ImportResult.Exception != null) { Util.ShowExceptionMessageBox(routeImporter.ImportResult.Exception, Strings.InvalidRoute); } else { MessageBox.Show(routeImporter.ImportResult.ErrorMessage, Strings.InvalidRoute, MessageBoxButtons.OK, MessageBoxIcon.Error); } return(DialogResult.Cancel); } try { if (string.IsNullOrEmpty(mapImageFileName.Text)) { var blankMap = new Bitmap(1500, 1500); using (Graphics g = Graphics.FromImage(blankMap)) { g.Clear(Color.White); } Map = new Map(blankMap); } else if (!ImageHasBeenTransformed) { CreateMapAndSetInitialTransformations(); } else { // don't care about transformations embedded in jpg, qrt or kmz files since the original file has been transformed Map = new Map(new Bitmap(transformedImage)); } } catch (Exception ex) { Cursor = Cursors.Default; Util.ShowExceptionMessageBox(ex, Strings.InvalidMapImage); return(DialogResult.Cancel); } ImportResult = routeImporter.ImportResult; if (!string.IsNullOrEmpty(mapImageFileName.Text)) { Util.ApplicationSettings.AddRecentMapImageFileName(mapImageFileName.Text); } if (routeFromFile.Checked) { Util.ApplicationSettings.AddRecentRouteFileName(routeFileName.Text); } } return(result); }
private void Import() { if (routeFromFile.Checked && !File.Exists(routeFileName.Text)) { MessageBox.Show(Strings.RouteFileDoesNotExist, Strings.InvalidRoute, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } IRouteImporter routeImporter = null; if (routeFromFile.Checked) { IRouteFileImporter routeFileImporter = ((RouteFileFormat)routeFileFormatComboBox.SelectedItem).Importer; routeFileImporter.FileName = routeFileName.Text; routeImporter = routeFileImporter; } else if (routeFromGpsDevice.Checked) { GPSDevice gpsDevice = routeGpsDevice.SelectedItem as GPSDevice; if (gpsDevice == null) { MessageBox.Show(Strings.NoGPSDevicesConnectedMessageBox, Strings.InvalidRoute, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } routeImporter = gpsDevice.Importer; } routeImporter.BeginWork += routeImporter_BeginWork; routeImporter.WorkProgress += routeImporter_WorkProgress; routeImporter.EndWork += routeImporter_EndWork; if (routeImporter.ShowPreImportDialogs() == DialogResult.OK) { try { routeImporter.Import(); } catch (Exception ex) { routeImporter.ImportResult.Succeeded = false; routeImporter.ImportResult.Error = ImportError.Unknown; routeImporter.ImportResult.ErrorMessage = ex.Message; routeImporter.ImportResult.Exception = ex; } if (!routeImporter.ImportResult.Succeeded) { // an error occured, show relevant error info and cancel creation of new session. switch (routeImporter.ImportResult.Error) { case ImportError.NoWaypoints: routeImporter.ImportResult.ErrorMessage = Strings.RouteImportError_NoWaypoints; break; case ImportError.NoWaypointTimes: routeImporter.ImportResult.ErrorMessage = Strings.RouteImportError_NoWaypointTimes; break; } Cursor = Cursors.Default; if (routeImporter.ImportResult.Exception != null) { Util.ShowExceptionMessageBox(routeImporter.ImportResult.Exception, Strings.InvalidRoute); } else { MessageBox.Show(routeImporter.ImportResult.ErrorMessage, Strings.InvalidRoute, MessageBoxButtons.OK, MessageBoxIcon.Error); } return; } // add new session to session collection var monochromeColors = new Color[] { Color.Red, Color.Blue, Color.DarkGreen, Color.DarkOrange, Color.DarkGray }; SessionSettings ss = Document.Settings.DefaultSessionSettings.Copy(); ss.RouteLineSettingsCollection[WaypointAttribute.Pace].MonochromeColor = Color.FromArgb(160, monochromeColors[ Sessions.Count % monochromeColors. Length]); ss.RouteLineSettingsCollection[WaypointAttribute.Pace].MonochromeWidth = 3; Session s = new Session( routeImporter.ImportResult.Route, routeImporter.ImportResult.Laps, Document.Map.Image.Size, Document.Sessions.CalculateAverageTransformation().TransformationMatrix, Document.ProjectionOrigin, ss); s.CreateAdjustedRoute(); Sessions.Add(s); // update session grid sessionGrid.DataSource = CreateBindingSource(Sessions); } }
private DialogResult Import() { // validate file names if (mapImageFromFile.Checked && !File.Exists(mapImageFileName.Text)) { MessageBox.Show(Strings.MapImageFileDoesNotExist, Strings.InvalidMapImage, MessageBoxButtons.OK, MessageBoxIcon.Error); return(DialogResult.Cancel); } if (routeFromFile.Checked && !File.Exists(routeFileName.Text)) { MessageBox.Show(Strings.RouteFileDoesNotExist, Strings.InvalidRoute, MessageBoxButtons.OK, MessageBoxIcon.Error); return(DialogResult.Cancel); } IRouteImporter routeImporter = null; if (routeFromFile.Checked) { IRouteFileImporter routeFileImporter = ((RouteFileFormat)routeFileFormatComboBox.SelectedItem).Importer; routeFileImporter.FileName = routeFileName.Text; routeImporter = routeFileImporter; } else if (routeFromGpsDevice.Checked) { GPSDevice gpsDevice = routeGpsDevice.SelectedItem as GPSDevice; if (gpsDevice == null) { MessageBox.Show(Strings.NoGPSDevicesConnectedMessageBox, Strings.InvalidRoute, MessageBoxButtons.OK, MessageBoxIcon.Error); return(DialogResult.Cancel); } routeImporter = gpsDevice.Importer; } routeImporter.BeginWork += routeImporter_BeginWork; routeImporter.WorkProgress += routeImporter_WorkProgress; routeImporter.EndWork += routeImporter_EndWork; DialogResult result; try { result = routeImporter.ShowPreImportDialogs(); } catch (Exception ex) { Cursor = Cursors.Default; Util.ShowExceptionMessageBox(ex, Strings.InvalidRoute); return(DialogResult.Cancel); } if (result == DialogResult.OK) { try { routeImporter.Import(); } catch (Exception ex) { routeImporter.ImportResult.Succeeded = false; routeImporter.ImportResult.Error = ImportError.Unknown; routeImporter.ImportResult.ErrorMessage = ex.Message; routeImporter.ImportResult.Exception = ex; } if (!routeImporter.ImportResult.Succeeded) { // an error occured, show relevant error info and cancel creation of new document. switch (routeImporter.ImportResult.Error) { case ImportError.NoWaypoints: routeImporter.ImportResult.ErrorMessage = Strings.RouteImportError_NoWaypoints; break; case ImportError.NoWaypointTimes: routeImporter.ImportResult.ErrorMessage = Strings.RouteImportError_NoWaypointTimes; break; } Cursor = Cursors.Default; if (routeImporter.ImportResult.Exception != null) { Util.ShowExceptionMessageBox(routeImporter.ImportResult.Exception, Strings.InvalidRoute); } else { MessageBox.Show(routeImporter.ImportResult.ErrorMessage, Strings.InvalidRoute, MessageBoxButtons.OK, MessageBoxIcon.Error); } return(DialogResult.Cancel); } try { if (mapImageFromFile.Checked) { switch (mapImageFileFormatComboBox.SelectedIndex) { case 0: // map image from image file Map = new Map(mapImageFileName.Text, MapSourceType.FileSystem, MapStorageType.Inline); // is it a QuickRoute image? if yes, use embedded transformation matrix var ed = QuickRouteJpegExtensionData.FromJpegFile(mapImageFileName.Text); if (ed != null && ed.Sessions != null && ed.Sessions.Count > 0) { InitialTransformation = ed.Sessions.CalculateAverageTransformation(); } break; case 1: // map image from QuickRoute file Document d = Document.OpenFromQrt(mapImageFileName.Text); if (d != null) { Map = d.Map; InitialTransformation = d.Sessions.CalculateAverageTransformation(); } break; case 2: // map image from kmz file var kmz = new KmzDocument(mapImageFileName.Text); if (kmz.ImageStream != null) { Map = new Map(kmz.ImageStream); InitialTransformation = kmz.Transformation; } break; } } else if (mapImageBlank.Checked) { var blankMap = new Bitmap(1500, 1500); using (Graphics g = Graphics.FromImage(blankMap)) { g.Clear(Color.White); } Map = new Map(blankMap); } else if (mapImageFromUrl.Checked) { Map = new Map(mapImageUrl.Text, MapSourceType.Url, MapStorageType.Inline); } } catch (Exception ex) { Cursor = Cursors.Default; Util.ShowExceptionMessageBox(ex, Strings.InvalidMapImage); return(DialogResult.Cancel); } ImportResult = routeImporter.ImportResult; if (mapImageFromFile.Checked) { Util.ApplicationSettings.AddRecentMapImageFileName(mapImageFileName.Text); } if (routeFromFile.Checked) { Util.ApplicationSettings.AddRecentRouteFileName(routeFileName.Text); } } return(result); }
static GPSDevice GetGPSDevice(string gpsCode) { if (Static_GPSDeviceDictionary.ContainsKey(gpsCode)) return Static_GPSDeviceDictionary[gpsCode]; string cmdText = string.Format(Static_SQLTextFormat_GPSDevice, gpsCode); using (MySqlDataReader dr = MySqlHelper.ExecuteReader(Static_ConnString_Tuge, cmdText)) { if (dr.Read()) { GPSDevice device = new GPSDevice() { GPSCode = gpsCode, VehicleCode = dr["VehicleCode"].ToString(), InitMileage = dr["InitMileage"] == DBNull.Value ? 0 : Convert.ToDecimal(dr["InitMileage"]) }; Static_GPSDeviceDictionary.Add(gpsCode, device); return device; } } return null; }