[CommandMethod("DoText")]
public void dotext()
{
DisplayText("Testing");
}
public static DBObjectCollection temptext
= new DBObjectCollection
(); public static IntegerCollection intColl = null;
public static bool eventadded = false;
public static void DisplayText(string mystring)
{
intColl
= new IntegerCollection
(); Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor MyEditor = Application.DocumentManager.MdiActiveDocument.Editor;
Point2d screenSize = (Point2d)Application.GetSystemVariable("SCREENSIZE");
System.Drawing.Point upperLeft
= new System.Drawing.Point(0,
0); System.Drawing.Point lowerRight
= new System.Drawing.Point((int)screenSize
.X,
(int)screenSize
.Y); Point3d upperLeftWorld = MyEditor.PointToWorld(upperLeft, 0);
Point3d lowerRightWorld = MyEditor.PointToWorld(lowerRight, 0);
double screensize = upperLeftWorld.DistanceTo(lowerRightWorld);
if (!eventadded)
{
acDoc
.CommandWillStart += new CommandEventHandler
(doc_CommandWillStart
); eventadded = true;
}
DBText mytext
= new DBText
(); mytext.TextString = mystring;
mytext.Height = screensize * .02;
mytext
.Position = new Point3d
(lowerRightWorld
.X - 20, lowerRightWorld
.Y + 20,
0); mytext.ColorIndex = 140;
aGi.TransientManager.CurrentTransientManager.AddTransient(mytext, aGi.TransientDrawingMode.DirectTopmost, 128, intColl);
temptext.Add(mytext);
}
public static void doc_CommandWillStart(object sender, CommandEventArgs e)
{
if (e.GlobalCommandName.Contains("REGEN"))
{
ClearMarkers();
Document doc = Application.DocumentManager.MdiActiveDocument;
doc
.CommandWillStart -= new CommandEventHandler
(doc_CommandWillStart
); eventadded = false;
}
}
public static void ClearMarkers()
{
for (int i = 0; i < temptext.Count; i++)
{
aGi.TransientManager.CurrentTransientManager.EraseTransient(temptext[i], intColl);
temptext[i].Dispose();
}
temptext.Clear();
}