private void PasteStatsMenuItem_Click(object sender, EventArgs e) { if (_damageTracker == null) { return; } var playerStatsSequence = _damageTracker.OrderByDescending(playerStats => playerStats.Dealt.Damage).TakeWhile(x => x.Dealt.Damage > 0); const int maxLength = 300; var sb = new StringBuilder(); bool first = true; foreach (var playerInfo in playerStatsSequence) { var placeHolder = DamagePlaceHolders.FromPlayerInfo(playerInfo, FormatHelpers.Invariant); var playerText = first ? "" : " | "; playerText += placeHolder.Replace("{Name} {Damage} {DPS} {DamagePercent}"); if (sb.Length + playerText.Length > maxLength) { break; } sb.Append(playerText); first = false; } var text = sb.ToString(); TeraWindow.SendString(text); }
protected override void OnPaint(PaintEventArgs e) { var formatHelpers = FormatHelpers.Pretty; var placeHolder = DamagePlaceHolders.FromPlayerInfo(PlayerInfo, formatHelpers); var graphics = e.Graphics; var rect = ClientRectangle; using (var backBrush = new SolidBrush(BackColor)) { graphics.FillRectangle(backBrush, rect); } if (PlayerInfo == null) { return; } var highlightRect = new Rectangle(rect.Left, rect.Top, (int)Math.Round(rect.Width * PlayerInfo.DamageFraction), rect.Height); using (var highlightBrush = new SolidBrush(HighlightColor)) { graphics.FillRectangle(highlightBrush, highlightRect); } var iconWidth = (int)(rect.Height * 0.8); graphics.DrawImage(ClassIcons.GetImage(PlayerInfo.Class), (iconWidth - ClassIcons.Size) / 2, (rect.Height - ClassIcons.Size) / 2); var textRect = Rectangle.FromLTRB(rect.Left + iconWidth, rect.Top, rect.Right, rect.Bottom); using (var bigFont = new Font(Font.FontFamily, (int)Math.Round(rect.Height * 0.34), GraphicsUnit.Pixel)) using (var smallFont = new Font(Font.FontFamily, (int)Math.Round(rect.Height * 0.25), GraphicsUnit.Pixel)) using (var textBrush = new SolidBrush(ForeColor)) { var row1LeftText = placeHolder.Replace(Strings.PlayerBoxLeftLine1); var row2RightText = placeHolder.Replace(Strings.PlayerBoxRightLine1); var row2LeftText = placeHolder.Replace(Strings.PlayerBoxLeftLine2); var row3LeftText = placeHolder.Replace(Strings.PlayerBoxLeftLine3); var row3RightText = placeHolder.Replace(Strings.PlayerBoxRightLine3); var row1Y = (float)Math.Round(textRect.Top + 0.00 * textRect.Height); var row2Y = (float)Math.Round(textRect.Top + 0.36 * textRect.Height); var row3Y = (float)Math.Round(textRect.Top + 0.64 * textRect.Height); graphics.DrawString(row1LeftText, bigFont, textBrush, textRect.Left, row1Y); graphics.DrawString(row2LeftText, smallFont, textBrush, textRect.Left, row2Y); graphics.DrawString(row3LeftText, smallFont, textBrush, textRect.Left, row3Y); float x = textRect.Right; x = DrawStringRightToLeft(graphics, row2RightText, bigFont, textBrush, x, textRect.Top); x = textRect.Right; x = DrawStringRightToLeft(graphics, formatHelpers.FormatValue(PlayerInfo.Dealt.Damage), smallFont, Brushes.Red, x, row2Y); if (PlayerInfo.Dealt.Heal != 0) { x = DrawStringRightToLeft(graphics, "+", smallFont, textBrush, x, row2Y); x = DrawStringRightToLeft(graphics, formatHelpers.FormatValue(PlayerInfo.Dealt.Heal), smallFont, Brushes.LawnGreen, x, row2Y); } x = textRect.Right; x = DrawStringRightToLeft(graphics, row3RightText, smallFont, textBrush, x, row3Y); } }