示例#1
0
        private void Draw(object sender, DrawGraphicsEventArgs e)
        {
            var gfx = e.Graphics;

            gfx.ClearScene(_brushes["transparent"]);

            float x          = 0f;
            float incrementY = 25f;
            float leaderboardStatsOffsetX = 250f;
            float y = 0 + incrementY;

            // stats drawing
            //gfx.ClearScene(_brushes["stats_background"]);
            // data limit
            gfx.DrawTextWithBackground(_fonts["consolas"],
                                       _brushes["gray"],
                                       _brushes["stats_background"],
                                       x,
                                       y,
                                       $"Data limit: {Math.Round(StatsDataStore.DataUsed, 2)}%");
            y += incrementY;

            // custom messages if any
            CustomMessages.ForEach(m =>
            {
                gfx.DrawTextWithBackground(_fonts["consolas"],
                                           _brushes["gray"],
                                           _brushes["stats_background"],
                                           x,
                                           y,
                                           m);
                y += incrementY;
            });

            // headers
            gfx.DrawTextWithBackground(_fonts["consolas"],
                                       _brushes["white"],
                                       _brushes["stats_background"],
                                       x,
                                       y,
                                       BuildHeader().ToString());
            y += incrementY;

            // stats
            StatsDataStore
            .GetData()
            .OrderBy(d => d.Stats.Value)
            .Select(r => BuildEntryRowString(r)).ToList()
            .ForEach(r =>
            {
                var(displayString, data) = r;
                gfx.DrawTextWithBackground(_fonts["consolas"],
                                           _brushes[GetColor(data)],
                                           _brushes["stats_background"],
                                           x,
                                           y,
                                           displayString.ToString());
                y += incrementY;
            });

            // leaderboard drawing
            // reset coords
            x = 0;
            y = 0 + incrementY;
            // headers
            gfx.DrawTextWithBackground(_fonts["consolas"],
                                       _brushes["white"],
                                       _brushes["stats_background"],
                                       x + leaderboardStatsOffsetX,
                                       y,
                                       BuildHeaderLeaderboard().ToString());
            y += incrementY;
            // sub header
            gfx.DrawTextWithBackground(_fonts["consolas"],
                                       _brushes["light gray"],
                                       _brushes["stats_background"],
                                       x + leaderboardStatsOffsetX,
                                       y,
                                       BuildSubHeaderLeaderboard().ToString());
            y += incrementY;
            // leaderboard pos
            StatsDataStore
            .GetDataLeaderboard()
            .OrderBy(d => d.PositionType)
            .Select(r => BuildEntryRowString(r)).ToList()
            .ForEach(r =>
            {
                // main line
                var(posLine, data) = r;
                gfx.DrawTextWithBackground(_fonts["consolas"],
                                           _brushes[GetColor(data)],
                                           _brushes["stats_background"],
                                           x + leaderboardStatsOffsetX,
                                           y,
                                           posLine.ToString());
                y += incrementY;
                // sub lines
                var detailLines = data.Positions.Select(p => BuildEntryDetailRowString(p));
                foreach (var line in detailLines)
                {
                    var(sb, detailData) = line;
                    gfx.DrawTextWithBackground(_fonts["consolas"],
                                               detailData.Roe > 0 ? _brushes["dimmed green"] : _brushes["dimmed red"],
                                               _brushes["stats_background"],
                                               x + leaderboardStatsOffsetX,
                                               y,
                                               sb.ToString());
                    y += incrementY;
                }
            });

            var(xOffset, yOffset) = WindowDataStore.GetLastOffets();
            _window.X            += xOffset;
            _window.Y            += yOffset;
        }