示例#1
0
 private void assignTableauBreakIndex(FRCTableauPart tableauPart, out int tableauBreakIdx)
 {
     if (tableauPart.Length == 128)
     {
         tableauBreakIdx = 2;
     }
     else if (tableauPart.Length == 64)
     {
         tableauBreakIdx = 2;
     }
     else if (tableauPart.Length == 32)
     {
         tableauBreakIdx = 1;
     }
     else
     {
         tableauBreakIdx = 3;
     }
 }
示例#2
0
        /// <summary>
        /// A method to be called from interpretTableau().
        /// </summary>
        private void interpretLengthInTableau()
        {
            FRCTableauPart tPart = new FRCTableauPart();

            while (reader.MoveToNextAttribute())
            {
                if (reader.Name == TITRE)
                {
                    tPart.Title = reader.Value;
                }
                else if (reader.Name == TAILLE)
                {
                    tPart.Length = int.Parse(reader.Value);
                }

                //Console.Write(" " + reader.Name + "='" + reader.Value + "'");
            }
            tableau[tableau.Count - 1].addTableauPart(tPart);
            //Just to increment the index of list in tableau.
            tableau[tableau.Count - 1].getNextTableauPart();
        }
示例#3
0
文件: FRCTableau.cs 项目: RobinK2/FRC
 /// <summary>
 /// Add tableau part.
 /// </summary>
 /// <param name="tableauPart"></param>
 public void addTableauPart(FRCTableauPart tableauPart)
 {
     this.tableauPart.Add(tableauPart);
 }
示例#4
0
        private void drawTableauPartOnTableauPart(XGraphics graphics, XFont font, FRCTableauPart tableauPart, double tableauWidth,
                                                  double tableauSpace, int partNumber, string title, double titleX, double titleY)
        {
            FRCMatch  match;
            FRCFencer fencer1, fencer2, winner;
            double    fontHeight        = font.GetHeight();
            int       endPointIdx       = 0;
            int       tableauSize       = tableauPart.Length;
            int       iterationsPerPage = tableauSize / tableauPageCounter;

            FRCFencer[] ft = fencerInTableau.ToArray();
            fencerInTableau.Clear();

            for (int i = 0; i < tableauSize; i += 2)
            {
                XPoint point = tableauEndPoint[endPointIdx];
                if ((i >= iterationsPerPage) && (i % iterationsPerPage == 0))
                {
                    graphics.Dispose();
                    pageIdx++;
                    graphics = XGraphics.FromPdfPage(document.Pages[pageIdx]);
                    graphics.DrawString(title, font, XBrushes.Black, titleX, titleY, XStringFormats.TopLeft);
                }

                fencer1 = ft[i];
                fencer2 = ft[i + 1];
                string name, score;

                tableauEndPoint[endPointIdx] = drawTableauLines(graphics, point, tableauSpace * Math.Pow(2, partNumber), tableauWidth, tableauWidth);
                XPoint endPoint = tableauEndPoint[endPointIdx];
                endPointIdx += (int)Math.Pow(2, partNumber);

                if (fencer1 == null && fencer2 == null)
                {
                    winner = null;
                    name   = "----------";
                    score  = "";
                }
                else if (fencer1 == null)
                {
                    winner = fencer2;
                    name   = fencer2.LastName.ToUpper() + " " + fencer2.FirstName;
                    score  = "";
                }
                else if (fencer2 == null)
                {
                    winner = fencer1;
                    name   = fencer1.LastName.ToUpper() + " " + fencer1.FirstName;
                    score  = "";
                }
                else
                {
                    match   = tableauPart.getNextMatch();
                    fencer1 = getFencerFromTableauMatchingID(match.FencerID1);
                    fencer2 = getFencerFromTableauMatchingID(match.FencerID2);
                    if (match.Fencer1Win)
                    {
                        winner = fencer1;
                        name   = fencer1.LastName.ToUpper() + " " + fencer1.FirstName;
                        if (match.Fencer2Abandon)
                        {
                            score = "by abandonment";
                        }
                        else if (match.Fencer2Forfait)
                        {
                            score = "by scratch";
                        }
                        else if (match.Fencer2Exclusion)
                        {
                            score = "by exclusion";
                        }
                        else
                        {
                            score = match.ScoreFencer1.ToString() + "/" + match.ScoreFencer2.ToString();
                        }
                    }
                    else
                    {
                        winner = fencer2;
                        name   = fencer2.LastName.ToUpper() + " " + fencer2.FirstName;
                        if (match.Fencer1Abandon)
                        {
                            score = "by abandonment";
                        }
                        else if (match.Fencer1Forfait)
                        {
                            score = "by scratch";
                        }
                        else if (match.Fencer1Exclusion)
                        {
                            score = "by exclusion";
                        }
                        else
                        {
                            score = match.ScoreFencer2.ToString() + "/" + match.ScoreFencer1.ToString();
                        }
                    }
                }

                if (name.Length > 18)
                {
                    name = name.Remove(18);
                }

                fencerInTableau.Add(winner);
                graphics.DrawString(name, font, XBrushes.Black, endPoint.X + 5, endPoint.Y - 2);
                graphics.DrawString(score, font, XBrushes.Black, endPoint.X + 15, endPoint.Y + fontHeight);
            }
            graphics.Dispose();
        }
