public void Createcards() { Card[] cards1 = myICommon.GetCards(clientid); cards = new List <Label>(); othercards1 = new List <Label>(); othercards2 = new List <Label>(); othercards3 = new List <Label>(); for (int i = 0; i < 13; i++) { Card card = cards1[i]; Label label = new Label(); string str = card.GetNum().ToString() + card.GetShape().ToUpper()[0]; Image img = Image.FromFile("..\\..\\..\\PNG\\" + str + ".png"); img = Resize(img, 54, 83); label.Image = img; label.Location = new Point(335 + i * 56, 550); label.Size = img.Size; label.Tag = card; label.Click += CardClick; this.cards.Add(label); Controls.Add(label); Label label1 = new Label(); Image img1 = Image.FromFile("..\\..\\..\\PNG\\gray_back.png"); img1 = Resize(img1, 83, 54); label1.Image = img1; label1.Size = img1.Size; label1.Location = new Point(1100, 150 + i * 30); Controls.Add(label1); othercards1.Add(label1); Label label2 = new Label(); Image img2 = Image.FromFile("..\\..\\..\\PNG\\green_back.png"); img2 = Resize(img2, 83, 54); label2.Image = img2; label2.Size = img2.Size; label2.Location = new Point(190, 150 + i * 30); Controls.Add(label2); othercards2.Add(label2); Label label3 = new Label(); Image img3 = Image.FromFile("..\\..\\..\\PNG\\blue_back.png"); img3 = Resize(img3, 54, 83); label3.Image = img3; label3.Size = img3.Size; label3.Location = new Point(480 + i * 30, 60); Controls.Add(label3); othercards3.Add(label3); } }
public void Createcards() { Card[] cards = myICommon.GetCards(clientid); int spa = 0, dia = 0, hea = 0; List <Card> spad = new List <Card>(); List <Card> hear = new List <Card>(); List <Card> diam = new List <Card>(); List <Card> clu = new List <Card>(); Card[] cards1 = new Card[13]; for (int i = 0; i < 13; i++) { if (cards[i].GetShape() == "spades") { spad.Add(cards[i]); spa++; } if (cards[i].GetShape() == "hearts") { hear.Add(cards[i]); hea++; } if (cards[i].GetShape() == "diamonds") { diam.Add(cards[i]); dia++; } if (cards[i].GetShape() == "clubs") { clu.Add(cards[i]); } } for (int i = 0; i < spa; i++) { for (int j = i + 1; j < spa; j++) { if (spad[i].GetNum() < spad[j].GetNum()) { Card card = new Card(spad[j]); spad[j] = new Card(spad[i]); spad[i] = card; } } cards1[i] = spad[i]; } for (int i = 0; i < hea; i++) { for (int j = i + 1; j < hea; j++) { if (hear[i].GetNum() < hear[j].GetNum()) { Card card = new Card(hear[j]); hear[j] = new Card(hear[i]); hear[i] = card; } } cards1[i + spa] = hear[i]; } for (int i = 0; i < dia; i++) { for (int j = i + 1; j < dia; j++) { if (diam[i].GetNum() < diam[j].GetNum()) { Card card = new Card(diam[j]); diam[j] = new Card(diam[i]); diam[i] = card; } } cards1[i + 13 - dia] = diam[i]; } for (int i = 0; i < 13 - spa - hea - dia; i++) { for (int j = i + 1; j < 13 - spa - hea - dia; j++) { if (clu[i].GetNum() < clu[j].GetNum()) { Card card = new Card(clu[j]); clu[j] = new Card(clu[i]); clu[i] = card; } } cards1[i + spa + hea] = clu[i]; } for (int i = 0; i < 13; i++) { Card card = cards1[i]; Label label = new Label(); string str = card.GetNum().ToString() + card.GetShape().ToUpper()[0]; Image img = Image.FromFile("..\\..\\..\\PNG\\" + str + ".png"); img = Resize(img, 54, 83); label.Image = img; label.Location = new Point(335 + i * 56, 550); label.Size = img.Size; label.Tag = card; label.Click += CardClick; this.cards.Add(label); Controls.Add(label); Label label1 = new Label(); Image img1 = Image.FromFile("..\\..\\..\\PNG\\gray_back.png"); img1 = Resize(img1, 83, 54); label1.Image = img1; label1.Size = img1.Size; label1.Location = new Point(1100, 150 + i * 30); Controls.Add(label1); othercards1.Add(label1); Label label2 = new Label(); Image img2 = Image.FromFile("..\\..\\..\\PNG\\green_back.png"); img2 = Resize(img2, 83, 54); label2.Image = img2; label2.Size = img2.Size; label2.Location = new Point(190, 150 + i * 30); Controls.Add(label2); othercards2.Add(label2); Label label3 = new Label(); Image img3 = Image.FromFile("..\\..\\..\\PNG\\blue_back.png"); img3 = Resize(img3, 54, 83); label3.Image = img3; label3.Size = img3.Size; label3.Location = new Point(480 + i * 30, 60); Controls.Add(label3); othercards3.Add(label3); } }