[CommandMethod("MTL")]
public void MTL()
{
MtxtCommand(AttachmentPoint.TopLeft);
}
[CommandMethod("MTC")]
public void MTC()
{
MtxtCommand(AttachmentPoint.TopCenter);
}
[CommandMethod("MTR")]
public void MTR()
{
MtxtCommand(AttachmentPoint.TopRight);
}
[CommandMethod("MML")]
public void MML()
{
MtxtCommand(AttachmentPoint.MiddleLeft);
}
[CommandMethod("MMC")]
public void MMC()
{
MtxtCommand(AttachmentPoint.MiddleCenter);
}
[CommandMethod("MMR")]
public void MMR()
{
MtxtCommand(AttachmentPoint.MiddleRight);
}
[CommandMethod("MBL")]
public void MBL()
{
MtxtCommand(AttachmentPoint.BottomLeft);
}
[CommandMethod("MBC")]
public void MBC()
{
MtxtCommand(AttachmentPoint.BottomCenter);
}
[CommandMethod("MBR")]
public void MBR()
{
MtxtCommand(AttachmentPoint.BottomRight);
}
private void MtxtCommand(AttachmentPoint attachPnt)
{
PromptPointOptions ppo
= new PromptPointOptions
("\nSelect Mtext's " + Enum.GetName(typeof(AttachmentPoint
), attachPnt
) + " attachment point: ");
PromptPointResult ppr = Ed.GetPoint(ppo);
if (ppr.Status != PromptStatus.OK)
{
return;
}
using (Transaction trx = Db.TransactionManager.StartTransaction())
{
using (MText mtxt
= new MText
()) {
mtxt.SetDatabaseDefaults();
mtxt.Contents = "";
mtxt.Location = ppr.Value;
mtxt.SetAttachmentMovingLocation(attachPnt);
mtxt.TextStyleId = Db.Textstyle;
TextStyleTableRecord txtStyleTblRecord = Db.Textstyle.GetDBObject<TextStyleTableRecord>();
if (txtStyleTblRecord.Annotative == AnnotativeStates.True)
{
mtxt.Annotative = AnnotativeStates.True;
ObjectContextManager ocm =Db.ObjectContextManager;
ObjectContextCollection occ =ocm.GetContextCollection("ACDB_ANNOTATIONSCALES");
ObjectContexts.AddContext(mtxt, occ.CurrentContext);
mtxt.TextHeight = (1.0 / Db.Cannoscale.Scale) * txtStyleTblRecord.TextSize;
}
else
{
mtxt.TextHeight = Db.Textsize;
}
InplaceTextEditorSettings ipts
= new InplaceTextEditorSettings
(); InplaceTextEditor.Invoke(mtxt, ipts);
if (!String.IsNullOrWhiteSpace(mtxt.Contents))
{
BlockTableRecord btr = Db.CurrentSpace(OpenMode.ForWrite);
btr.AppendEntity(mtxt);
trx.AddNewlyCreatedDBObject(mtxt, true);
}
}
trx.Commit();
}
}