在图上,绘制一个批注
[ object, uuid(2541C92F-E8ED-427E-AA18-304A708BE58E), dual, nonextensible, pointer_default(unique) ] interface IMxDrawComment : IMxDrawEntity;
MxDrawComment.idl
例如: C#
private void DynWorldDrawComment(MxDrawCustomEntity pCustomEntity, MxDrawWorldDraw pWorldDraw,MxDrawPoint curPt) { string sText = pCustomEntity.GetString("Text"); Double dTextHeight = pCustomEntity.GetDouble("TextHeight"); Int32 iEdgeNumber = pCustomEntity.GetLong("EdgeNumber"); Double dShapRadius = pCustomEntity.GetDouble("ShapRadius"); MxDrawComment comment = new MxDrawComment(); comment.Text = sText; comment.TextHeight = dTextHeight; comment.EdgeNumber = (Int16)iEdgeNumber; comment.ShapRadius = dShapRadius; comment.basePoint = curPt; comment.Position = curPt; pWorldDraw.TextStyle = "MyCommentFont"; pWorldDraw.DrawEntity((MxDrawEntity)comment); } private void DynWorldDrawComment2(MxDrawCustomEntity pCustomEntity, MxDrawWorldDraw pWorldDraw, MxDrawPoint curPt) { string sText = pCustomEntity.GetString("Text"); Double dTextHeight = pCustomEntity.GetDouble("TextHeight"); Int32 iEdgeNumber = pCustomEntity.GetLong("EdgeNumber"); Double dShapRadius = pCustomEntity.GetDouble("ShapRadius"); MxDrawPoint basePoint = pCustomEntity.GetPoint("BasePoint"); MxDrawComment comment = new MxDrawComment(); comment.Text = sText; comment.TextHeight = dTextHeight; comment.EdgeNumber = (Int16)iEdgeNumber; comment.ShapRadius = dShapRadius; comment.basePoint = basePoint; comment.Position = curPt; pWorldDraw.TextStyle = "MyCommentFont"; pWorldDraw.DrawEntity((MxDrawEntity)comment); } private void DrawComment() { axMxDrawX1.AddTextStyle2("MyCommentFont","黑体",0.7); MxDrawUiPrPoint getPt = new MxDrawUiPrPoint(); getPt.message = "输入标注插入基点"; MxDrawCustomEntity spDrawData = getPt.InitUserDraw("DrawComment"); spDrawData.SetString("Text", "测试批注文字"); spDrawData.SetDouble("TextHeight", 100); spDrawData.SetLong("EdgeNumber", 2); spDrawData.SetDouble("ShapRadius", 300); if (getPt.go() != MCAD_McUiPrStatus.mcOk) return; MxDrawUiPrPoint getSecondPt = new MxDrawUiPrPoint(); getSecondPt.message = "输入标注位置点"; getSecondPt.basePoint = getPt.value(); getSecondPt.setUseBasePt(false); spDrawData = getSecondPt.InitUserDraw("DrawComment2"); spDrawData.SetPoint("BasePoint", getPt.value()); spDrawData.SetString("Text", "测试批注文字"); spDrawData.SetDouble("TextHeight", 100); spDrawData.SetLong("EdgeNumber", 2); spDrawData.SetDouble("ShapRadius", 300); if (getSecondPt.go() != MCAD_McUiPrStatus.mcOk) return; MxDrawResbuf ret = spDrawData.Draw(); for (int i = 0; i < ret.Count; i++) { MxDrawEntity ent = (MxDrawEntity)ret.AtObject(i); ent.TextStyle = "MyCommentFont"; } }
例如: C# 直接绘制
MxDrawComment comment = (MxDrawComment)axMxDrawX1.NewEntity("IMxDrawComment"); comment.Text = "测试批注文字"; comment.TextHeight = 100; comment.EdgeNumber = 0; comment.ShapRadius = 300; axMxDrawX1.DrawEntity(comment); axMxDrawX1.ZoomAll();