Example #1
0
        protected void CalculateSizesAndLoadFonts()
        {
            float windowHeight = this.Height;

              // Reserve part of the top screen space for the status text
              windowHeight *= 0.93f;

              playerSlotSize = this.Width / (double)playersPerSectionRow;
              playerSize = playerSlotSize * 0.9;
              playerSectionHeight = playerSlotSize * Math.Ceiling((double)Settings.Players / (double)playersPerSectionRow);
              playerSectionTop = this.Height - playerSectionHeight;

              foodSize = playerSize * 0.5;
              foodOffset = foodSize * 0.1;

              // Calculate plot layout
              plotAreaTop = this.Height - windowHeight;
              double plotAreaHeight = windowHeight - playerSectionHeight;
              double plotWidth = 0, plotHeight = 0, plotsPerRow = 0;

              switch (plots.Length)
              {
            case 4:
            case 10:
              plotsPerRow = 2;
              break;

            case 6:
            case 9:
              plotsPerRow = 3;
              break;

            case 8:
              plotsPerRow = 4;
              break;

            default:
              plotsPerRow = plots.Length;
              break;
              }

              plotWidth = this.Width / plotsPerRow;
              plotHeight = plotAreaHeight / ((double)plots.Length / plotsPerRow);

              // Load fonts
              float plotNumberFontSize = Math.Min(400.0f, (float)Math.Min(plotWidth, plotHeight) * 0.75f);
              plotNumberFont = new Font(FontFamily.GenericMonospace, plotNumberFontSize, FontStyle.Bold);

              plotNumberExtents = plotPrinter.Measure("0", plotNumberFont);

              // Set up plots
              for (int plotIndex = 0; plotIndex < plots.Length; plotIndex++)
              {
            plots[plotIndex] = new RectangleF(
              (float)((plotIndex % plotsPerRow) * plotWidth),
              (float)(plotAreaTop + ((plotIndex / (int)plotsPerRow) * plotHeight)),
              (float)plotWidth, (float)plotHeight
            );

            plotNumberOffsets[plotIndex] = new PointF(
              (float)Math.Truncate((plotWidth - plotNumberExtents.BoundingBox.Width) / 2.0),
              (float)Math.Truncate((plotHeight - plotNumberExtents.BoundingBox.Height) / 2.0)
            );
              }

              statusFont = new Font(FontFamily.GenericMonospace, (float)plotAreaTop * 0.55f, FontStyle.Bold);

              var statusExtents = statusPrinter.Measure("00:00", statusFont);
              statusTextPoint.X = (float)Math.Truncate((this.Width - statusExtents.BoundingBox.Width) / 2.0);
              statusTextPoint.Y = (float)Math.Truncate((plotAreaTop - statusExtents.BoundingBox.Height) / 2.0);

              scoreFont = new Font(FontFamily.GenericMonospace, (float)playerSlotSize * 0.5f, FontStyle.Bold);
              foodCountFont = new Font(FontFamily.GenericMonospace, (float)foodSize * 0.5f, FontStyle.Bold);
        }
Example #2
0
 internal TextExtents Clone()
 {
     TextExtents extents = new TextExtents();
     extents.glyph_extents.AddRange(GlyphExtents);
     extents.BoundingBox = BoundingBox;
     return extents;
 }