zoukankan      html  css  js  c++  java
  • CADViewX 9中使用图片作为背景的代码示例

    在以前的老版本的CADViewX Import.Net中, 我们可以使用一个PictureBox, 然后加载一个BMP文件, 最后将CADViewX Import.Net产生的图像画上去。 代码如下

    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)
            {
                //加载BMP文件
                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)
            {
                //--- 加载DXF文件
                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);
            }
        }

    在CADViewX 9以后, 这段代码就会有问题。 因为CADViewX import.net会先擦除BMP的背景。 我们要设置他的背景属性。如下代码即可。

    private void pbxImage_Paint(object sender, PaintEventArgs e)
    { 
    if (null != m_CADImageDXF)
    {
     //这句话非常重要
    m_CADImageDXF.IsShowBackground = false; 
    m_CADImageDXF.Draw(e.Graphics, pbxImage.ClientRectangle);
    }
    }
  • 相关阅读:
    2020牛客暑期多校训练营(第二场)G-Greater and Greater bitset
    2020牛客暑期多校训练营(第二场)H Happy Triangle 线段树
    平衡树——splay
    动态规划之状态压缩
    动态规划入门理解
    快速幂入门
    最小生成树初步
    线性筛素数
    最短路径—迪杰斯特拉算法入门
    并查集初步
  • 原文地址:https://www.cnblogs.com/platfarm/p/3768071.html
Copyright © 2011-2022 走看看