//Overides parent's class method since text is render in the lower rectangle. //Draws text based on on the space's rotate orientation. public new void RotateDrawText(Graphics g, string str, Rectangle rectangle, Font font, SolidBrush brush, StringFormat format) { Matrix m = new Matrix(); //g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; g.SmoothingMode = SmoothingMode.HighQuality; m.RotateAt((int)rotateOrientation, new PointF(rectangle.X + rectangle.Width / 2, rectangle.Y + rectangle.Height / 2)); g.Transform = m; if (font == null) { font = FormatManager.GetGeneralFont(); } if (rotateOrientation == RotateEnum.Rotate270 || rotateOrientation == RotateEnum.Rotate90) { Rectangle temp = new Rectangle(rectangle.X, rectangle.Y + 25, rectangle.Width, (int)(rectangle.Height * 0.75)); g.DrawString(str, font, brush, temp, format); } else { Rectangle temp = new Rectangle(rectangle.X, rectangle.Y, rectangle.Width, (int)(rectangle.Height * 1)); g.DrawString(str, font, brush, temp, format); } g.ResetTransform(); m.Dispose(); }
public Space(int spaceId, int x, int y, Size size, RotateEnum rotate) : base(x, y, size) { this.spaceId = spaceId; font = FormatManager.GetGeneralFont(); textColor = new SolidBrush(Color.Black); rotateOrientation = rotate; SetIsClickable(true); playersOnSpace = new List <Player>(); //Default text alignment textFormat = new StringFormat(); textFormat.LineAlignment = StringAlignment.Far; textFormat.Alignment = StringAlignment.Center; }
//Rendering player for server games. Includes the client id since server games use //client ids and is used in this method to display the client own infomation along with //the current player's information public void Draw(Graphics g, int xOffset, int yOffset, int currentPlayer, int clientId) { base.Draw(g, xOffset, yOffset); if (playerId == currentPlayer) { g.DrawString("Player " + playerId + " - Total Money - " + totalMoney.ToString("C2"), FormatManager.GetPlayerFont(), new SolidBrush(GetColor()), new PointF(0, 0)); } if (playerId == clientId) { float padding = FormatManager.GetGeneralFont().GetHeight() * 2; g.DrawString("You " + "- Total Money - " + totalMoney.ToString("C2"), FormatManager.GetPlayerFont(), new SolidBrush(GetColor()), new PointF(0, padding)); } }
//Draws text based on on the space's rotate orientation. public void RotateDrawText(Graphics g, string str, Rectangle rectangle, Font font, SolidBrush brush, StringFormat format) { Matrix m = new Matrix(); //g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; g.SmoothingMode = SmoothingMode.HighQuality; m.RotateAt((int)rotateOrientation, new PointF(rectangle.X + rectangle.Width / 2, rectangle.Y + rectangle.Height / 2)); g.Transform = m; if (font == null) { font = FormatManager.GetGeneralFont(); } //Calculates new rectangle with padding for text to be drawn Rectangle temp = new Rectangle(rectangle.X, rectangle.Y + (int)(rectangle.Height * 0.10), rectangle.Width, (int)(rectangle.Height * 0.80)); g.DrawString(str, font, brush, temp, format); g.ResetTransform(); m.Dispose(); }