Пример #1
0
 //method for changing back colors
 private void ChangeBackColorInAllCards()
 {
     for (int i = 0; i < ControlGrid.Children.Count; i++)
     {
         (ControlGrid.Children[i] as MyButton).BackCardImage = CardBackImageSourceObtainer.GetBackImageSource(cardBack);
     }
 }
Пример #2
0
        //method for adjusting card in the constructor
        private void AdjustCardAtStart()
        {
            if (ActualFrame.Children.Count == 0)
            {
                MyButton myButton = new MyButton();
                (myButton.Height, myButton.Width) = EstimateCardHeightAndWidth(false);
                myButton.BackCardImage            = CardBackImageSourceObtainer.GetBackImageSource(BackColor.Blue);
                myButton.VerticalAlignment        = VerticalAlignment.Center;
                myButton.HorizontalAlignment      = HorizontalAlignment.Center;
                myButton.Margin    = new Thickness(0);
                myButton.ClickMode = ClickMode.Press;

                //left mouse preview left mouse button down event
                //for creation an event that corresponds to taking
                //cards from deck by player
                myButton.Click += new RoutedEventHandler(
                    (s, e) =>
                {
                    MyButton button = s as MyButton;
                    OnTakeCardClick();
                });

                ActualFrame.Children.Add(myButton);
            }
        }
Пример #3
0
        //adding only one card to the wrap panel
        private void AddSingleCardBackToWrapPanel(BackColor color)
        {
            WrapPanelSelectableItem button = new WrapPanelSelectableItem
            {
                Height              = 110,
                Width               = 110,
                VerticalAlignment   = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Left,
                Margin              = new Thickness(0),
                ItemSelected        = Visibility.Collapsed,
                ItemHoovered        = Visibility.Collapsed,
                ImageSource         = CardBackImageSourceObtainer.GetBackImageSource(color),
                Tag = color,
            };

            //mouse enter and leave event
            button.MouseEnter += CardBackButton_MouseEnter;
            button.MouseLeave += CardBackButton_MouseLeave;
            button.Click      += AvatarButton_Click;

            CardBacksWrapPanel.Children.Add(button);

            var logger = NLog.LogManager.GetCurrentClassLogger();

            logger.Info("Added one card back to the Wrap Panel: " + color.ToString());
        }
Пример #4
0
        //method for changing picture that represents back of the cards
        public void ChangeBackColor(BackColor color)
        {
            if (ActualFrame.Children.Count > 0)
            {
                (ActualFrame.Children[0] as MyButton).BackCardImage = CardBackImageSourceObtainer.GetBackImageSource(color);
            }

            var logger = NLog.LogManager.GetCurrentClassLogger();

            logger.Info("Deck representation card color changed to: " + color);
        }
Пример #5
0
        //method for adding new Card (button) to Contorl
        private void AddSingleButtonToControl()
        {
            MyButton myButton = new MyButton();

            (myButton.Height, myButton.Width) = EstimateCardHeightAndWidth(false);
            myButton.VerticalAlignment        = VerticalAlignment.Top;
            myButton.HorizontalAlignment      = HorizontalAlignment.Left;
            myButton.Margin        = new Thickness(0);
            myButton.BackCardImage = CardBackImageSourceObtainer.GetBackImageSource(cardBack);

            ControlGrid.Children.Add(myButton);
        }
Пример #6
0
        //method for adding one card to control
        private void AddCardToControl(int place)
        {
            if (place < 0 || place > 7)
            {
                var    logger = NLog.LogManager.GetCurrentClassLogger();
                string text   = "Place number cannot be grather than 7 or less than 0 - adding";
                logger.Error(text);
                throw new ArgumentException(text);
            }

            MyButton myButton = new MyButton();

            (myButton.Height, myButton.Width) = EstimateCardHeightAndWidth(false);
            myButton.HorizontalAlignment      = HorizontalAlignment.Center;
            myButton.VerticalAlignment        = VerticalAlignment.Center;
            myButton.CardImage = CardBackImageSourceObtainer.GetBackImageSource(BackColor.Gray);
            myButton.Margin    = new Thickness(0);

            switch (place)
            {
            case 0: FirstCard.Children.Add(myButton); currentAmountOfCards++; break;

            case 1: SecondCard.Children.Add(myButton); currentAmountOfCards++; break;

            case 2: ThirdCard.Children.Add(myButton); currentAmountOfCards++; break;

            case 3: FourthCard.Children.Add(myButton); currentAmountOfCards++; break;

            case 4: FifthCard.Children.Add(myButton); currentAmountOfCards++; break;

            case 5: SixthCard.Children.Add(myButton); currentAmountOfCards++; break;

            case 6: SeventhCard.Children.Add(myButton); currentAmountOfCards++; break;

            case 7: EightCard.Children.Add(myButton); currentAmountOfCards++; break;

            default: break;
            }
        }