tooltip显示图元类型
using Autodesk.AutoCAD.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 不显示内容 <p>以前试过ToolTip,但有个问题,2010里的ToolTip是灰色的底色,</p><p>而代码实现的是蓝色的,有办法解决么?</p> <p>VB代码:</p><p>Imports Autodesk.AutoCAD.ApplicationServices<br/>Imports Autodesk.AutoCAD.DatabaseServices<br/>Imports Autodesk.AutoCAD.EditorInput<br/>Imports Autodesk.AutoCAD.GeomeTry<br/>Imports Autodesk.AutoCAD.Runtime</p><p>Namespace tooltip<br/> Public Class Class1<br/> Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor <CommandMethod("TestOn")> _<br/> Public Sub MyTestOn()<br/> AddHandler ed.PointMonitor, New PointMonitorEventHandler(AddressOf ed_PointMonitor)<br/> End Sub<br/> <CommandMethod("TestOff")> _<br/> Public Sub MyTestOff()<br/> RemoveHandler ed.PointMonitor, New PointMonitorEventHandler(AddressOf ed_PointMonitor)<br/> End Sub</p><p> Private Sub ed_PointMonitor(ByVal sender As Object, ByVal e As PointMonitorEventArgs)<br/> Dim db As Database = HostApplicationServices.WorkingDatabase<br/> Dim ipc As InputPointContext = e.Context<br/> Dim ePaths() As FullSubentityPath = ipc.GetPickedEntities()<br/> If ePaths.Length > 0 Then<br/> Dim ePath As FullSubentityPath = ePaths(0)<br/> Dim trans As Transaction = db.TransactionManager.StartTransaction()<br/> Dim entId As ObjectId = ePath.GetObjectIds()(0)<br/> Dim ent As Entity = CType(trans.GetObject(entId, OpenMode.ForRead), Entity)<br/> e.AppendToolTipText(vbCrLf & "这是 :" + ent.GetType().FullName)<br/> trans.Commit()<br/> End If<br/> End Sub<br/> End Class<br/>End Namespace<br/></p> 学习学习 没看懂,希望高手指点一下VBA部分的! 我测试了一下,程序运行正常
可就是看不到ToolTip,不知是什么原因? 好好学习,正是我要学习的东西 我直接使用这个e.AppendToolTipText显示内容,为什么不显示呢?各位大神帮忙啊。。。谢谢了 真不错的工具 学习 了赞 ~
页:
[1]
2