Inheritance: System.Windows.Forms.UserControl
 public CardAnimator( CardPictureBox animated )
 {
     _animated = animated;
     _animationQueue = new Queue<CardPictureBox>( 4 );
     _timer = new Timer();
     _timer.Interval = 25;
     _timer.Tick += new System.EventHandler( OnTick );
 }
 public CardAnimator(CardPictureBox animated)
 {
     _animated       = animated;
     _animationQueue = new Queue <CardPictureBox>(4);
     _timer          = new Timer();
     _timer.Interval = 25;
     _timer.Tick    += new System.EventHandler(OnTick);
 }
        private void InitNextControl()
        {
            _horizontalMovementFinished = false;
            _verticalMovementFinished   = false;
            _target = ( CardPictureBox )_animationQueue.Dequeue();

            _animated.Left  = _target.Left + _target.Parent.Left;
            _animated.Top   = _target.Top + _target.Parent.Top;
            _animated.Card  = _target.Card;
            _target.Visible = false;
            _target.Parent.SendToBack();
            _initialLocation = _target.Location;
            _animated.BringToFront();
            _animated.Visible = true;
        }
        private void OnVisibleChanged( object sender, EventArgs e )
        {
            if ( this.Visible )
            {
                #region _hands

                int rowsSN = 0;
                int rowsWE = 0;

                foreach ( Hand hand in _hands )
                {
                    int cols = 0;
                    foreach ( Card card in hand )
                    {
                        if ( hand.Winner.Position == PlayerPosition.South || hand.Winner.Position == PlayerPosition.North )
                        {
                            CardPictureBox cpb = new CardPictureBox();
                            cpb.Width = IMAGE_WIDTH;
                            cpb.Height = IMAGE_HEIGTH;
                            cpb.Card = card;
                            cpb.Location = new Point( cols * ( IMAGE_WIDTH + PAD_WIDTH ) + PAD_WIDTH, rowsSN * ( IMAGE_HEIGTH + PAD_HEIGTH ) + PAD_HEIGTH );

                            _panelSNHands.Controls.Add( cpb );
                        }
                        else
                        {
                            CardPictureBox cpb = new CardPictureBox();
                            cpb.Width = IMAGE_WIDTH;
                            cpb.Height = IMAGE_HEIGTH;
                            cpb.Card = card;
                            cpb.Location = new Point( cols * ( IMAGE_WIDTH + PAD_WIDTH ) + PAD_WIDTH, rowsWE * ( IMAGE_HEIGTH + PAD_HEIGTH ) + PAD_HEIGTH );

                            _panelWEHands.Controls.Add( cpb );
                        }
                        cols++;
                    }

                    if ( hand.Winner.Position == PlayerPosition.South || hand.Winner.Position == PlayerPosition.North )
                    {
                        rowsSN++;
                    }
                    else
                    {
                        rowsWE++;
                    }
                }

                #endregion

                #region Combinations

                int lastSNlabelTop = 0;
                int lastWElabelTop = 0;

                foreach ( KeyValuePair<CardCombination, Player> kv in _mapCombinationToPlayer )
                {
                    CardCombination combination = kv.Key;
                    Player player = kv.Value;

                    Label labelCombination = new Label();
                    labelCombination.Text = GetCombinationString( combination );
                    labelCombination.Width = 160;
                    labelCombination.Height = LABEL_HEIGHT;
                    labelCombination.Font = _labelFont;

                    Label labelPoints = new Label();
                    labelPoints.Text = combination.Points.ToString();
                    labelPoints.Width = 40;
                    labelPoints.Height = LABEL_HEIGHT;
                    labelPoints.Font = _labelFont;

                    PictureBox pictureCounted = new PictureBox();
                    pictureCounted.Width = LABEL_HEIGHT;
                    pictureCounted.Height = LABEL_HEIGHT;
                    pictureCounted.SizeMode = PictureBoxSizeMode.StretchImage;
                    if ( combination.IsCounted )
                    {
                        pictureCounted.Image = Properties.Resources.yes;
                    }
                    else
                    {
                        pictureCounted.Image = Properties.Resources.no;
                    }

                    if ( player.Position == PlayerPosition.South || player.Position == PlayerPosition.North )
                    {
                        labelCombination.Location = new Point( 0, lastSNlabelTop );
                        labelPoints.Location = new Point( 160, lastSNlabelTop );
                        pictureCounted.Location = new Point( 200, lastSNlabelTop );

                        _panelSNCombinations.Controls.Add( labelCombination );
                        _panelSNCombinations.Controls.Add( labelPoints );
                        _panelSNCombinations.Controls.Add( pictureCounted );
                        lastSNlabelTop += LABEL_HEIGHT;
                    }
                    else
                    {
                        labelCombination.Location = new Point( 0, lastWElabelTop );
                        labelPoints.Location = new Point( 160, lastWElabelTop );
                        pictureCounted.Location = new Point( 200, lastWElabelTop );

                        _panelWECombinations.Controls.Add( labelCombination );
                        _panelWECombinations.Controls.Add( labelPoints );
                        _panelWECombinations.Controls.Add( pictureCounted );
                        lastWElabelTop += LABEL_HEIGHT;
                    }
                }

                #endregion

                _labelSNPointsReal.Text = _deal.RawNorthSouthPoints.ToString();
                _labelWEPointsReal.Text = _deal.RawEastWestPoints.ToString();
            }
        }
