Пример #1
0
        public void RemoveWaypoint(Waypoint RemoveWp)
        {
            switch (Waypoints.Count)
            {
            case 0:
            case 1:
                break;

            case 2:
                lock (WaypointsTableLock)
                {
                    foreach (Waypoint Wp in Waypoints)
                    {
                        WaypointService.DatabaseDeleteWaypoint(Wp);
                    }
                    Waypoints.Clear();
                }     //lock
                break;

            default:
                lock (WaypointsTableLock)
                {
                    int Index = -1;
                    foreach (Waypoint Wp in Waypoints)
                    {
                        if (Wp.GUID == RemoveWp.GUID)
                        {
                            Index = Waypoints.IndexOf(Wp);
                        }
                    }
                    if (Index != -1)
                    {
                        if (Index != 0)
                        {
                            if (Index == Waypoints.Count)
                            {
                                Waypoints[Index - 1].NextWaypointGUID = 0;
                            }
                            else
                            {
                                Waypoints[Index - 1].NextWaypointGUID = Waypoints[Index].NextWaypointGUID;
                            }

                            WaypointService.DatabaseSaveWaypoint(Waypoints[Index - 1]);
                            WaypointService.DatabaseDeleteWaypoint(Waypoints[Index]);
                            Waypoints.RemoveAt(Index);
                        }
                    }
                }
                // lock (WaypointsTableLock)
                break;
            } // switch
        }
Пример #2
0
 public void SaveWaypoint(Waypoint SaveWp)
 {
     WaypointService.DatabaseSaveWaypoint(SaveWp);
 }