• 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
  • 相关阅读:
    MKMapViewDelegate
    MKMapView
    正则表达式随手篇
    c#多线程
    sql模糊查询效率
    c#多线程,进度条,实时给前台发送数据
    如何使用CocoaPods
    TabBar自定义方式(一)
    Spring MVC 学习资料
    优化Myeclipse10 Building Workspace速度慢等问题
  • 原文地址:https://www.cnblogs.com/wangyong/p/1673216.html
Copyright © 2020-2023  润新知