Exemple #5
0
        private void OnVisibleChanged(object sender, EventArgs e)
        {
            if (this.Visible)
            {
                #region _hands

                int rowsSN = 0;
                int rowsWE = 0;

                foreach (Hand hand in _hands)
                {
                    int cols = 0;
                    foreach (Card card in hand)
                    {
                        if (hand.Winner.Position == PlayerPosition.South || hand.Winner.Position == PlayerPosition.North)
                        {
                            CardPictureBox cpb = new CardPictureBox();
                            cpb.Width    = IMAGE_WIDTH;
                            cpb.Height   = IMAGE_HEIGTH;
                            cpb.Card     = card;
                            cpb.Location = new Point(cols * (IMAGE_WIDTH + PAD_WIDTH) + PAD_WIDTH, rowsSN * (IMAGE_HEIGTH + PAD_HEIGTH) + PAD_HEIGTH);

                            _panelSNHands.Controls.Add(cpb);
                        }
                        else
                        {
                            CardPictureBox cpb = new CardPictureBox();
                            cpb.Width    = IMAGE_WIDTH;
                            cpb.Height   = IMAGE_HEIGTH;
                            cpb.Card     = card;
                            cpb.Location = new Point(cols * (IMAGE_WIDTH + PAD_WIDTH) + PAD_WIDTH, rowsWE * (IMAGE_HEIGTH + PAD_HEIGTH) + PAD_HEIGTH);

                            _panelWEHands.Controls.Add(cpb);
                        }
                        cols++;
                    }

                    if (hand.Winner.Position == PlayerPosition.South || hand.Winner.Position == PlayerPosition.North)
                    {
                        rowsSN++;
                    }
                    else
                    {
                        rowsWE++;
                    }
                }

                #endregion

                #region Combinations

                int lastSNlabelTop = 0;
                int lastWElabelTop = 0;

                foreach (KeyValuePair <CardCombination, Player> kv in _mapCombinationToPlayer)
                {
                    CardCombination combination = kv.Key;
                    Player          player      = kv.Value;

                    Label labelCombination = new Label();
                    labelCombination.Text   = GetCombinationString(combination);
                    labelCombination.Width  = 160;
                    labelCombination.Height = LABEL_HEIGHT;
                    labelCombination.Font   = _labelFont;

                    Label labelPoints = new Label();
                    labelPoints.Text   = combination.Points.ToString();
                    labelPoints.Width  = 40;
                    labelPoints.Height = LABEL_HEIGHT;
                    labelPoints.Font   = _labelFont;

                    PictureBox pictureCounted = new PictureBox();
                    pictureCounted.Width    = LABEL_HEIGHT;
                    pictureCounted.Height   = LABEL_HEIGHT;
                    pictureCounted.SizeMode = PictureBoxSizeMode.StretchImage;
                    if (combination.IsCounted)
                    {
                        pictureCounted.Image = Properties.Resources.yes;
                    }
                    else
                    {
                        pictureCounted.Image = Properties.Resources.no;
                    }

                    if (player.Position == PlayerPosition.South || player.Position == PlayerPosition.North)
                    {
                        labelCombination.Location = new Point(0, lastSNlabelTop);
                        labelPoints.Location      = new Point(160, lastSNlabelTop);
                        pictureCounted.Location   = new Point(200, lastSNlabelTop);

                        _panelSNCombinations.Controls.Add(labelCombination);
                        _panelSNCombinations.Controls.Add(labelPoints);
                        _panelSNCombinations.Controls.Add(pictureCounted);
                        lastSNlabelTop += LABEL_HEIGHT;
                    }
                    else
                    {
                        labelCombination.Location = new Point(0, lastWElabelTop);
                        labelPoints.Location      = new Point(160, lastWElabelTop);
                        pictureCounted.Location   = new Point(200, lastWElabelTop);

                        _panelWECombinations.Controls.Add(labelCombination);
                        _panelWECombinations.Controls.Add(labelPoints);
                        _panelWECombinations.Controls.Add(pictureCounted);
                        lastWElabelTop += LABEL_HEIGHT;
                    }
                }

                #endregion

                _labelSNPointsReal.Text = _deal.RawNorthSouthPoints.ToString();
                _labelWEPointsReal.Text = _deal.RawEastWestPoints.ToString();
            }
        }
 public void EnqueueControl( CardPictureBox target )
 {
     _animationQueue.Enqueue( target );
 }
        private void InitNextControl()
        {
            _horizontalMovementFinished = false;
            _verticalMovementFinished = false;
            _target = ( CardPictureBox )_animationQueue.Dequeue();

            _animated.Left = _target.Left + _target.Parent.Left;
            _animated.Top = _target.Top + _target.Parent.Top;
            _animated.Card = _target.Card;
            _target.Visible = false;
            _target.Parent.SendToBack();
            _initialLocation = _target.Location;
            _animated.BringToFront();
            _animated.Visible = true;
        }
 public void EnqueueControl(CardPictureBox target)
 {
     _animationQueue.Enqueue(target);
 }