• CAD—鼠标悬浮显示信息


        在CAD2006中,可以借用Editor的两个事件来实现鼠标的悬浮显示信息的功能,即ToolTip。这两个事件都可以实现ToolTip的功能。具体代码如下:

    代码
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            
    #region IExtensionApplication 成员

            
    public void Initialize()
            {
                MyToolTip();
            }

            
    public void Terminate()
            {
                
    //throw new System.Exception("The method or operation is not implemented.");
            }

            
    private void MyToolTip()
            {
                ed.PointMonitor 
    +=new PointMonitorEventHandler(ToolTip);
                ed.PointFilter 
    +=new PointFilterEventHandler(ed_PointFilter);
            }

            
    private void ToolTip(object sender, PointMonitorEventArgs e)
            {
                Database db 
    = HostApplicationServices.WorkingDatabase;
                FullSubentityPath[] paths 
    = e.Context.GetPickedEntities();

                
    if (paths.Length > 0)
                {
                    FullSubentityPath fsPath 
    = paths[0];
                    
    using (Transaction trans = db.TransactionManager.StartTransaction())
                    {
                        ObjectId entId 
    = fsPath.GetObjectIds()[0];
                        Entity ent 
    = trans.GetObject(entId, OpenMode.ForRead) as Entity;
                        e.AppendToolTipText(
    "PointMonitor事件\n实体是:" + ent.GetType().ToString()); 
                        trans.Commit();
                    }
                }
                
    else
                {
                    e.AppendToolTipText(
    "请选择图元");
                }
            }

                   
    private void ed_PointFilter(object sender, PointFilterEventArgs e)
                   {
                       Database db 
    = HostApplicationServices.WorkingDatabase;
                       FullSubentityPath[] full 
    = e.Context.GetPickedEntities();
                       
    if (full.Length > 0)
                       {
                          FullSubentityPath fSon 
    = full[0];
                          ObjectId[] ids 
    = fSon.GetObjectIds();
                          ObjectId id 
    = ids[0];
                          
    using (Transaction trans = db.TransactionManager.StartTransaction())
                          {
                              Entity ent 
    = trans.GetObject(id, OpenMode.ForRead) as Entity;
                              e.Result.ToolTipText 
    = "PointFilter事件\nID:" + id.ToString();  
                          }
                      }  
                   }
              
    #endregion
  • 相关阅读:
    hdu4930 模拟斗地主
    hdu4930 模拟斗地主
    hdu4923 f(A,B)分段处理
    hdu4923 f(A,B)分段处理
    poj2112 二分最大流+Floyd
    poj2112 二分最大流+Floyd
    POJ1149 PIGS(最大流)
    POJ1149 PIGS(最大流)
    对最大团的理解
    对最大团的理解
  • 原文地址:https://www.cnblogs.com/wangyong/p/1673216.html
Copyright © 2020-2023  润新知