示例#5
0
        /// <summary>
        /// Should be used to draw the first tableau part.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="font"></param>
        /// <param name="fontClub"></param>
        /// <param name="tableauPart"></param>
        /// <param name="qualifiers"></param>
        /// <param name="tableauWidth"></param>
        /// <param name="tableauSpace"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="title"></param>
        /// <param name="titleY"></param>
        private void drawTableauPart(XGraphics graphics, XFont font, XFont fontClub, FRCTableauPart tableauPart, int qualifiers,
                                     double tableauWidth, double tableauSpace, double x, double y, string title, double titleY)
        {
            FRCMatch  match;
            FRCFencer fencer1, fencer2, winner;
            double    fontHeight = font.GetHeight();
            double    totalY;

            currentYCoordinate = y;
            int endPointIdx = 0;
            int rank1, rank2;
            int tableauSize = tableauPart.Length;

            interpreter.Tableau.calculateTableauNumbers(tableauSize);
            FRCFencer[] ft = fencerInTableau.ToArray();
            fencerInTableau.Clear();

            for (int i = 0; i < tableauSize; i += 2)
            {
                totalY              = currentYCoordinate + tableauSpace * 2;
                graphics            = checkYCoordinate(graphics, totalY);
                currentYCoordinate += tableauSpace;

                if (pageAdded)
                {
                    graphics.DrawString(title, font, XBrushes.Black, (x + tableauWidth) / 2, titleY, XStringFormats.TopLeft);
                    currentYCoordinate += fontHeight;
                    pageAdded           = false;
                }

                string name1, name2, name3, club1, club2, score;
                rank1 = interpreter.Tableau.getTableauNumber(i);
                rank2 = interpreter.Tableau.getTableauNumber(i + 1);
                if (!onlyOnce)
                {
                    fencer1 = getFencerFromTableauMatchingInitialRanking(rank1);
                    fencer2 = getFencerFromTableauMatchingInitialRanking(rank2);
                }
                else
                {
                    fencer1 = ft[i];
                    fencer2 = ft[i + 1];
                }

                if (fencer1 == null)
                {
                    name1 = "----------";
                    club1 = "";
                }
                else
                {
                    name1 = fencer1.LastName.ToUpper() + " " + fencer1.FirstName;
                    club1 = fencer1.Club;
                    if (name1.Length > 22)
                    {
                        name1 = name1.Remove(22);
                    }
                    if (club1.Length > 15)
                    {
                        club1 = club1.Remove(15);
                    }
                }
                if (fencer2 == null)
                {
                    name2 = "----------";
                    club2 = "";
                }
                else
                {
                    name2 = fencer2.LastName.ToUpper() + " " + fencer2.FirstName;
                    club2 = fencer2.Club;
                    if (name2.Length > 22)
                    {
                        name2 = name2.Remove(22);
                    }
                    if (club2.Length > 15)
                    {
                        club2 = club2.Remove(15);
                    }
                }

                if (fencer1 == null && fencer2 == null)
                {
                    winner = null;
                    name3  = "----------";
                    score  = "";
                }
                else if (fencer1 == null)
                {
                    winner = fencer2;
                    name3  = fencer2.LastName.ToUpper() + " " + fencer2.FirstName;
                    score  = "";
                }
                else if (fencer2 == null)
                {
                    winner = fencer1;
                    name3  = fencer1.LastName.ToUpper() + " " + fencer1.FirstName;
                    score  = "";
                }
                else
                {
                    match = tableauPart.getNextMatch();
                    //Skip matches with REF=0 in extended format of xml file.
                    while (match.FencerID1 == 0 || match.FencerID2 == 0)
                    {
                        match = tableauPart.getNextMatch();
                    }

                    fencer1 = getFencerFromTableauMatchingID(match.FencerID1);
                    fencer2 = getFencerFromTableauMatchingID(match.FencerID2);
                    if (match.Fencer1Win)
                    {
                        winner = fencer1;
                        name3  = fencer1.LastName.ToUpper() + " " + fencer1.FirstName;
                        if (match.Fencer2Abandon)
                        {
                            score = "by abandonment";
                        }
                        else if (match.Fencer2Forfait)
                        {
                            score = "by scratch";
                        }
                        else if (match.Fencer2Exclusion)
                        {
                            score = "by exclusion";
                        }
                        else
                        {
                            score = match.ScoreFencer1.ToString() + "/" + match.ScoreFencer2.ToString();
                        }
                    }
                    else
                    {
                        winner = fencer2;
                        name3  = fencer2.LastName.ToUpper() + " " + fencer2.FirstName;
                        if (match.Fencer1Abandon)
                        {
                            score = "by abandonment";
                        }
                        else if (match.Fencer1Forfait)
                        {
                            score = "by scratch";
                        }
                        else if (match.Fencer1Exclusion)
                        {
                            score = "by exclusion";
                        }
                        else
                        {
                            score = match.ScoreFencer2.ToString() + "/" + match.ScoreFencer1.ToString();
                        }
                    }
                }

                if (name3.Length > 18)
                {
                    name3 = name3.Remove(18);
                }

                fencerInTableau.Add(winner);

                tableauEndPoint.Add(drawTableauLines(graphics, new XPoint(x, currentYCoordinate), tableauSpace, tableauWidth,
                                                     tableauWidth * 0.7));
                graphics.DrawString(rank1.ToString(), font, XBrushes.Black, x, currentYCoordinate - 2);
                graphics.DrawString(name1, font, XBrushes.Black, x + 20, currentYCoordinate - 2);
                graphics.DrawString(club1, fontClub, XBrushes.Black, x + 20, currentYCoordinate + fontHeight * 0.8);
                currentYCoordinate += tableauSpace;
                graphics.DrawString(rank2.ToString(), font, XBrushes.Black, x, currentYCoordinate - 2);
                graphics.DrawString(name2, font, XBrushes.Black, x + 20, currentYCoordinate - 2);
                graphics.DrawString(club2, fontClub, XBrushes.Black, x + 20, currentYCoordinate + fontHeight * 0.8);

                XPoint point = tableauEndPoint[endPointIdx];
                endPointIdx++;
                graphics.DrawString(name3, font, XBrushes.Black, point.X + 5, point.Y - 2);
                graphics.DrawString(score, font, XBrushes.Black, point.X + 15, point.Y + fontHeight);
            }
            onlyOnce = true;
            graphics.Dispose();
        }
