//void new() public sTileTriangle(oTile.TileDiv StartDiv, int StartNumber) { this.zzzTheTileDiv = StartDiv; this.zzzTheNumber = StartNumber; this.zzzTheTriangleColor = new sTileTriangleColor(Color.Black, Color.White); this.RefreshVariable(); }
//optien un seul triangle d'une tile en fonction du nombre et la position du triangle public static Bitmap GetBitmapForTriangle(oTile.TileDiv TheDiv, int TheNumber) { int twidth = oTile.TileWidth; int twidth2 = twidth / 2; Bitmap img = new Bitmap(twidth, twidth); img.MakeTransparent(); Graphics g = Graphics.FromImage(img); //fait quelque truc que tout le monde aura ou pourait avoir besoin string Text = TheNumber.ToString(); Font TextFont = new Font("consolas", 15); Size TextSize = module.GetTextSize(Text, TextFont); sTileTriangleColor AllColor = oTile.GetTriangleColor(TheNumber); Brush BackBrush = new SolidBrush(AllColor.BackColor); Brush ForeBrush = new SolidBrush(AllColor.ForeColor); //les coordonner des coin et du centre Point cUL = new Point(0, 0); Point cUR = new Point(twidth, 0); Point cDL = new Point(0, twidth); Point cDR = new Point(twidth, twidth); Point cCenter = new Point(twidth2, twidth2); if (TheDiv == TileDiv.up) { Point[] t = new Point[] { cUL, cUR, cCenter }; g.FillPolygon(BackBrush, t); Point TextPos = new Point(twidth2 - (TextSize.Width / 2), (twidth2 / 2) - (TextSize.Height / 2)); g.DrawString(Text, TextFont, ForeBrush, (float)(TextPos.X), (float)(TextPos.Y)); } if (TheDiv == TileDiv.down) { Point[] t = new Point[] { cDL, cDR, cCenter }; g.FillPolygon(BackBrush, t); Point TextPos = new Point(twidth2 - (TextSize.Width / 2), (twidth2 * 3 / 2) - (TextSize.Height / 2)); g.DrawString(Text, TextFont, ForeBrush, (float)(TextPos.X), (float)(TextPos.Y)); } if (TheDiv == TileDiv.right) { Point[] t = new Point[] { cUR, cDR, cCenter }; g.FillPolygon(BackBrush, t); Point TextPos = new Point((twidth2 * 3 / 2) - (TextSize.Width / 2), twidth2 - (TextSize.Height / 2)); g.DrawString(Text, TextFont, ForeBrush, (float)(TextPos.X), (float)(TextPos.Y)); } if (TheDiv == TileDiv.left) { Point[] t = new Point[] { cUL, cDL, cCenter }; g.FillPolygon(BackBrush, t); Point TextPos = new Point((twidth2 / 2) - (TextSize.Width / 2), twidth2 - (TextSize.Height / 2)); g.DrawString(Text, TextFont, ForeBrush, (float)(TextPos.X), (float)(TextPos.Y)); } g.Dispose(); return(img); }