Beispiel #1
0
        private void MainPanel_Paint(object sender, PaintEventArgs e)
        {
            if (activePlayerFont == null)
            {
                activePlayerFont = new Font(playerFont, FontStyle.Bold);
            }

            var graphics     = e.Graphics;
            var width        = (float)mainPanel.Width;
            var height       = (float)mainPanel.Height;
            var middlePointX = width / 2f;
            var middlePointY = height / 2f;

            float dbWidth  = 80f;
            float dbFac    = dbWidth / (float)blankCardImage.Width;
            var   dbHeight = dbFac * blankCardImage.Height;

            RectangleF rect           = new RectangleF(middlePointX - (dbWidth / 2), middlePointY - dbHeight - (dbHeight / 4), dbWidth, dbHeight);
            RectangleF rectToDecorate = new RectangleF(middlePointX - (dbWidth / 2) - 5, middlePointY - dbHeight - (dbHeight / 4), dbWidth + 10, dbHeight);
            Rect       simpleRect     = new DiagonalDecorator(new BorderDecorator(new BackgroundDecorator(new SimpleRect(rectToDecorate, graphics))));

            simpleRect.Draw();
            graphics.DrawImage(CardImageStore.GetImage(Gamestate.ActiveCard), rect);

            if (StateContext.GetState() is WinningState)
            {
                PrintStars(graphics);
            }
        }
Beispiel #2
0
        private void HandPanel_Paint(object sender, PaintEventArgs e)
        {
            if (Gamestate != null)
            {
                var widthPerCard = HandCardWidth / 2;
                var handCount    = Gamestate.Hand.Count;

                var   graphics     = e.Graphics;
                float movePosition = 0f;
                xyImage = new float[handCount, 2];

                float width       = (float)handPanel.Width;
                float height      = (float)handPanel.Height;
                float middlePoint = width / 4f;

                if (handCount * widthPerCard > (width - middlePoint))
                {
                    middlePoint = width - (handCount * widthPerCard);

                    if (middlePoint < 0)
                    {
                        middlePoint  = 0;
                        widthPerCard = width / handCount;
                    }
                }

                for (int i = 0; i < handCount; i++)
                {
                    var card = Gamestate.Hand[i];
                    if (card != null)
                    {
                        var img = CardImageStore.GetImage(card);

                        xyImage[i, 0] = middlePoint + movePosition;
                        xyImage[i, 1] = 15f;                         // Recommended cards
                        movePosition += widthPerCard;

                        var dbWidth  = HandCardWidth / (float)img.Width;
                        var dbHeight = dbWidth * img.Height;

                        graphics.DrawImage(img, new RectangleF(xyImage[i, 0], xyImage[i, 1], HandCardWidth, dbHeight));
                    }
                }
            }
        }
Beispiel #3
0
        int HitTestCard(Point loc)
        {
            var x = loc.X;
            var y = loc.Y;

            int bild = -1;

            for (int i = 0; i < Gamestate.Hand.Count; i++)
            {
                var img = CardImageStore.GetImage(Gamestate.Hand[i]);

                var dblFac    = HandCardWidth / (float)img.Width;
                var dblHeight = dblFac * img.Height;

                if (x >= xyImage[i, 0] && x <= xyImage[i, 0] + HandCardWidth && y >= xyImage[i, 1] && y <= xyImage[i, 1] + dblHeight)
                {
                    bild = i;
                }
            }
            return(bild);
        }