private Panel CreateRankingsOverlay(string text)
        {
            RunHistoryLine lastHistoryLine = historyLines[HistoryLineCount - 1];

            Point topLeft     = competitorNumberCaptionPanel.Location;
            Point bottomRight = lastHistoryLine.Location + lastHistoryLine.Size;

            return(new Panel
            {
                Location = topLeft,
                Size = new Size(bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y),
                BackColor = Color.DarkRed,
                Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
                BorderStyle = BorderStyle.FixedSingle,
                Controls =
                {
                    new AutoScalingLabel
                    {
                        Text = text,
                        ForeColor = Color.White,
                        Dock = DockStyle.Fill,
                        TextAlign = ContentAlignment.MiddleCenter
                    }
                }
            });
        }
Example #2
0
        private void RecreateScrollableRunHistoryLines(IReadOnlyCollection <CompetitionRunResult> runResults)
        {
            UpdateScrollingPanel(() =>
            {
                scrollingPanel.ClearInnerControls();

                int heightOffset    = 0;
                int minControlCount = (int)Math.Truncate((decimal)scrollingPanel.Height / ControlHeightIncrement);

                for (int index = 0; index < Math.Max(minControlCount, runResults.Count); index++)
                {
                    var runHistoryLine = new RunHistoryLine
                    {
                        Anchor   = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
                        Location = new Point(2, heightOffset),
                        Name     = $"runHistoryLine{index:0000}",
                        Size     = new Size(ClientSize.Width - 4, 51)
                    };

                    CompetitionRunResult?runResult = runResults.ElementAtOrDefault(index);

                    if (runResult != null)
                    {
                        runHistoryLine.SetCompetitionRunResult(runResult);
                    }
                    else
                    {
                        runHistoryLine.ClearCompetitionRunResult();
                    }

                    scrollingPanel.AddToInnerControls(runHistoryLine);
                    heightOffset += ControlHeightIncrement;
                }
            });
        }