예제 #1
0
 private static void hideCard(CardButton i_CardToHide)
 {
     if (i_CardToHide != null)
     {
         i_CardToHide.BackgroundImage            = null;
         i_CardToHide.FlatAppearance.BorderColor = Color.Black;
         i_CardToHide.FlatAppearance.BorderSize  = 1;
         i_CardToHide.Enabled = true;
     }
 }
예제 #2
0
 private void exposeCard(CardButton i_CardToExpose)
 {
     if (i_CardToExpose != null)
     {
         Location?cardLocation  = i_CardToExpose.CardLocation;
         int      cardContentId = r_CurrentGame.Board[cardLocation.Value.Row, cardLocation.Value.Col].CellContent;
         i_CardToExpose.BackgroundImage            = r_CardImages[cardContentId];
         i_CardToExpose.FlatAppearance.BorderColor = getCurrentPlayerColor();
         i_CardToExpose.FlatAppearance.BorderSize  = 5;
         i_CardToExpose.Enabled = false;
     }
 }
예제 #3
0
        private void r_CurrentGame_CardFlipped(Cell i_CardFlipped)
        {
            int i = i_CardFlipped.Location.Row,
                j = i_CardFlipped.Location.Col;
            CardButton cardToFlip = r_Board[i, j];
            bool       isCardFacingUpAfterFlipped = i_CardFlipped.IsFlipped;

            if (isCardFacingUpAfterFlipped)
            {
                exposeCard(cardToFlip);
            }
            else
            {
                hideCard(cardToFlip);
            }
        }
예제 #4
0
        private void addCardButtonToBoard(int i_HeightIdx, int i_WidthIdx, params int[] i_CardButtonLocation)
        {
            r_Board[i_HeightIdx, i_WidthIdx] = new CardButton(new Location(i_HeightIdx, i_WidthIdx));

            CardButton currentCardButton = r_Board[i_HeightIdx, i_WidthIdx];

            currentCardButton.BackgroundImage = null;
            currentCardButton.Anchor          = (System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top
                                                                                    | System.Windows.Forms.AnchorStyles.Left
                                                                                    | System.Windows.Forms.AnchorStyles.Right);
            currentCardButton.FlatStyle = FlatStyle.Flat;
            currentCardButton.Location  = new System.Drawing.Point(i_CardButtonLocation[0], i_CardButtonLocation[1]);
            currentCardButton.Name      = string.Format(
                "m_ButtonCard{0}{1}",
                i_HeightIdx,
                i_WidthIdx);
            currentCardButton.Size     = r_ImageSize;
            currentCardButton.TabIndex = (i_HeightIdx * r_Board.GetLength(0)) + i_WidthIdx;
            currentCardButton.UseVisualStyleBackColor = true;
            currentCardButton.Click += new System.EventHandler(this.cardButton_Click);
            this.Controls.Add(r_Board[i_HeightIdx, i_WidthIdx]);
        }
예제 #5
0
        private void cardButton_Click(object i_Sender, EventArgs i_E)
        {
            CardButton buttonClicked = i_Sender as CardButton;

            Location cardLocation = buttonClicked.CardLocation.Value;
            Cell     cardCell     = r_CurrentGame.GetCellByLocation(cardLocation);

            r_CurrentGame.FlipCard(cardCell);

            if (r_ChosenPair[0] == null)
            {
                // First card of the pair to be exposed
                r_ChosenPair[0] = buttonClicked;
            }
            else
            {
                r_ChosenPair[1] = buttonClicked;

                // disable the form in order to avoid unnecessary clicks //
                this.Enabled = false;
                r_ExposureTimer.Start();
            }
        }