public void LoadCourses() { bool tempFlag = true; if (saves == null) { return; } foreach (clsSlot CurrentSlot in saves.slot) { if (CurrentSlot.IsUsed.ToLower() != "true") { continue; } clsCourse CurrentCourse = new clsCourse(); CurrentCourse = clsXmlSaveLoad.DeserializeXmlFromFile <clsCourse>(Path + System.IO.Path.DirectorySeparatorChar + CurrentSlot.FileName); CurrentSlot.course = CurrentCourse; if (tempFlag) { CurrentSlot.course.IsDisplayed = true; //tempFlag = false; } } }
public List <clsWaypoint> DrawCourse(clsCourse Course, Graphics g, Rectangle Client, Rectangle ViewPort, List <clsWaypoint> SelectedWaypoints, int Quality) { //TODO: Draw On seperate surface? Prerender a waypoint marker in each color. Blit to screen. clsWaypoint PreviousWaypoint = null; Matrix TransformMatrix = new Matrix(); Matrix PenMatrix = new Matrix(); Pen CurrentPen; clsWaypoint CurrentWaypoint = Course.waypoint[0]; List <clsWaypoint> ReturnList = new List <clsWaypoint>(); TransformMatrix.Translate(((MapSize.Width / 2) - (ViewPort.X)) * ZoomFactor, ((MapSize.Height / 2) - (ViewPort.Y)) * ZoomFactor); TransformMatrix.Scale(ZoomFactor, ZoomFactor); g.Transform = TransformMatrix; PenMatrix = TransformMatrix.Clone(); PenMatrix.Invert(); CurrentPen = pens[PenModifier.Default]; CurrentPen.Transform = PenMatrix; for (int i = 0; i < Course.waypoint.Count; i++) { PenModifier CurrentModifier; if (i != 0 && i < Course.waypoint.Count) { PreviousWaypoint = CurrentWaypoint; CurrentWaypoint = Course.waypoint[i]; } if (IsOnScreen(CurrentWaypoint.position, ViewPort)) { ReturnList.Add(CurrentWaypoint); if (i == 0) { CurrentModifier = PenModifier.Start; } else if (i == Course.waypoint.Count - 1) { CurrentModifier = PenModifier.End; } else { CurrentModifier = GetPenModifierForWaypoint(CurrentWaypoint); } if (SelectedWaypoints != null && SelectedWaypoints.Contains(CurrentWaypoint)) { CurrentModifier = PenModifier.Selected; } g.DrawImage(WaypointMarkers[CurrentModifier], CurrentWaypoint.position); if (PreviousWaypoint != null) { g.DrawLine(CurrentPen, PreviousWaypoint.position, CurrentWaypoint.position); } } else { if (PreviousWaypoint != null && IsOnScreen(PreviousWaypoint.position, ViewPort)) { g.DrawLine(CurrentPen, PreviousWaypoint.position, CurrentWaypoint.position); } } if (Quality < 2) { i += 2; } } //TransformMatrix.Reset(); TransformMatrix.Invert();//TransformMatrix.Translate((MapSize.Width / 2) * -1, (MapSize.Height / 2) * -1); TransformMatrix.Scale(1, 1); g.Transform = TransformMatrix; return(ReturnList); }