Beispiel #1
0
        public Map(string filename, Competition parentCompetition)
            : base()
        {
            Bitmap image = new Bitmap(filename);
            GpsPoint topLeftPoint;
            GpsPoint bottomRightPoint;
            double topLeftLatitude;
            double topLeftLongitude;
            double bottomRightLatitude;
            double bottomRightLongitude;
            string[] coordinatesFromPath = filename.Remove(filename.LastIndexOf(".")).Substring(filename.LastIndexOf(@"\") + 1).Split("_".ToCharArray());
            foreach (string coordinate in coordinatesFromPath)
            {
                if (coordinate.Length != 6 || coordinate == null || coordinate == string.Empty)
                {
                    throw (new FormatException("Coordinates in image name not in correct format!"));
                }
            }
            topLeftLongitude = Convert.ToDouble(coordinatesFromPath[0]);
            topLeftLatitude = Convert.ToDouble(coordinatesFromPath[1]);
            bottomRightLongitude = Convert.ToDouble(coordinatesFromPath[2]);
            bottomRightLatitude = Convert.ToDouble(coordinatesFromPath[3]);
            topLeftPoint = new GpsPoint(topLeftLatitude, topLeftLongitude, GpsPointFormatImport.Swiss);
            bottomRightPoint = new GpsPoint(bottomRightLatitude, bottomRightLongitude, GpsPointFormatImport.Swiss);

            this.image = image;
            this.mapName = filename;
            this.topLeftPoint = topLeftPoint;
            this.bottomRightPoint = bottomRightPoint;
            this.parcoursCollection = new ParcoursCollection();
            this.parentCompetition = parentCompetition;
        }
Beispiel #2
0
 /// <summary>
 /// Creates a Map Object. 
 /// 
 /// </summary>
 /// <param name="image">Bitmap Image of the Location, corresponding to the GPS-Points</param>
 /// <param name="topLeftPoint">GPS Point with the Coordinates of the upper Left Point on the Map Image</param>
 /// <param name="bottomRightPoint">GPS Point with the Coordinates of the lower Right Point on the Map Image</param>
 public Map(Bitmap image, GpsPoint topLeftPoint, GpsPoint bottomRightPoint, Competition parentCompetition)
 {
     this.Image = image;
     this.TopLeftPoint = topLeftPoint;
     this.BottomRightPoint = bottomRightPoint;
     this.parcoursCollection = new ParcoursCollection();
     this.parentCompetition = parentCompetition;
 }
 public GroupCompetitorSelection(Competition competition, Race race)
 {
     InitializeComponent();
     this.race = race;
     this.competition = competition;
     UpdateCmbRaceResults();
     UpdateGridCompetitors(competition.CompetitorCollection);
 }
Beispiel #4
0
 public GroupsForm(Competition competition, Race race, CompetitorGroup group)
 {
     InitializeComponent();
     this.competition = competition;
     this.race = race;
     this.competitorGroup = group;
 }
Beispiel #5
0
        /// <summary>
        /// Creates a Flight Data Sheet for the specified Flight in the PdfSharp.PdfDocument Format.
        /// </summary>
        /// <param name="competitor"></param>
        /// <param name="flight"></param>
        /// <param name="race"></param>
        /// <param name="parcours"></param>
        /// <param name="group"></param>
        /// <returns></returns>
        public static PdfDocument createPdf(Competition competition, Competitor competitor, Flight flight, Race race, Parcours parcours)
        {
            // Create a new PDF document
            PdfDocument document = new PdfDocument();

            // Create an empty page
            PdfPage page = document.AddPage();

            // Get an XGraphics object for drawing
            XGraphics gfx = XGraphics.FromPdfPage(page);

            // Create a font
            XFont font = new XFont("Verdana", 14, XFontStyle.Bold);
            XFont font2 = new XFont("Verdana", 10, XFontStyle.Regular);
            XFont font3 = new XFont("Verdana", 10, XFontStyle.Regular);

            // Draw the text
            string headingText = "Results for " + race.Name + ", " + competition.Date.ToString("dd.MM.yyyy") + " in " + competition.Location;
            gfx.DrawString(headingText, font, XBrushes.DarkMagenta, new XPoint(50, 50), XStringFormat.TopLeft);

            string pilotLine = "Pilot: " + competitor.PilotName + ", " + competitor.PilotFirstName;
            gfx.DrawString(pilotLine, font2, XBrushes.Black, new XPoint(50, 90), XStringFormat.TopLeft);

            string copilotLine = "Navigator: " + competitor.NavigatorName + ", " + competitor.NavigatorFirstName;
            gfx.DrawString(copilotLine, font2, XBrushes.Black, new XPoint(50, 110), XStringFormat.TopLeft);

            string takeoffTime = "Takeoff time: " + flight.TakeOffTime.ToString("HH.mm.ss");
            gfx.DrawString(takeoffTime, font2, XBrushes.Black, new XPoint(50, 130), XStringFormat.TopLeft);

            string startTime = "Start Time: " + flight.StartGateTime.ToString("HH.mm.ss");
            gfx.DrawString(startTime, font2, XBrushes.Black, new XPoint(50, 150), XStringFormat.TopLeft);

            string finishTime = "Finish Time: " + flight.FinishGateTime.ToString("HH.mm.ss");
            gfx.DrawString(finishTime, font2, XBrushes.Black, new XPoint(250, 150), XStringFormat.TopLeft);

            Image image = Common.drawFlight(parcours.ParentMap, parcours, flight);
            int originalHeight = image.Height;
            int originalWidth = image.Width;
            XImage xImage = XImage.FromGdiPlusImage(image);
            double ratio = (double)image.Height / (double)image.Width;
            int height = (int)Math.Ceiling((page.Width.Point - 100) * ratio);
            gfx.DrawImage(xImage, 50, 180, page.Width.Point - 100, height);

            gfx.DrawString("Penalties", font2, XBrushes.Black, 50, height + 200);
            int position = height + 220;
            int i = 0;

            foreach (Penalty penalty in flight.AutomaticPenalties)
            {
                if ((position + i * 20) <= page.Height.Point - 50)
                {
                    gfx.DrawString(penalty.PenaltyPoints.ToString(), font3, XBrushes.Gray, 60, (position + i * 20));
                    gfx.DrawString(penalty.PenaltyType.ToString() + ", " + penalty.Comment, font2, XBrushes.Gray, 120, (position + i * 20));
                    i++;
                }
                else
                {
                    page = document.AddPage();
                    gfx = XGraphics.FromPdfPage(page);
                    i = 0;
                    position = 50;
                }
            }
            return document;
        }
Beispiel #6
0
 /// <summary>
 /// Saves the specified PdfDocument to a specified Location.
 /// </summary>
 /// <param name="doc">PfdDocument to save</param>
 /// <param name="filename">Filepath (e.g. C:\flight.pdf). String must contain file Ending</param>
 public static void savePdf(Competition competition, Competitor competitor, Flight flight, Race race, Parcours parcours, string filename)
 {
     createPdf(competition, competitor, flight, race, parcours).Save(filename);
 }
Beispiel #7
0
        public AirNavRace()
        {
            competition = new Competition();

            InitializeComponent();
            InitBindings();
            //InitCompetitionForm();
        }
Beispiel #8
0
 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();
 }