Transparent background

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
ELVITEC-AXOS
Posts: 4
Joined: 21 May 2010, 13:07

Transparent background

Post by ELVITEC-AXOS » 16 Apr 2014, 16:35

Hello,

i'm working with VIsualStudio 2010 and C#. and CAD Import NET 9.0.0.30903

In a PictureBox, i load a BMP file. After, i would like to draw an ImageCAD in the PictureBox but the ImageCAD erase the previous bitmap !!

Code: Select all

public partial class Form1 : Form
    {
        /// <summary>Image de base</summary>
        public Bitmap ImageBase;
        /// <summary>CAD Image DXF</summary>
        private CADImage m_CADImageDXF;
        
        public Form1()
        {
            InitializeComponent();

            //----- CAD IMPORT
            ArrayList regDat = new ArrayList();
            regDat.Add("xxx");
            regDat.Add("xxx");
            string Key = "xxxx";
            Protection.Register(Key, regDat, false);

        }

        private void button1_Click(object sender, EventArgs e)
        {
            //_________ Load File
            string ExePath = AppDomain.CurrentDomain.BaseDirectory;
            FileStream fStream = new FileStream(ExePath + "test.bmp", FileMode.Open, FileAccess.Read);
            ImageBase = new Bitmap(Image.FromStream(fStream));
            fStream.Close();
            if (fStream != null) fStream.Close();
            //---
            pbxImage.Image = ImageBase;  
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //--- Load DXF File
            m_CADImageDXF = new CADImage();
            m_CADImageDXF = CADImage.CreateImageByExtension("Dummy.DXF");
            string ExePath = AppDomain.CurrentDomain.BaseDirectory;
            m_CADImageDXF.LoadFromFile(ExePath  + "test.dxf");
            m_CADImageDXF.GraphicsOutMode = DrawGraphicsMode.GDIPlus;
            pbxImage.Refresh();
        }

        private void pbxImage_Paint(object sender, PaintEventArgs e)
        {           
            if (null != m_CADImageDXF)
                m_CADImageDXF.Draw(e.Graphics, pbxImage.ClientRectangle);
        }
    }
How can i change the background of the ImageCad ?


NOTE :
With the version CAD Import NET 6.0.2603.19332, this code was OK !!


Thanks.

ELVITEC-AXOS
Posts: 4
Joined: 21 May 2010, 13:07

Re: Transparent background

Post by ELVITEC-AXOS » 22 Apr 2014, 16:43

private void pbxImage_Paint(object sender, PaintEventArgs e)
{
if (null != m_CADImageDXF)
{
m_CADImageDXF.IsShowBackground = false;
m_CADImageDXF.Draw(e.Graphics, pbxImage.ClientRectangle);
}
}

Post Reply