T
Tony Johansson
Hello
Here is some code that place a user control called CardGUI in another user
control named PlayerGUI.
Assume width for the CardGUI is 100. The first card is placed at xPos=0 and
y=0.
Now when I place the second card I set xPos = 50 and y = 0.
The problem is that I want the second card to overlap the first so only the
left part of the first card is shown.
I thought this code did this but here only the right part the second card
that is shown.
private void InitialDeal()
{
Control[] ctrl = this.pnlPlayers.Controls.Find(PlayerGUI, false);
for (int cardNr = 0; cardNr < StartDeal; cardNr++)
{
for (int playerNr = 0; playerNr < ctrl.Length; playerNr++)
{
Card card = gm.GetPlayerCard(playerNr, cardNr);
for (int i = 0; i < pnlPlayers.Controls.Count; i++)
{
PlayerGUI pg = ctrl as PlayerGUI;
if (pg.PlayerName == gm.Players[playerNr].Name)
{
string imagePath =
Path.Combine(Environment.CurrentDirectory, @"..\..\Images\" + card.Suit+
".ico");
CardGUI cg = new CardGUI(imagePath,card.RankSymbol());
int xPos = (cardNr % 2) * cg.Width/2;
cg.Location = new Point(xPos, 0);
pg.AddCard(cg);
break;
}
}
}
}
}
//Tony
Here is some code that place a user control called CardGUI in another user
control named PlayerGUI.
Assume width for the CardGUI is 100. The first card is placed at xPos=0 and
y=0.
Now when I place the second card I set xPos = 50 and y = 0.
The problem is that I want the second card to overlap the first so only the
left part of the first card is shown.
I thought this code did this but here only the right part the second card
that is shown.
private void InitialDeal()
{
Control[] ctrl = this.pnlPlayers.Controls.Find(PlayerGUI, false);
for (int cardNr = 0; cardNr < StartDeal; cardNr++)
{
for (int playerNr = 0; playerNr < ctrl.Length; playerNr++)
{
Card card = gm.GetPlayerCard(playerNr, cardNr);
for (int i = 0; i < pnlPlayers.Controls.Count; i++)
{
PlayerGUI pg = ctrl as PlayerGUI;
if (pg.PlayerName == gm.Players[playerNr].Name)
{
string imagePath =
Path.Combine(Environment.CurrentDirectory, @"..\..\Images\" + card.Suit+
".ico");
CardGUI cg = new CardGUI(imagePath,card.RankSymbol());
int xPos = (cardNr % 2) * cg.Width/2;
cg.Location = new Point(xPos, 0);
pg.AddCard(cg);
break;
}
}
}
}
}
//Tony