示例#1
0
文件: Form1.cs 项目: 74805/Whist
        public void GetFrischCard(object sender, EventArgs args)
        {
            if (frischcards.Count == 3)
            {
                Card card = (Card)((Label)sender).Tag;
                int  ind  = myICommon.GetCardIndex(card, clientid);

                Label  newcard = new Label();
                string str     = card.GetNum().ToString() + card.GetShape().ToUpper()[0];
                Image  img     = Image.FromFile("..\\..\\..\\PNG\\" + str + ".png");
                img            = Resize(img, 54, 83);
                newcard.Size   = img.Size;
                newcard.Image  = img;
                newcard.Click += CardClick;
                cards.Add(newcard);
                if (ind < cards.Count - 1)
                {
                    newcard.Location = new Point(cards[ind].Location.X, 550);;
                }
                else
                {
                    newcard.Location = new Point(cards[ind - 1].Location.X + 56, 550);
                }

                for (int i = ind; i < cards.Count; i++)
                {
                    Label card1 = cards[i];
                    cards[i] = cards[cards.Count - 1];
                    cards[cards.Count - 1] = card1;
                }
                for (int i = 0; i < cards.Count; i++)
                {
                    if (i > ind)
                    {
                        cards[i].Location = new Point(cards[i].Location.X + 28, 550);
                    }
                    else
                    {
                        cards[i].Location = new Point(cards[i].Location.X - 28, 550);
                    }
                }

                Controls.Add(newcard);
            }
        }