Exemple #1
0
        public override void DrawString(byte x, byte y, string text, bool black)
        {
            var       width       = CellSize / (float)stoneSize;
            Rectangle destination = new Rectangle((int)(((x * CellSize) - 10) / width),
                                                  (int)(((y * CellSize) - 10) / width),
                                                  (int)((CellSize + 20) / width),
                                                  (int)((CellSize + 20) / width));

            font.DrawText(sprite, text, destination,
                          DrawTextFormat.VerticalCenter | DrawTextFormat.Center,
                          unchecked ((int)(black ? 0xFF000000 : 0xFFFFFFFF)));
        }
Exemple #2
0
        public override void DrawMessage(string message)
        {
            var margin = 10;
            var target = new Rectangle(0, 0, BoardSize * CellSize, BoardSize * CellSize);
            var size   = messageFont.MeasureString(messageSprite, message, ref target,
                                                   DrawTextFormat.VerticalCenter | DrawTextFormat.Center);
            var destination = new Rectangle((int)((BoardSize * CellSize - size.Width) / 2 - 2 * margin),
                                            (int)((BoardSize * CellSize / 2 - size.Height) - margin),
                                            (int)(size.Width + 4 * margin),
                                            (int)(size.Height + 2 * margin));

            sprite.Flush();

            var factor = new SizeF(destination.Width / (float)stoneSize,
                                   destination.Height / (float)stoneSize);

            messageSprite.Transform = Matrix.Scaling(factor.Width, factor.Height, 1);
            messageSprite.Draw(markup[7], Vector3.Empty,
                               new Vector3(destination.Left / factor.Width,
                                           destination.Top / factor.Height,
                                           0.0f), 0x78FFFFFF);
            messageSprite.Transform = Matrix.Identity;
            messageFont.DrawText(messageSprite, message, destination,
                                 DrawTextFormat.VerticalCenter | DrawTextFormat.Center,
                                 unchecked ((int)0xFFFFFFFF));
            messageSprite.Flush();
            var surface = device.GetBackBuffer(0, BackBufferType.Mono);

            device.ColorFill(surface,
                             new Rectangle(destination.Left - 2, destination.Top - 2,
                                           2, destination.Height + 3),
                             Color.Black);
            device.ColorFill(surface,
                             new Rectangle(destination.Left + destination.Width - 1, destination.Top - 2,
                                           2, destination.Height + 3),
                             Color.Black);
            device.ColorFill(surface,
                             new Rectangle(destination.Left - 2, destination.Top - 2,
                                           destination.Width + 3, 2),
                             Color.Black);
            device.ColorFill(surface,
                             new Rectangle(destination.Left - 2, destination.Top + destination.Height - 1,
                                           destination.Width + 3, 2),
                             Color.Black);
        }