tooltip显示图元类型
using Autodesk..ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
namespace tooltip
{
public class Class1
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
public void MyTestOn()
{
ed.PointMonitor += new PointMonitorEventHandler(ed_PointMonitor);
}
public void MyTestOff()
{
ed.PointMonitor -= new PointMonitorEventHandler(ed_PointMonitor);
}
void ed_PointMonitor(object sender, PointMonitorEventArgs e)
{
Database db = HostApplicationServices.WorkingDatabase;
InputPointContext ipc = e.Context;
FullSubentityPath[] ePaths = ipc.GetPickedEntities();
if (ePaths.Length > 0)
{
FullSubentityPath ePath = ePaths;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
ObjectId entId = ePath.GetObjectIds();
Entity ent = (Entity)trans.GetObject(entId, OpenMode.ForRead);
e.AppendToolTipText("\n这是 :" + ent.GetType().FullName);
trans.Commit();
}
}
}
}
}加载DLL,输入teston命令后,用鼠标指向一个图元,会出现tooltip提示。用testoff命令可关掉这个功能。当然,你可以进一步修改代码,如显示扩展数据,加载DLL后功能即打开……
e.AppendToolTipText 不显示内容 以前试过ToolTip,但有个问题,2010里的ToolTip是灰色的底色,
而代码实现的是蓝色的,有办法解决么?
VB代码:
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.GeomeTry
Imports Autodesk.AutoCAD.Runtime
Namespace tooltip
Public Class Class1
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor _
Public Sub MyTestOn()
AddHandler ed.PointMonitor, New PointMonitorEventHandler(AddressOf ed_PointMonitor)
End Sub
_
Public Sub MyTestOff()
RemoveHandler ed.PointMonitor, New PointMonitorEventHandler(AddressOf ed_PointMonitor)
End Sub
Private Sub ed_PointMonitor(ByVal sender As Object, ByVal e As PointMonitorEventArgs)
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim ipc As InputPointContext = e.Context
Dim ePaths() As FullSubentityPath = ipc.GetPickedEntities()
If ePaths.Length > 0 Then
Dim ePath As FullSubentityPath = ePaths(0)
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Dim entId As ObjectId = ePath.GetObjectIds()(0)
Dim ent As Entity = CType(trans.GetObject(entId, OpenMode.ForRead), Entity)
e.AppendToolTipText(vbCrLf & "这是 :" + ent.GetType().FullName)
trans.Commit()
End If
End Sub
End Class
End Namespace
学习学习 没看懂,希望高手指点一下VBA部分的! 我测试了一下,程序运行正常
可就是看不到ToolTip,不知是什么原因? 好好学习,正是我要学习的东西 我直接使用这个e.AppendToolTipText显示内容,为什么不显示呢?各位大神帮忙啊。。。谢谢了 真不错的工具
页:
[1]
2