Exemple #1
0
        private IList <IGPSLocation> getSelectedGPSLocations(IMapDrawContext drawContext)
        {
            IList <IGPSLocation> list = new List <IGPSLocation>()
            {
            };
            IMapControl mapControl = UI.MapLayers.MapControlLayer.Instance.MapControl;

            ICollection <IMapControlObject> selectedGPS = mapControl.Selected;

            if (selectedGPS.Count > 0)
            {
                IMapControlObject[] selectedMapControlObjects = new IMapControlObject[selectedGPS.Count];
                selectedGPS.CopyTo(selectedMapControlObjects, 0);
                for (int i = 0; i < selectedGPS.Count; i++)
                {
                    Rectangle rec = selectedMapControlObjects[i].PixelBounds(drawContext);

                    int          X   = rec.X + (rec.Width / 2) - (drawContext.DrawRectangle.Width / 2);
                    int          Y   = rec.Y + (rec.Height / 2) - (drawContext.DrawRectangle.Height / 2);
                    IGPSLocation loc = drawContext.Projection.PixelToGPS(drawContext.Center, drawContext.ZoomLevel, new Point(X, Y));
                    list.Add(loc);
                }
            }
            return(list);
        }
Exemple #2
0
 public static IGPSPoint LocationToPoint(IGPSLocation location)
 {
     if (location == null)
     {
         //TODO: raise exception?
         return(new GPSPoint(0, 0, 0));
     }
     return(new GPSPoint(location.LatitudeDegrees, location.LongitudeDegrees, float.NaN));
 }
Exemple #3
0
        protected override void OnMapControlMouseMove(object sender, MouseEventArgs e)
        {
            if (this._selectedPointMoving != null)
            {
                if (_selectedPointMoving != null)
                {
                    //MapControl.RemoveOverlay(_selectedWaypointMoving);
                    Point        p = new Point(m_clickToCenterOffset.X + e.Location.X, m_clickToCenterOffset.Y + e.Location.Y);
                    IGPSLocation l = MapControl.MapProjection.PixelToGPS(MapControl.MapBounds.NorthWest, MapControl.Zoom, p);
                    _selectedPointMoving.TrailPoint.GpsLoc = l;
                    this.m_editTrail.UpdatePointFromMap(this._selectedPointMoving.TrailPoint);

                    //Refresh this point. Only seem to be possible with refreshing all
                    RefreshOverlays(true);
                    //MapControl.AddOverlay(_selectedWaypointMoving);
                    //MapControl.RefreshMap();
                }
            }
        }
Exemple #4
0
        public void Draw(IMapDrawContext drawContext)
        {
            if (m_CaptureSelectedGPSLocations)
            {
                m_CaptureSelectedGPSLocations = false;
                if (m_SelectedGPSLocations.Count != MapControl.Selected.Count)
                {
                    m_SelectedGPSLocations = getSelectedGPSLocations(drawContext);
                    SelectedGPSLocationsChanged(this, new System.EventArgs());
                }
            }

            if (_showPage)
            {
                //drawContext.Center

                IGPSLocation loc1           = drawContext.Projection.PixelToGPS(drawContext.Center, drawContext.ZoomLevel, new Point(0, 0));
                IGPSLocation loc2           = drawContext.Projection.PixelToGPS(drawContext.Center, drawContext.ZoomLevel, new Point(0, 100));
                IGPSPoint    point1         = Utils.GPS.LocationToPoint(loc1);
                IGPSPoint    point2         = Utils.GPS.LocationToPoint(loc2);
                float        meters         = point1.DistanceMetersToPoint(point2) / 100;
                float        radiusInPixels = m_highlightRadius / meters;

                foreach (TrailGPSLocation gpsLocation in m_TrailPoints)
                {
                    Point point = drawContext.Projection.GPSToPixel(drawContext.Center, drawContext.ZoomLevel, gpsLocation.GpsLocation);
                    Pen   pen   = new Pen(Color.Red, 5.0F);

                    drawContext.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                    float X = point.X + (drawContext.DrawRectangle.Width / 2) - radiusInPixels;
                    float Y = point.Y + (drawContext.DrawRectangle.Height / 2) - radiusInPixels;
                    if (X > 0 && X < 1000 && Y > 0 && Y < 1000)
                    {
                        //Prevent crashes at large elipses
                        drawContext.Graphics.DrawEllipse(pen, X, Y, radiusInPixels * 2, radiusInPixels * 2);
                    }
                }
            }
        }
        public IGPSLocation GetCenterMap()
        {
            IGPSLocation centerLocation = this.MapControl.MapBounds.Center;

            return(centerLocation);
        }
