Esempio n. 1
0
 public GpxFileModel(GpxModel parent, string fileName, gpx gpx)
 {
     Parent   = parent;
     Gpx      = gpx;
     FileName = fileName;
     reset();
 }
        public override bool add(GpxModel oldModel, GpxModel newModel, PasteMode mode)
        {
            bool retVal = true;
            int  index;

            switch (mode)
            {
            case PasteMode.BEGINNING: {
                if (newModel is GpxTrackpointModel trkpModel)
                {
                    trkpModel.Parent = this;
                    Trackpoints.Insert(0, trkpModel);
                }
                break;
            }

            case PasteMode.BEFORE: {
                if (newModel is GpxTrackpointModel trkpModel)
                {
                    index = Trackpoints.IndexOf((GpxTrackpointModel)oldModel);
                    if (index == -1)
                    {
                        retVal = false;
                    }
                    else
                    {
                        trkpModel.Parent = this;
                        Trackpoints.Insert(index, trkpModel);
                    }
                }
                break;
            }

            case PasteMode.AFTER: {
                if (newModel is GpxTrackpointModel trkpModel)
                {
                    index            = Trackpoints.IndexOf((GpxTrackpointModel)oldModel);
                    trkpModel.Parent = this;
                    Trackpoints.Insert(index + 1, trkpModel);
                }
                break;
            }

            case PasteMode.END: {
                if (newModel is GpxTrackpointModel trkpModel)
                {
                    trkpModel.Parent = this;
                    Trackpoints.Add(trkpModel);
                }
                break;
            }
            }
            return(retVal);
        }
Esempio n. 3
0
 public GpxTrackpointModel(GpxModel parent, wptType wpt)
 {
     Parent = parent;
     if (wpt == null)
     {
         Trackpoint      = new wptType();
         Trackpoint.name = "New Trackpoint";
     }
     else
     {
         Trackpoint = wpt;
     }
 }
 public GpxWaypointModel(GpxModel parent, wptType wpt)
 {
     Parent = parent;
     if (wpt == null)
     {
         Waypoint      = new wptType();
         Waypoint.name = "New Waypoint";
     }
     else
     {
         Waypoint = wpt;
     }
 }
 public GpxTrackSegmentModel(GpxModel parent, trksegType seg)
 {
     Parent = parent;
     if (seg == null)
     {
         Segment = new trksegType();
     }
     else
     {
         Segment = seg;
     }
     Trackpoints = new List <GpxTrackpointModel>();
     if (Segment.trkpt != null)
     {
         foreach (wptType tkp in Segment.trkpt)
         {
             Trackpoints.Add(new GpxTrackpointModel(this, tkp));
         }
     }
 }
Esempio n. 6
0
 public GpxRouteModel(GpxModel parent, rteType rte)
 {
     Parent = parent;
     if (rte == null)
     {
         Route      = new rteType();
         Route.name = "New Route";
     }
     else
     {
         Route = rte;
     }
     Waypoints = new List <GpxWaypointModel>();
     if (Route.rtept != null)
     {
         foreach (wptType wpt in Route.rtept)
         {
             Waypoints.Add(new GpxWaypointModel(this, wpt));
         }
     }
 }
Esempio n. 7
0
 public GpxTrackModel(GpxModel parent, trkType trk)
 {
     Parent = parent;
     if (trk == null)
     {
         Track      = new trkType();
         Track.name = "New Track";
     }
     else
     {
         Track = trk;
     }
     Segments = new List <GpxTrackSegmentModel>();
     if (Track.trkseg != null)
     {
         foreach (trksegType seg in Track.trkseg)
         {
             Segments.Add(new GpxTrackSegmentModel(this, seg));
         }
     }
 }
Esempio n. 8
0
 public GpxFileModel(GpxModel parent, string fileName)
 {
     Parent   = parent;
     FileName = fileName;
     if (Path.GetExtension(fileName).ToLower().Equals(".tcx"))
     {
         IsTcx = true;
         TrainingCenterDatabase tcx = TrainingCenterDatabase.Load(fileName);
         if (tcx != null)
         {
             Gpx = GpsData.convertTcxToGpx(tcx);
         }
         else
         {
             Utils.errMsg("Failed to convert to GPX: " + NL + fileName);
         }
     }
     else
     {
         Gpx = gpx.Load(fileName);
     }
     reset();
 }
