private void Suit_Pile4_pictureBox_Click(object sender, EventArgs e) { int a; if (Is_discard_selected == true) { if (Solitaire_Game.DisToSuit(4) == false) { MessageBox.Show("ERROR - Move not allowed - Cannot place card onto this card"); } else { Displaysuit(4); Displaydiscard(); } } else if ((a = Is_panel_selected()) > 0) { if (Solitaire_Game.PanelToSuit(a, 4) == false) { MessageBox.Show("ERROR - Move not allowed - Cannot place card onto this card"); } else { Displaysuit(4); Display7table(a); } } reset_is_select(); }
private void tableLayoutPanel1_MouseClick(object sender, MouseEventArgs e) { int a; // MessageBox.Show("x:" + e.Location.X + " y:" + e.Location.Y); if (Is_discard_selected == true) { Hand[] h = Solitaire_Game.get_tableauPiles(); if (h[0].GetCount() == 0) { num_shown_panel1 = 1; } if (Solitaire_Game.Move_Card(1) == true) { Display7table(1); Displaydiscard(); } else { MessageBox.Show("ERROP - Move not allowed - Cannot place card onto this card"); } Is_discard_selected = false; } else if ((a = Is_panel_selected()) > 0) { if (a != 1) { if (Solitaire_Game.PanelToPanel(a, 1)) { num_shown_panel1++; reduce_num(a); } else { MessageBox.Show("ERROP - Move not allowed - Cannot place card onto this card"); } reset_is_select(); Display7table(a); Display7table(1); } else { MessageBox.Show("ERROP - Move not allowed - Cannot place card onto this card"); reset_is_select(); Is_panel1_selected = true; } } else { reset_is_select(); Is_panel1_selected = true; } }
private void Displaydiscard() { CardPile dis = Solitaire_Game.get_discardPile(); if (dis.GetCount() > 0) { Discard_Pile_pictureBox1.Image = Games.Images.GetCardImage(dis.GetLastCardInPile()); } else if (dis.GetCount() == 0) { Discard_Pile_pictureBox1.Image = null; } }
private void tableLayoutPanel7_MouseClick(object sender, MouseEventArgs e) { int a; if (Is_discard_selected == true) { if (Solitaire_Game.Move_Card(7) == true) { num_shown_panel7++; Display7table(7); Displaydiscard(); } else { MessageBox.Show("ERROP - Move not allowed - Cannot place card onto this card"); } Is_discard_selected = false; } else if ((a = Is_panel_selected()) > 0) { if (a != 7) { if (Solitaire_Game.PanelToPanel(a, 7)) { reduce_num(a); num_shown_panel7++; } else { MessageBox.Show("ERROP - Move not allowed - Cannot place card onto this card"); } reset_is_select(); Display7table(a); Display7table(7); } else { MessageBox.Show("ERROP - Move not allowed - Cannot place card onto this card"); reset_is_select(); Is_panel7_selected = true; } } else { reset_is_select(); Is_panel7_selected = true; } }
public Solitaire_Game_Form() { InitializeComponent(); Solitaire_Game.SetUpGame(); Display7table(1); Display7table(2); Display7table(3); Display7table(4); Display7table(5); Display7table(6); Display7table(7); Displaydraw(false); Displaydiscard(); Is_discard_selected = false; }
// End DisplayGuiHand private void Drawcard_Pile_pictureBox1_Click(object sender, EventArgs e) { CardPile draw = Solitaire_Game.get_drawPile(); if (Solitaire_Game.Draw_Card() == true) { Displaydraw(false); } else { Displaydraw(true); } Displaydiscard(); reset_is_select(); }
private void Displaysuit(int num) { num--; CardPile[] suit = Solitaire_Game.get_suitPiles(); if (num == 0) { Suit_Pile1_pictureBox.Image = Games.Images.GetCardImage(suit[num].GetLastCardInPile()); } else if (num == 1) { Suit_Pile2_pictureBox.Image = Games.Images.GetCardImage(suit[num].GetLastCardInPile()); } else if (num == 2) { Suit_Pile3_pictureBox.Image = Games.Images.GetCardImage(suit[num].GetLastCardInPile()); } else if (num == 3) { Suit_Pile4_pictureBox.Image = Games.Images.GetCardImage(suit[num].GetLastCardInPile()); } }
private void Display7table(int i) { TableLayoutPanel tableLayoutPanel; int num_shown; Hand[] hand = Solitaire_Game.get_tableauPiles(); if (i == 1) { tableLayoutPanel = tableLayoutPanel1; num_shown = num_shown_panel1; } else if (i == 2) { num_shown = num_shown_panel2; tableLayoutPanel = tableLayoutPanel2; } else if (i == 3) { num_shown = num_shown_panel3; tableLayoutPanel = tableLayoutPanel3; } else if (i == 4) { num_shown = num_shown_panel4; tableLayoutPanel = tableLayoutPanel4; } else if (i == 5) { num_shown = num_shown_panel5; tableLayoutPanel = tableLayoutPanel5; } else if (i == 6) { num_shown = num_shown_panel6; tableLayoutPanel = tableLayoutPanel6; } else { num_shown = num_shown_panel7; tableLayoutPanel = tableLayoutPanel7; } tableLayoutPanel.Controls.Clear(); i--; if (hand[i].GetCount() == 0) { // Construct a PictureBox object. PictureBox pictureBox = new PictureBox(); // Set the PictureBox to use all of its space pictureBox.Dock = DockStyle.Fill; // Remove spacing around the PictureBox. (Default is 3 pixels.) pictureBox.Margin = new Padding(0); pictureBox.Image = null; } else { for (int j = 0; j < hand[i].GetCount() - num_shown; j++) { // Construct a PictureBox object. PictureBox pictureBox = new PictureBox(); // Set the PictureBox to use all of its space pictureBox.Dock = DockStyle.Fill; // Remove spacing around the PictureBox. (Default is 3 pixels.) pictureBox.Margin = new Padding(0); pictureBox.Image = Games.Images.GetBackOfCardImage(); // Add the PictureBox object to the tableLayoutPanel. tableLayoutPanel.Controls.Add(pictureBox); } for (int j = hand[i].GetCount() - num_shown; j < hand[i].GetCount(); j++) { // Construct a PictureBox object. PictureBox pictureBox = new PictureBox(); // Set the PictureBox to use all of its space pictureBox.Dock = DockStyle.Fill; // Remove spacing around the PictureBox. (Default is 3 pixels.) pictureBox.Margin = new Padding(0); pictureBox.Image = Games.Images.GetCardImage(hand[i].GetCard(j)); tableLayoutPanel.Controls.Add(pictureBox); } } }