public Parcours(Map parentMap) : base() { this.forbiddenZones = new ForbiddenZoneCollection(); this.routes = new RouteCollection(); this.nbLine = new Gate(); this.parentMap = parentMap; }
public Parcours(string filepath, Map parentMap) : base() { this.forbiddenZones = new ForbiddenZoneCollection(); this.routes = new RouteCollection(); this.nbLine = new Gate(); this.parentMap = parentMap; this.importFromDxf(filepath); }
public Race(string filename) : base() { competitors = new CompetitorCollection(); competitorGroups = new CompetitorGroupCollection(); flights = new FlightCollection(); map = new Map(); this.loadRace(filename); }
public void Remove(Map item) { items.Remove(item); }
public bool Contains(Map item) { return items.Contains(item); }
public void Add(Map item) { items.Add(item); }
/// <summary> /// Draw the Image of the flights of a Group /// </summary> /// <param name="map"></param> /// <param name="parcours"></param> /// <param name="group"></param> /// <returns></returns> public static Image drawGroupFlights(Race race, Map map, Parcours parcours, CompetitorGroup group) { int competitorCounter = 0; Image img = drawParcours(parcours); Bitmap pg = new Bitmap(img.Width, img.Height); Graphics gr = Graphics.FromImage(pg); // clear the canvas to white Rectangle pgRect = new Rectangle(0, 0, pg.Width, pg.Height); SolidBrush solidWhite = new SolidBrush(Color.White); gr.FillRectangle(solidWhite, pgRect); // load a new image and draw it centered on our canvas Rectangle rc = new Rectangle(0, 0, img.Width, img.Height); gr.DrawImage(img, rc); img.Dispose(); foreach (CompetitorRouteAssignment cra in group.CompetitorRouteAssignmentCollection) { Competitor competitor = cra.Competitor; Flight flight = race.Flights.GetFlightByGroupAndCompetitorId(group, competitor); Pen[] pens = new Pen[] { new Pen(Brushes.Blue, 3.0f), new Pen(Brushes.Aquamarine, 3.0f), new Pen(Brushes.BlueViolet, 3.0f), new Pen(Brushes.DeepSkyBlue, 3.0f) }; Pen penInZone = new Pen(Brushes.LawnGreen, 5.0f); SolidBrush sb = new SolidBrush(Color.FromArgb(50, 250, 00, 20)); double imagePointsLongitudeDifference = map.BottomRightPoint.Longitude - map.TopLeftPoint.Longitude; double imagePointsLatitudeDifference = map.TopLeftPoint.Latitude - map.BottomRightPoint.Latitude; Point[] points = new Point[flight.Track.Count]; DateTime expectedFinishingTime = flight.StartGateTime.AddMinutes(parcours.DefaultTargetFlightDuration.TotalMinutes + 1); int i = 0; bool lastPointWasOffTrack = false; bool passedFinishingGate = false; List<Point> penaltyPoints = new List<Point>(); List<List<Point>> penaltyPointsList = new List<List<Point>>(); foreach (TrackPoint trackPoint in flight.Track) { double currentPointLongitudeDifference = trackPoint.Longitude - map.TopLeftPoint.Longitude; double currentPointLatitudeDifference = map.TopLeftPoint.Latitude - trackPoint.Latitude; double currentPointImageX = (currentPointLongitudeDifference / imagePointsLongitudeDifference) * pg.Width; double currentPointImageY = (currentPointLatitudeDifference / imagePointsLatitudeDifference) * pg.Height; int mapPointX = int.Parse(Math.Ceiling(currentPointImageX).ToString()); int mapPointY = int.Parse(Math.Ceiling(currentPointImageY).ToString()); GraphicsPath p = new GraphicsPath(); foreach (Route route in parcours.Routes) { if (route.EndGate.gatePassed(trackPoint, flight.Track[i + 1]) || trackPoint.TimeStamp > expectedFinishingTime) { passedFinishingGate = true; } } if (!passedFinishingGate && parcours.IsPointOffTrack(trackPoint)) { lastPointWasOffTrack = true; penaltyPoints.Add(new Point(mapPointX, mapPointY)); } else { if (lastPointWasOffTrack) { penaltyPointsList.Add(penaltyPoints); penaltyPoints = new List<Point>(); } lastPointWasOffTrack = false; } points[i] = new Point(mapPointX, mapPointY); if (i < flight.Track.Count - 2) { i++; } } gr.DrawLines(pens[competitorCounter], points); foreach (List<Point> penaltyPts in penaltyPointsList) { Point[] pointarray = penaltyPts.ToArray(); gr.DrawLines(penInZone, pointarray); } competitorCounter++; } return pg; }
private void competitionMapsCmbSelectMaps_SelectedIndexChanged(object sender, EventArgs e) { currentMap = (Map)competitionMapsCmbSelectMaps.SelectedItem; UpdateMapView(); }
void MapLoad_FileOk(object sender, CancelEventArgs e) { string filename = ((OpenFileDialog)sender).FileName; Map map = new Map(filename, competition); competition.MapCollection.Add(map); currentMap = map; UpdateCompetitionMapsCmbSelectMaps(); UpdateMapView(); }
void ImportCompetition_FileOk(object sender, CancelEventArgs e) { IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(((OpenFileDialog)sender).FileName, FileMode.Open, FileAccess.Read, FileShare.Read); competition = (Competition)formatter.Deserialize(stream); stream.Close(); currentCompetitor = null; currentMap = null; currentParcours = null; competitionUpdateBaseData(); UpdateCompetitionMapsCmbSelectMaps(); UpdateCompetitionParcoursCmbParcoursSelection(); UpdateMapView(); UpdateParcoursView(); }
public void loadRace(string filename) { BinaryFormatter binaryFormatter = new BinaryFormatter(); Stream fStream = File.OpenRead(filename); Race r = (Race)binaryFormatter.Deserialize(fStream); this.competitors = r.Competitors; this.competitorGroups = r.CompetitorGroups; this.flights = r.Flights; this.map = r.map; }