private void RecordWaypoint(int interval, string pathName, GatherWindow Gwindow) { if (RecordFlag) { return; } // Set recording as true. RecordFlag = true; // Get ID of current zone. var zoneId = Marshal.ReadInt32(NativeStructs.ZoneAddress); // Check if we need to make a new Zone entry. var nozones = _Waypoints.Zone.All(p => p.ID != zoneId); // We need to make a new entry. if (nozones) { // Add new Zone entry for our current zone. _Waypoints.Zone.Add(new Zones(zoneId)); // Add an empty Path entry. _Waypoints.AddPathToZone(zoneId, pathName); // This is a new entry, so grab the last Zone we added, and the first Path in that Zone, // Then start adding new Point entries (at the rate of the given interval), and wait for the user to click stop. _Waypoints.Zone.Last().Path.First().AddPoints(interval, Gwindow); } else { // We already have the Zone in our xml, so lets go strait to adding points. _Waypoints.Zone.First(p => p.ID == zoneId).AddPoints(pathName, interval, Gwindow); } // If this is a single add, just reset the record flag and save the xml. if (interval == 0) { StopRecord(); } }