zoukankan      html  css  js  c++  java
  • 监视用户是保存用户编辑还是放弃参照编辑

    原文

     1 using Autodesk.AutoCAD.ApplicationServices;
     2 using Autodesk.AutoCAD.DatabaseServices;
     3 using Autodesk.AutoCAD.EditorInput;
     4 using Autodesk.AutoCAD.Runtime;
     5 
     6 // 此行不是强制性的,但可以提高装载性能
     7 [assembly: CommandClass(typeof(监视用户是保存用户编辑还是放弃参照编辑.XrefLongTrans))]
     8 
     9 namespace 监视用户是保存用户编辑还是放弃参照编辑
    10 {
    11     public class XrefLongTrans
    12     {
    13         enum EditInPlaceXrefState
    14         {
    15             Discarded,
    16             Saved
    17         };
    18 
    19         static EditInPlaceXrefState state = EditInPlaceXrefState.Discarded;
    20 
    21         [CommandMethod("WatchXref")]
    22         public void WatchXref()
    23         {
    24             Document doc = Application.DocumentManager.MdiActiveDocument;
    25             if (doc == null) return;
    26             Editor ed = doc.Editor;
    27             LongTransactionManager longTranMan = Application.LongTransactionManager;
    28             longTranMan.CheckedIn += TrMan_CheckedIn;
    29             longTranMan.Aborted += TrMan_Aborted;
    30             doc.CommandEnded += Doc_CommandEnded;
    31         }
    32         [CommandMethod("UnWatchXref")]
    33         public void UnWatchXref()
    34         {
    35             Document doc = Application.DocumentManager.MdiActiveDocument;
    36             if (doc == null) return;
    37             Editor ed = doc.Editor;
    38             LongTransactionManager longTranMan = Application.LongTransactionManager;
    39             longTranMan.CheckedIn -= TrMan_CheckedIn;
    40             longTranMan.Aborted -= TrMan_Aborted;
    41             doc.CommandEnded -= Doc_CommandEnded;
    42         }
    43 
    44         private void TrMan_Aborted(object sender, LongTransactionEventArgs e)
    45         {
    46             Document doc = Application.DocumentManager.MdiActiveDocument;
    47             if (doc == null) return;
    48             Editor ed = doc.Editor;
    49             if (e.Transaction.Type == LongTransactionType.XRefDb)
    50             {
    51                 ed.WriteMessage("
    Long transaction {0} aborted
    ", e.Transaction.LongTransactionName);
    52                 state = EditInPlaceXrefState.Discarded;
    53             }
    54         }
    55 
    56         private void TrMan_CheckedIn(object sender, LongTransactionEventArgs e)
    57         {
    58             Document doc = Application.DocumentManager.MdiActiveDocument;
    59             if (doc == null) return;
    60             Editor ed = doc.Editor;
    61             if (e.Transaction.Type == LongTransactionType.XRefDb)
    62             {
    63                 ed.WriteMessage("
    Long transaction {0} commited
    ", e.Transaction.LongTransactionName);
    64                 state = EditInPlaceXrefState.Saved;
    65             }
    66         }
    67 
    68         private void Doc_CommandEnded(object sender, CommandEventArgs e)
    69         {
    70             if (e.GlobalCommandName.ToUpper() == "REFCLOSE")
    71             {
    72                 Document doc = Application.DocumentManager.MdiActiveDocument;
    73                 if (doc == null) return;
    74                 Editor ed = doc.Editor;
    75                 ed.WriteMessage("
    Modification of XREF {0}
    ", (state == EditInPlaceXrefState.Saved) ? "Saved" : "Discarded");
    76             }
    77         }
    78     }
    79 }
  • 相关阅读:
    zookeeper报错java.net.ConnectException: Connection refused: no further information
    dubbo 使用zookeeper 出现 Dubbo客户端调用报错NullPointerException
    docker下载镜像received unexpected Http status:500 Internal Server Error
    Spring Security 无法登陆,报错:There is no PasswordEncoder mapped for the id “null”
    js 解决中文乱码的问题
    使用Elasticsearch 出现的拒绝连接
    com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class cn.edu.
    yii2判断数据库字段is null
    MySQL之终端(Terminal)管理数据库、数据表、数据的基本操作
    yii2.0-rules验证规则应用实例
  • 原文地址:https://www.cnblogs.com/smallstoneman/p/11209144.html
Copyright © 2011-2022 走看看