• 双击CAD对象(具有扩展数据),显示自定义对话框实现方法


    转自:Cad人生

    链接:http://www.cnblogs.com/cadlife/p/3463337.html

    题目:双击CAD对象,显示自定义对话框实现方法

    内容粘贴如下:

     主要是绑定两个事件:一个是 Application.DocumentManager.DocumentLockModeChanged -----  该事件为文档锁定事件,一直在被监测中
    一个是 Application.BeginDoubleClick ----- 该事件为应用程序的双击事件
     1     class TlsApplication : IExtensionApplication //程序初始化,在加载dll时,cad会自动捕捉并运行该过程
      3     { 
      5         void IExtensionApplication.Initialize() 
      7         { 
      9             TTest.Start(); 
     11         } 
     13         void IExtensionApplication.Terminate() 
     15         { 
     17         } 
     19     }
     20 
     21     class TTest 
     23     { 
     25         static bool m_Veto = false; 
     27         public static void Start() 
     29         { 
     31             Application.DocumentManager.DocumentLockModeChanged += new DocumentLockModeChangedEventHandler(vetoCommand); 
     33             Application.BeginDoubleClick += new BeginDoubleClickEventHandler(beginDoubleClick); 
     35         } 
     37         static void beginDoubleClick(object sender, BeginDoubleClickEventArgs e) 
     39         { 
     41             Document doc = Application.DocumentManager.MdiActiveDocument; 
     43             Editor ed = doc.Editor; 
     45             PromptSelectionResult res = ed.SelectImplied(); 
     47             SelectionSet ss = res.Value; 
     49             if (ss != null) 
     51             { 
     53                 if (ss.Count == 1) 
     55                 { 
     57                     using (Transaction tr = doc.TransactionManager.StartTransaction()) 
     59                     { 
     61                         Line line = tr.GetObject(ss[0].ObjectId, OpenMode.ForRead) as Line; 
     63                         if (line != null) 
     65                         { 
     67                             ResultBuffer rb = line.GetXDataForApplication("MyApp"); //提取对象的扩展数据
     69                             if (rb != null) 
     71                             { 
     73                                 m_Veto = true; 
     75                             } 
     77                         } 
     79                     } 
     81                 } 
     83             } 
     85         }
     86 
     87         static void vetoCommand(object sender, DocumentLockModeChangedEventArgs e) 
     89         { 
     91             if (e.GlobalCommandName.ToLower() == "properties") //判断是否是调用属性对话框
     93             { 
     95                 if (m_Veto) 
     97                 {
     99                     e.Veto(); 
    103                     Application.ShowAlertDialog("hello"); //在此处可以添加自定义对话框
    105                     m_Veto = false; 
    107                 } 
    109             } 
    111         } 
    113     }
  • 相关阅读:
    【转】ORACLE Dataguard安装
    win7 配置微软的深度学习caffe
    深度学习-开源方案
    Python之包管理工具
    C#调用Python脚本的简单示例
    转Python 和C#的交互
    转-使用 CefSharp 在 C# App 中嵌入 Chrome 浏览器
    转-在Mac OS上搭建Python的开发环境
    Weex入门与进阶指南
    A couple of notes about .NET Framework 4.6 setup behaviors
  • 原文地址:https://www.cnblogs.com/whlkx/p/8678779.html
Copyright © 2020-2023  润新知