示例#6
0
        /// <summary>
        /// Prints the tableau.
        /// </summary>
        private void printTableau()
        {
            tableauStarted = true;
            //Starting on a new page if the given page is not empty.
            if (currentYCoordinate > pageTopSize)
            {
                currentYCoordinate = 810;
            }

            XGraphics graphics     = XGraphics.FromPdfPage(getCurrentPage());
            XFont     font         = new XFont(FONT_TYPE, 10);
            XFont     fontClub     = new XFont(FONT_TYPE, 9);
            double    fontHeight   = font.GetHeight();
            double    x            = DEFAULT_START_X;
            double    titleY       = currentYCoordinate;
            double    tableauWidth = TABLEAU_WIDTH;
            double    tableauSpace = TABLEAU_SPACE;
            string    title;

            pageAdded = false;
            //Checks and fixes if two fencers has same ranking.
            interpreter.Tableau.checkRankingIND();

            FRCTableauPart tableauPart = interpreter.Tableau.getNextTableauPart();

            if (tableauPart.Length == 2)
            {
                title = FRCPrinterConstants.Final;
            }
            else if (tableauPart.Length == 4)
            {
                title = FRCPrinterConstants.SEMI_FINALS;
            }
            else
            {
                title = FRCPrinterConstants.TABLE_OF + " " + tableauPart.Length.ToString();
            }

            if (tableauPart.Length > 16)
            {
                font         = new XFont(FONT_TYPE, 8.5);
                fontClub     = new XFont(FONT_TYPE, 7);
                fontHeight   = font.GetHeight();
                tableauSpace = tableauSpace * 0.68;
                tableauWidth = tableauWidth * 0.9;
            }

            graphics.DrawString(title, font, XBrushes.Black, (x + tableauWidth) / 2, titleY, XStringFormats.TopLeft);
            currentYCoordinate += fontHeight;
            tableauEndPoint.Clear();
            //Draws the first part of tableau on the page.
            drawTableauPart(graphics, font, fontClub, tableauPart, interpreter.Tableau.amountOfFencers(), tableauWidth, tableauSpace,
                            x, currentYCoordinate, title, titleY);
            x           += tableauWidth * 1.8;
            tableauWidth = tableauWidth * 0.7;

            //Index for building tableau.
            int tableauBreakIdx;

            assignTableauBreakIndex(tableauPart, out tableauBreakIdx);

            //Builds with several tableau parts on the first part.
            for (int i = 0; i < tableauBreakIdx; i++)
            {
                if (interpreter.Tableau.hasNextTableauPart())
                {
                    tableauPart = interpreter.Tableau.getNextTableauPart();
                    if (tableauPart.Length == 2)
                    {
                        title = FRCPrinterConstants.Final;
                    }
                    else if (tableauPart.Length == 4)
                    {
                        title = FRCPrinterConstants.SEMI_FINALS;
                    }
                    else
                    {
                        title = FRCPrinterConstants.TABLE_OF + " " + tableauPart.Length.ToString();
                    }

                    pageIdx  = document.Pages.Count - tableauPageCounter;
                    graphics = XGraphics.FromPdfPage(document.Pages[pageIdx]);
                    graphics.DrawString(title, font, XBrushes.Black, (x + tableauWidth) / 1.9, titleY, XStringFormats.TopLeft);
                    drawTableauPartOnTableauPart(graphics, font, tableauPart, tableauWidth, tableauSpace, i + 1, title, (x + tableauWidth) / 1.9, titleY);
                    x += tableauWidth * 2;
                }
            }

            tableauPageCounter = 0;
            graphics.Dispose();
        }