protected override void OnPaint(PaintEventArgs pe) { using (var g = pe.Graphics) { var gameCountWidth = (int)(this.Width * _gameCountFactor); var gameCountRectF = new RectangleF(0, 0, gameCountWidth, this.Height); var gameCountTextSize = g.MeasureString(GameCount.ToString("0,0"), this.Font); var gameCountTextRectF = new RectangleF(gameCountRectF.Width - gameCountTextSize.Width, 0, gameCountTextSize.Width, this.Height); var whiteRectF = new RectangleF(gameCountWidth, 0, (this.Width - gameCountWidth) * this.WhitePercent / 100, this.Height); var whiteTextSize = g.MeasureString($"{this.WhitePercent}%", this.Font); var whiteTextRectF = new RectangleF(whiteRectF.X + (whiteRectF.Width - whiteTextSize.Width) / 2, 0, whiteTextSize.Width, this.Height); var nullRectF = new RectangleF(gameCountWidth + whiteRectF.Width, 0, (this.Width - gameCountWidth) * this.NullPercent / 100, this.Height); var nullTextSize = g.MeasureString($"{this.NullPercent}%", this.Font); var nullTextRectF = new RectangleF(nullRectF.X + (nullRectF.Width - nullTextSize.Width) / 2, 0, nullTextSize.Width, this.Height); var blackRectF = new RectangleF(gameCountWidth + whiteRectF.Width + nullRectF.Width, 0, this.Width - (gameCountRectF.Width + whiteRectF.Width + nullRectF.Width), this.Height); var blackTextSize = g.MeasureString($"{this.BlackPercent}%", this.Font); var blackTextRectF = new RectangleF(blackRectF.X + (blackRectF.Width - blackTextSize.Width) / 2, 0, blackTextSize.Width, this.Height); // Draw Game Count g.FillRectangle(Brushes.Black, gameCountRectF); if (GameCount == 0) { g.DrawString("??", this.Font, Brushes.Gainsboro, gameCountTextRectF); } else { if (gameCountTextSize.Width < gameCountRectF.Width) { g.DrawString(GameCount.ToString("0,0"), this.Font, Brushes.Gainsboro, gameCountTextRectF); } } // Draw White percentage g.FillRectangle(_whiteBrush, whiteRectF); if (GameCount == 0) { g.DrawString("??", this.Font, Brushes.Black, whiteTextRectF); } else { if (whiteTextSize.Width < whiteRectF.Width) { g.DrawString($"{this.WhitePercent}%", this.Font, Brushes.Black, whiteTextRectF); } } // Draw null percentage g.FillRectangle(_nullBrush, nullRectF); if (GameCount == 0) { g.DrawString("??", this.Font, Brushes.Gainsboro, nullTextRectF); } else { if (nullTextSize.Width < nullRectF.Width) { g.DrawString($"{this.NullPercent}%", this.Font, Brushes.Gainsboro, nullTextRectF); } } // Draw Blacks percentage g.FillRectangle(_blackBrush, blackRectF); if (GameCount == 0) { g.DrawString("??", this.Font, Brushes.Gainsboro, blackTextRectF); } else { if (blackTextSize.Width < blackRectF.Width) { g.DrawString($"{this.BlackPercent}%", this.Font, Brushes.Gainsboro, blackTextRectF); } } g.Flush(); } }
/// <summary> /// Transforms the game record. /// </summary> /// <returns>False is this game record must be skipped (e.g. by RemoveNoShowdown). The game record may be nevertheless partially transformed.</returns> public bool Transform(GameRecord gameRecord) { RenamePlayers(gameRecord); // Now we know the hero int heroPos = GetHeroPos(gameRecord); if (RemoveNoHeroMoves) { bool heroMoved = false; foreach (PokerAction pa in gameRecord.Actions) { if (pa.IsPlayerAction(heroPos)) { heroMoved = true; break; } } if (!heroMoved) { return(false); } } GameState gs = new GameState(gameRecord, null); if (gs.IsGameOver) { if (RemoveNoShowdown && !gs.IsShowdownRequired) { return(false); } } if (HideOpponentCards) { DoHideOpponentCards(gameRecord, heroPos); } if (NormalizeCards) { DoNormalizeCards(gameRecord); } if (ResetResults) { foreach (GameRecord.Player p in gameRecord.Players) { p.Result = 0; } } if (ResetStacks) { foreach (GameRecord.Player p in gameRecord.Players) { p.Stack = 0; } } if (NormalizeStakes >= 0) { double factor = NormalizeStakes; if (NormalizeStakes == 0 && gameRecord.Players.Count >= 2) { factor = gameRecord.Players[1].Blind; } gameRecord.NormalizeStakes(factor); } // Do renaming at the end in case we removed some games. if (RenumerateGames) { gameRecord.Id = GameCount.ToString(); GameCount++; } if (FinalizeGames) { gameRecord.IsGameOver = true; } return(true); }