Esempio n. 1
0
        public static void RemoveWaypoint(Waypoint _wpt)
        {
            lock (m_waypointsWithThumbs)
            {
                for (int i = WaypointsWithThumbs.Count - 1; i >= 0; i--)
                {
                    Waypoint wpt = (Waypoint)WaypointsWithThumbs.GetByIndex(i);
                    try
                    {
                        if (wpt == _wpt)
                        {
                            WaypointsWithThumbs.RemoveAt(i);

                            Track trk = WaypointsCache.getTrackById(wpt.TrackId);

                            if (trk != null)
                            {
                                trk.Trackpoints.Remove(wpt.DateTime);
                            }

                            break;
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }
Esempio n. 2
0
        public static void cleanPhotoTrackpoints(string thumbFileName)          // thumbFileName may be null - then clean all, else clean one
        {
            for (int i = 0; i < WaypointsWithThumbs.Count; i++)
            {
                Waypoint wpt = (Waypoint)WaypointsWithThumbs.GetByIndex(i);
                if (thumbFileName == null || thumbFileName.Equals(wpt.ThumbSource))
                {
                    Track trk = WaypointsCache.getTrackById(wpt.TrackId);

                    if (trk != null)
                    {
                        trk.Trackpoints.Remove(wpt.DateTime);
                    }

                    if (thumbFileName != null)
                    {
                        WaypointsWithThumbs.RemoveAt(i);
                        break;
                    }
                }
            }
            if (thumbFileName == null)
            {
                WaypointsWithThumbs.Clear();
            }
            hasCurrentWaypoint();               // make sure the pointer is as sane as it can be
        }
Esempio n. 3
0
 public static void resetThumbPositions()
 {
     for (int i = 0; i < WaypointsWithThumbs.Count; i++)
     {
         Waypoint wpt = (Waypoint)WaypointsWithThumbs.GetByIndex(i);
         wpt.ThumbPosition = Project.thumbPosition;
     }
 }
Esempio n. 4
0
 public static Waypoint PreviousWaypoint()
 {
     if (!hasPreviousWaypoint())
     {
         return(null);
     }
     return((Waypoint)WaypointsWithThumbs.GetByIndex(--CurrentWptIndex));
 }
Esempio n. 5
0
 public static Waypoint NextWaypoint()
 {
     if (!hasNextWaypoint())
     {
         return(null);
     }
     return((Waypoint)WaypointsWithThumbs.GetByIndex(++CurrentWptIndex));
 }
Esempio n. 6
0
 public static Waypoint FirstWaypoint()
 {
     if (!hasCurrentWaypoint())
     {
         return(null);
     }
     CurrentWptIndex = 0;
     return((Waypoint)WaypointsWithThumbs.GetByIndex(CurrentWptIndex));
 }
Esempio n. 7
0
        public static Waypoint LastWaypoint()
        {
            if (!hasCurrentWaypoint())
            {
                return(null);
            }
            int count = WaypointsWithThumbs.Count;

            CurrentWptIndex = count - 1;
            return((Waypoint)WaypointsWithThumbs.GetByIndex(CurrentWptIndex));
        }
Esempio n. 8
0
        /// <summary>
        /// rebuilds thumbnails for all photo waypoints, so that size changes can take place
        /// </summary>
        public static void reprocessThumbnails()
        {
            for (int i = 0; i < WaypointsWithThumbs.Count; i++)
            {
                Waypoint wpt = (Waypoint)WaypointsWithThumbs.GetByIndex(i);

// old way:
//				PhotoDescr photoDescr = PhotoDescr.FromFile(wpt.ThumbSource, wpt.Name);
//				wpt.ThumbImage = photoDescr.ThumbnailImage;
//				photoDescr.releaseImage();

                wpt.ThumbImage = PhotoDescr.rebuildThumbnailImage(wpt.ThumbSource);
            }
        }
Esempio n. 9
0
        public static SortedList getWaypointsWithThumbs(long trkid)
        {
            SortedList ret = new SortedList();

            for (int i = 0; i < WaypointsWithThumbs.Count; i++)
            {
                Waypoint wpt = (Waypoint)WaypointsWithThumbs.GetByIndex(i);
                if (wpt.TrackId == trkid)
                {
                    ret.Add(wpt.DateTime, wpt);
                }
            }

            return(ret);
        }
Esempio n. 10
0
        // try to set the pointer to the given waypoint
        public static bool SetCurrentWaypoint(Waypoint wpt)
        {
            if (!hasCurrentWaypoint())
            {
                return(false);
            }

            for (int i = 0; i < WaypointsWithThumbs.Count; i++)
            {
                Waypoint curWpt = (Waypoint)WaypointsWithThumbs.GetByIndex(i);
                if (wpt == curWpt)
                {
                    CurrentWptIndex = i;
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 11
0
 /// <summary>
 /// is called from WaypointsCache, so that the track membership is already taken care of
 /// </summary>
 /// <param name="source"></param>
 public static void RemoveWaypointsByTrackId(long trackId)
 {
     lock (m_waypointsWithThumbs)
     {
         for (int i = WaypointsWithThumbs.Count - 1; i >= 0; i--)
         {
             Waypoint wpt = (Waypoint)WaypointsWithThumbs.GetByIndex(i);
             try
             {
                 if (wpt.TrackId == trackId)
                 {
                     WaypointsWithThumbs.RemoveAt(i);
                 }
             }
             catch
             {
             }
         }
     }
 }
Esempio n. 12
0
 /// <summary>
 /// is called from WaypointsCache, so that the track membership is already taken care of
 /// </summary>
 /// <param name="source"></param>
 public static void RemoveWaypointsBySource(string source)
 {
     lock (m_waypointsWithThumbs)
     {
         for (int i = WaypointsWithThumbs.Count - 1; i >= 0; i--)
         {
             Waypoint wpt = (Waypoint)WaypointsWithThumbs.GetByIndex(i);
             try
             {
                 if (wpt.Source.Equals(source))
                 {
                     WaypointsWithThumbs.RemoveAt(i);
                 }
             }
             catch
             {
             }
         }
     }
 }
Esempio n. 13
0
        public static void cleanPhotoTrackpointsBySource(string sourceFileName)
        {
            for (int i = WaypointsWithThumbs.Count - 1; i >= 0; i--)
            {
                Waypoint wpt       = (Waypoint)WaypointsWithThumbs.GetByIndex(i);
                string   wptSource = wpt.Source;
                if (wptSource.StartsWith(sourceFileName))
                {
                    string rem = wptSource.Substring(sourceFileName.Length);
                    if (rem.IndexOf("\\") <= 0)                         // can start with \, like in "\trip.gpx"
                    {
                        Track trk = WaypointsCache.getTrackById(wpt.TrackId);

                        if (trk != null)
                        {
                            trk.Trackpoints.Remove(wpt.DateTime);
                        }

                        WaypointsWithThumbs.RemoveAt(i);
                    }
                }
                else if (wptSource.IndexOf("\\") <= 0)                          // came from GPS, not from file - try if thumbSource matches
                {
                    string wptImgSource = wpt.ThumbSource;
                    if (wptImgSource.StartsWith(sourceFileName))
                    {
                        Track trk = WaypointsCache.getTrackById(wpt.TrackId);

                        if (trk != null)
                        {
                            trk.Trackpoints.Remove(wpt.DateTime);
                        }

                        WaypointsWithThumbs.RemoveAt(i);
                    }
                }
            }
            hasCurrentWaypoint();               // make sure the pointer is as sane as it can be
        }
Esempio n. 14
0
        public static Waypoint getWaypointById(int id)
        {
            Waypoint ret = null;

            lock (m_waypointsWithThumbs)
            {
                for (int i = WaypointsWithThumbs.Count - 1; i >= 0; i--)
                {
                    Waypoint wpt = (Waypoint)WaypointsWithThumbs.GetByIndex(i);
                    try
                    {
                        if (wpt.Id == id)
                        {
                            ret = wpt;
                            break;
                        }
                    }
                    catch
                    {
                    }
                }
            }
            return(ret);
        }