zoukankan      html  css  js  c++  java
  • C# PicBox 背景透明

    private void picBackground_Paint(object sender, PaintEventArgs e)
            {
                foreach (Control C in this.Controls)
                {
                    if (C is Label)
                    {

                        Label L = (Label)C;

                        L.Visible = false;

                        //设置绘制文字的格式  
                        StringFormat strFmt = new System.Drawing.StringFormat();
                        strFmt.Alignment = StringAlignment.Center; //文本垂直居中  
                        strFmt.LineAlignment = StringAlignment.Center; //文本水平居中  
                        e.Graphics.DrawString(L.Text, this.Font, new SolidBrush(this.ForeColor), new RectangleF(L.Left - picBackground.Left, L.Top - picBackground.Top, L.Width, L.Height), strFmt); 

                    }
                    else if (C is PictureBox)
                    {
                        PictureBox L = (PictureBox)C;
                        if (!L.Name.Equals("picBackground"))
                        {
                            L.Visible = false;
                            ImageAttributes attrib = new ImageAttributes();
                            //Bitmap img = new Bitmap(L.Image);
                            Color color = Color.Transparent;
                            attrib.SetColorKey(color, color);
                            e.Graphics.DrawImage(L.Image, new Rectangle(L.Left - picBackground.Left, L.Top - picBackground.Top, L.Width, L.Height), 0, 0, L.Image.Width, L.Image.Height, GraphicsUnit.Pixel, attrib);
                        }
                    }
                }
            }

  • 相关阅读:
    jeecg+activemq之AjaxServlet+tomcat7
    odoo8.0 win7 64位 安装配置(补遗)
    odoo种种
    MySQL种种
    html种种
    jQuery种种
    freemarker种种
    jQuery ui autocomplete 与easyUI冲突解决办法(重命名ui的autocomplete 和menu部分)
    vue实现点击按钮下载图片
    VUE父子组件之间的传值,以及兄弟组件之间的传值
  • 原文地址:https://www.cnblogs.com/xsmhero/p/2620262.html
Copyright © 2011-2022 走看看