简体   繁体   中英

C# transparent image above 2 images

I have make a playbar for my new MP3 player but I have a problem as shown in attachement and this is my simple code :

 public void setpercent(int percent)
     {
         pic1.Width = pic2.Width / 100 * percent;
         pic3.Left = pic1.Width - ( pic3.Width /2); 

     }

I thought to use Graphics but I can't move it after. and the method of ".Parent" doesn't work in this case.

在此处输入图片说明

In the Load() event of your Form, modify the Region() property of pic3 so that it becomes circular instead of rectangular. This can be done by construction a GraphicsPath and adding an Ellipse to it. If this doesn't line up properly with your image, then manually determine the correct bounding box for the ellipse and use that instead:

    private void Form1_Load(object sender, EventArgs e)
    {
        System.Drawing.Drawing2D.GraphicsPath GP = new System.Drawing.Drawing2D.GraphicsPath();
        GP.AddEllipse(pic3.ClientRectangle);
        pic3.Region = new Region(GP);
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM