Example #1
0
 private void CreateWaypointsList()
 {
     if (_Tracks == null)
     {
         _WayPointsOnMap = null;
         _TracksOnMap = null;
     }
     else
     {
         _WayPointsOnMap = new List<WayPointOnMap>();
         _TracksOnMap = new List<TrackOnMap>();
         foreach (Track track in _Tracks)
         {
             TrackOnMap tom = new TrackOnMap();
             _TracksOnMap.Add(tom);
             foreach (TrackSegment seg in track.TrackSegments)
             {
                 foreach (WayPoint wp in seg.WayPoints)
                 {
                     WayPointOnMap wop = new WayPointOnMap(wp);
                     _WayPointsOnMap.Add(wop);
                     tom.WayPoints.Add(wop);
                 }
             }
         }
     }
 }
Example #2
0
 private void pnlImage_MouseDown(object sender, MouseEventArgs e)
 {
     try
     {
         if (e != null)
         {
             if (e.Button == MouseButtons.Left)
             {
                 _Selecting = true;
                 _SelectionStart = e.Location;
                 _SelectedWayPointsOnMap = null;
                 ResetHighlight();
             }
             else if (e.Button == MouseButtons.Right)
             {
                 //is it a waypoint?
                 _SelectedWayPointOnMap = GetWaypointFromPosition(e.X, e.Y);
             }
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("pnlImage_MouseDown: " + ex.ToString());
     }
 }
Example #3
0
 private void pnlImage_MouseUp(object sender, MouseEventArgs e)
 {
     try
     {
         if (e != null)
         {
             if (_Selecting)
             {
                 Point p1 = new Point(e.X < _SelectionStart.X ? e.X : _SelectionStart.X, e.Y < _SelectionStart.Y ? e.Y : _SelectionStart.Y);
                 _SelectionEnd = new Point(e.X > _SelectionStart.X ? e.X : _SelectionStart.X, e.Y > _SelectionStart.Y ? e.Y : _SelectionStart.Y);
                 _SelectionStart = p1;
                 _Selecting = false;
                 Graphics g = this.CreateGraphics();
                 Pen pen = new Pen(Color.Blue);
                 g.DrawRectangle(pen, new Rectangle(_SelectionStart.X, _SelectionStart.Y, _SelectionEnd.X - _SelectionStart.X, _SelectionEnd.Y - _SelectionStart.Y));
                 g.Dispose();
                 //calculate the selection
                 _SelectedWayPointsOnMap = new List<WayPointOnMap>();
                 foreach (WayPointOnMap wpm in _WayPointsOnMap)
                 {
                     if (wpm.IsInBounds(_SelectionStart.X, _SelectionStart.Y, _SelectionEnd.X, _SelectionEnd.Y))
                     {
                         wpm.IsHighlighted = true;
                         _SelectedWayPointsOnMap.Add(wpm);
                     }
                 }
                 Draw();
             }
             else if (_SelectedWayPointOnMap != null)
             {
                 //calculate x and y values for the point
                 int x = e.X + _LeftOffset - _LeftMargin;
                 int y = e.Y + _TopOffset - _TopMargin;
                 SetWaypointValueForCoordinates(_SelectedWayPointOnMap.WayPoint, x, y);
                 _SelectedWayPointOnMap = null;
                 foreach (Track track in _Tracks)
                     track.Recalculate();
                 Draw();
             }
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("pnlImage_MouseUp: " + ex.ToString());
     }
 }