Exemple #6
0
 public void MoveMap(IGPSLocation newLocation)
 {
     Debug.Write(showPage);
     base.MapControl.PanTo(newLocation);
 }
Exemple #7
0
		public static IGPSPoint LocationToPoint(IGPSLocation location) {
			return new GPSPoint(location.LatitudeDegrees, location.LongitudeDegrees, 0);
		}
Exemple #8
0
 public TrailGPSLocation(IGPSLocation gpsLoc, float radius) :
     this(gpsLoc.LatitudeDegrees, gpsLoc.LongitudeDegrees, float.NaN, "", true, radius)
 {
 }
Exemple #9
0
        private void EList_AddRow()
        {
            int i = EList_SelectedRow();

            if (i < 0)
            {
                if (((IList <EditTrailRow>) this.EList.RowData).Count > 0)
                {
                    i = ((IList <EditTrailRow>) this.EList.RowData).Count - 1;
                }
                else
                {
                    i = 0;
                }
            }
            TrailGPSLocation sel;

            if (((IList <EditTrailRow>) this.EList.RowData).Count > 0)
            {
                sel        = new TrailGPSLocation(((IList <EditTrailRow>) this.EList.RowData)[i].TrailGPS);
                sel.GpsLoc = new GPSLocation(sel.LatitudeDegrees + 0.0001F, sel.LongitudeDegrees + 0.0001F);
            }
            else
            {
                IGPSLocation l = m_layer.GetCenterMap();
                sel = new TrailGPSLocation(l, this.m_TrailToEdit.Radius);
            }

            sel.Name += " " + ZoneFiveSoftware.Common.Visuals.CommonResources.Text.ActionNew;

            //If a point is selected on the track, use it instead
            IList <IActivity> activities = new List <IActivity> {
                Controller.TrailController.Instance.ReferenceActivity
            };
            IList <IItemTrackSelectionInfo> selectedGPS =
                TrailsItemTrackSelectionInfo.SetAndAdjustFromSelectionFromST(m_view.RouteSelectionProvider.SelectedItems, activities);

            if (TrailsItemTrackSelectionInfo.ContainsData(selectedGPS))
            {
                IList <TrailGPSLocation> loc = TrailSelectorControl.GetGPS(this.Trail, activities, selectedGPS);
                if (loc.Count > 0 && loc[0] != null)
                {
                    sel.GpsLoc = loc[0];
                }
            }

            EditTrailRow newRow = new EditTrailRow(sel);

            if (((IList <EditTrailRow>) this.EList.RowData).Count > 0)
            {
                ((IList <EditTrailRow>) this.EList.RowData).Insert(i + 1, newRow);
            }
            else
            {
                this.EList.RowData = new List <EditTrailRow> {
                    newRow
                };
            }

            //Make ST see the update
            this.EList.RowData = ((IList <EditTrailRow>) this.EList.RowData);
            foreach (EditTrailRow t in (IList <EditTrailRow>) this.EList.RowData)
            {
                //Note: For reverse results, this is incorrect (but reverse results are only for incomplete, so no impact)
                this.EList.SetChecked(t, t.TrailGPS.Required);
            }
            this.EList.SelectedItems = new object[] { newRow };
            this.EList.Refresh();

            this.m_TrailToEdit.TrailLocations = EditTrailRow.getTrailGPSLocation((IList <EditTrailRow>) this.EList.RowData);
            this.m_layer.TrailPoints          = m_TrailToEdit.TrailLocations;
            this.m_layer.SelectedTrailPoints  = new List <TrailGPSLocation> {
                sel
            };
            this.m_layer.Refresh();
        }