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);
    }
    }
  • 相关阅读:
    POJ 1401 Factorial
    POJ 2407 Relatives(欧拉函数)
    POJ 1730 Perfect Pth Powers(唯一分解定理)
    POJ 2262 Goldbach's Conjecture(Eratosthenes筛法)
    POJ 2551 Ones
    POJ 1163 The Triangle
    POJ 3356 AGTC
    POJ 2192 Zipper
    POJ 1080 Human Gene Functions
    POJ 1159 Palindrome(最长公共子序列)
  • 原文地址:https://www.cnblogs.com/platfarm/p/3768071.html
Copyright © 2011-2022 走看看