Esempio n. 9
0
 /// <summary>
 /// Adds a new model
 /// </summary>
 /// <param name="oldModel">Used for locating the place in the list to
 /// put the new model. Can be null for PasteMode.BEGINNING
 /// or PasteMode.End.</param>
 /// <param name="newModelThe model to be added."></param>
 /// <param name="mode">PasteMode specifying where in the list to
 /// place the new model relative to the old model.</param>
 /// <returns></returns>
 public abstract bool add(GpxModel oldModel, GpxModel newModel, PasteMode mode);
Esempio n. 10
0
 public override bool add(GpxModel oldModel, GpxModel newModel, PasteMode mode)
 {
     throw new NotImplementedException();
 }
Esempio n. 11
0
        public override bool add(GpxModel oldModel, GpxModel newModel, PasteMode mode)
        {
            bool retVal = true;
            int  index  = -1;

            switch (mode)
            {
            case PasteMode.BEGINNING: {
                if (newModel is GpxTrackModel trkModel)
                {
                    trkModel.Parent = this;
                    Tracks.Insert(0, trkModel);
                }
                if (newModel is GpxRouteModel rteModel)
                {
                    rteModel.Parent = this;
                    Routes.Insert(0, rteModel);
                }
                if (newModel is GpxWaypointModel wptModel)
                {
                    wptModel.Parent = this;
                    Waypoints.Insert(0, wptModel);
                }
                break;
            }

            case PasteMode.BEFORE: {
                if (newModel is GpxTrackModel trkModel)
                {
                    index = Tracks.IndexOf((GpxTrackModel)oldModel);
                    if (index == -1)
                    {
                        retVal = false;
                    }
                    else
                    {
                        trkModel.Parent = this;
                        Tracks.Insert(index, trkModel);
                    }
                }
                if (newModel is GpxRouteModel rteModel)
                {
                    index = Routes.IndexOf((GpxRouteModel)oldModel);
                    if (index == -1)
                    {
                        retVal = false;
                    }
                    else
                    {
                        rteModel.Parent = this;
                        Routes.Insert(index, rteModel);
                    }
                }
                if (newModel is GpxWaypointModel wptModel)
                {
                    index = Waypoints.IndexOf((GpxWaypointModel)oldModel);
                    if (index == -1)
                    {
                        retVal = false;
                    }
                    else
                    {
                        wptModel.Parent = this;
                        Waypoints.Insert(index, wptModel);
                    }
                }
                break;
            }

            case PasteMode.AFTER: {
                if (newModel is GpxTrackModel trkModel)
                {
                    index           = Tracks.IndexOf((GpxTrackModel)oldModel);
                    trkModel.Parent = this;
                    Tracks.Insert(index + 1, trkModel);
                }
                if (newModel is GpxRouteModel rteModel)
                {
                    index           = Routes.IndexOf((GpxRouteModel)oldModel);
                    rteModel.Parent = this;
                    Routes.Insert(index + 1, rteModel);
                }
                if (newModel is GpxWaypointModel wptModel)
                {
                    index           = Waypoints.IndexOf((GpxWaypointModel)oldModel);
                    wptModel.Parent = this;
                    Waypoints.Insert(index + 1, wptModel);
                }
                break;
            }

            case PasteMode.END: {
                if (newModel is GpxTrackModel trkModel)
                {
                    trkModel.Parent = this;
                    Tracks.Add(trkModel);
                }
                if (newModel is GpxRouteModel rteModel)
                {
                    rteModel.Parent = this;
                    Routes.Add(rteModel);
                }
                if (newModel is GpxWaypointModel wptModel)
                {
                    wptModel.Parent = this;
                    Waypoints.Add(wptModel);
                }
                break;
            }
            }
            return(retVal);
        }
Esempio n. 12
0
 public GpxFileSetModel(GpxModel parent)
 {
     Parent = parent;
     Files  = new List <GpxFileModel>();
 }