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);
    }
    }
  • 相关阅读:
    安全加固3-加固
    Centos7 64位 -- glibc-2.29 编译升级方法(已成功)
    Centos7 -- glibc 升级失败、意外删除、故意删除后的处理方法
    系统引导修复,grub2下的各种骚作
    linux 升级 5.0.2内核
    kvm虚拟化二: 字符界面管理及 无人值守安装
    kvm虚拟化一: 图形化的管理方式
    Linux rhel7 无线网络配置
    虚拟化简介
    requests模块使用二
  • 原文地址:https://www.cnblogs.com/platfarm/p/3768071.html
Copyright © 2011-2022 走看看