1

I'm trying to develop a poker replayer hands but I am facing a problem that does not really know how to solve. With the methods below:

public Replayer() //ctor
    {
        InitializeComponent();

        pics = null;
        iCounter = 0;
        bShow = true;

        var pos = picTable.PointToScreen(picTable.Location);
        pos = picTable.PointToClient(pos);
        picTable.Parent = picBackground;
        picTable.Location = pos;
        picTable.BackColor = Color.Transparent;

        TenPlayerHoldem(); // for only test   
    }

 private void TenPlayerHoldem() // only test
    {
        int iCounter = 10;

        pics = new PictureBox[10];

        for(int i = 0; i < iCounter; i++)
        {
            pics[i] = new PictureBox();
            pics[i].Name = "pics" + i.ToString();
            pics[i].Size = new Size(148, 74);
            pics[i].Image = FreePokerReplayer.Properties.Resources.seatbold;
            pics[i].SizeMode = PictureBoxSizeMode.StretchImage;
            pics[i].BackColor = Color.Transparent;
            pics[i].Visible = true;
            pics[i].MouseClick += new MouseEventHandler(pics_Click);
            picTable.Controls.Add(pics[i]);
        }

        pics[0].Location = new Point(379, 410);
        var pos00 = pics[0].PointToScreen(pics[0].Location);
        pos00 = pics[0].PointToClient(pos00);
        pics[0].Parent = picTable;
        pics[0].Location = pos00;

        pics[1].Location = new Point(188, 377);
        var pos01 = pics[1].PointToScreen(pics[1].Location);
        pos01 = pics[1].PointToClient(pos01);
        pics[1].Parent = picTable;
        pics[1].Location = pos01;

        pics[2].Location = new Point(56, 288);
        var pos02 = pics[2].PointToScreen(pics[2].Location);
        pos02 = pics[2].PointToClient(pos02);
        pics[2].Parent = picTable;
        pics[2].Location = pos02;

I got this result: enter image description here

So with the code:

//another picturebox    
var poscard = pictureBox1.PointToScreen(pictureBox1.Location);
poscard = pictureBox1.PointToClient(poscard);
pictureBox1.Parent = picTable;
pictureBox1.Location = poscard;

Result is: enter image description here

the card is cut off ... I tried everything I knew to solve but no use. Any idea how to make the card appear behind the image, that is, part of the card be hidden without this "cut"?

Grateful for the help.

Pramod Gharu
  • 1,105
  • 3
  • 9
  • 18

1 Answers1

0

The comments all apply but since your title mentions transparency you ought to realize that there is strictly no transparency for overlapping controls.

Only nested controls can be transparent.

This seems to be the problem you have:

  • It looks like the ovals are nested in the table, so their transparency works.

  • But the card and the oval are **overlapping**, so transparency between them does not work.

You can workaround by making the the ovals rounded rectangles using a region..

See here for an example but there are quite a few other code examples you find when searching for 'rounded rectangle'..

Since you need many of them best make a RoundedPictureBox class!

Usually the best solution is to not use any Controls for displaying (non-rectangluar) images but to DrawImage them.

TaW
  • 53,122
  • 8
  • 69
  • 111
  • Thank TaW actually rounding the rectangle the result is better, which is really killing me AddArc method are the coordinates for the perfect way an "oval rectangle" Thankful again – Roberto Wsd Dec 28 '15 at 23:24
  • Well, do not touch them, I'd say.. When calling the `GetRoundPath` function you just need to use half the height as the radius, no? – TaW Dec 29 '15 at 00:06
  • If you are happy with an answer, please consider [accepting](http://stackoverflow.com/help/accepted-answer) it..! – TaW Dec 29 '15 at 16:45