Beispiel #1
0
        public void AddRiverCard(int player, int number, MahjongCard card, Grid container)
        {
            // Create a new card
            System.Windows.Controls.Image imgCard = new System.Windows.Controls.Image()
            {
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Height  = 40,
                Width   = 24,
                Stretch = Stretch.Uniform,
            };

            // Set the render to high quality
            imgCard.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.HighQuality);

            // Set card position
            imgCard.Margin = new Thickness(number % 7 * imgCard.Width, number / 7 * imgCard.Height, 0, 0);

            // Set image
            imgCard.Source = cardImage[card.name];

            // Set tag
            HandCardInfo handCardInfo = new HandCardInfo()
            {
                card   = card,
                player = player,
            };

            imgCard.Tag = handCardInfo;

            // Add the card
            container.Children.Add(imgCard);
        }
Beispiel #2
0
        private void AddHandCard(int player, int number, MahjongCard card, Grid container, int height = 75, int width = 46)
        {
            // Create a new card
            System.Windows.Controls.Image imgCard = new System.Windows.Controls.Image()
            {
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Height  = height,
                Width   = width,
                Stretch = Stretch.Uniform,
            };

            // Set the render to high quality
            imgCard.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.HighQuality);

            // Set card position
            imgCard.Margin = new Thickness((number * imgCard.Width) + 5, 10, 0, 0);

            // Set image
            imgCard.Source = cardImage[card.name];

            // Set mouse event
            imgCard.MouseEnter += HandCard_MouseEnter;
            imgCard.MouseLeave += HandCard_MouseLeave;

            // Set click event
            imgCard.MouseLeftButtonUp += HandCard_MouseLeftButtonUp;

            // Set tag
            HandCardInfo handCardInfo = new HandCardInfo()
            {
                card   = card,
                player = player,
            };

            imgCard.Tag = handCardInfo;

            // Add the card
            container.Children.Add(imgCard);
        }
Beispiel #3
0
        private void HandCard_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            HandCardInfo info = (HandCardInfo)(sender as System.Windows.Controls.Image).Tag;

            mahjongLogic.PlayCard(info.player, info.card);
        }