Example #1
0
        private void DrawDecks()
        {
            controlCanvas.Children.Clear();
            if (CurrentPlayer == null || Deck == null || !GameStarted)
            {
                return;
            }
            List <CardControl> stackedCards = new List <CardControl>();

            for (int i = 0; i < Deck.CardsInDeck; i++)
            {
                stackedCards.Add(new CardControl(Deck.GetCard(i))
                {
                    Margin = new Thickness(150 + (i * 1.25), 25 - (i * 1.25), 0, 0), IsFaceUp = false
                });
            }
            if (stackedCards.Count > 0)
            {
                stackedCards.Last().MouseLeftButtonDown += Deck_MouseDoubleClick;
            }
            if (AvailableCard != null)
            {
                var availableCard = new CardControl(AvailableCard)
                {
                    Margin = new Thickness(0, 25, 0, 0)
                };
                availableCard.MouseLeftButtonDown += AvailalbleCard_MouseClick;
                controlCanvas.Children.Add(availableCard);
            }
            stackedCards.ForEach(x => controlCanvas.Children.Add(x));
        }
Example #2
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.UserControl = ((CardsGUI.CardControl)(target));
                return;

            case 2:
                this.SuitLabel = ((System.Windows.Controls.Label)(target));
                return;

            case 3:
                this.RankLabel = ((System.Windows.Controls.Label)(target));
                return;

            case 4:
                this.RankLabelInverted = ((System.Windows.Controls.Label)(target));
                return;

            case 5:
                this.TopRightImage = ((System.Windows.Controls.Image)(target));
                return;

            case 6:
                this.BottomLeftImage = ((System.Windows.Controls.Image)(target));
                return;
            }
            this._contentLoaded = true;
        }
Example #3
0
        private void DrawCards()
        {
            bool isFaceup = (Owner.State != PlayerState.Inactive);

            if (Owner is ComputerPlayer)
            {
                isFaceup = (Owner.State == PlayerState.Loser ||
                            Owner.State == PlayerState.Winner);
            }
            var cards = Owner.GetCards();

            if (cards == null || cards.Count == 0)
            {
                return;
            }
            for (var i = 0; i < cards.Count; i++)
            {
                var cardControl = new CardControl(cards[i]);
                if (PlayerOrientation == Orientation.Horizontal)
                {
                    cardControl.Margin = new Thickness(i * 35, 35, 0, 0);
                }
                else
                {
                    cardControl.Margin = new Thickness(5, 35 + i * 30, 0, 0);
                }
                cardControl.MouseLeftButtonDown += cardControl_MouseClick;
                cardControl.IsFaceUp             = isFaceup;
                CardSurface.Children.Add(cardControl);
            }
        }
Example #4
0
        public GameClient()
        {
            InitializeComponent();
            var position = new Point(15, 15);

            for (var i = 0; i < 4; i++)
            {
                var suit = (CH11.Suit)i;
                position.Y = 15;
                for (int rank = 1; rank < 14; rank++)
                {
                    position.Y += 30;
                    var card = new CardControl(new CH11.Card(suit, (CH11.Rank)rank));
                    card.VerticalAlignment   = VerticalAlignment.Top;
                    card.HorizontalAlignment = HorizontalAlignment.Left;
                    card.Margin = new Thickness(position.X, position.Y, 0, 0);
                    contentGrid.Children.Add(card);
                }
                position.X += 112;
            }
        }