js implemented Definitions:
Dynamic drag and drop drawing event:
function DynWorldDrawComment2( pCustomEntity,pWorldDraw, curPt) { // get drawing parameters. var sText = pCustomEntity.GetString("Text"); var dTextHeight = pCustomEntity.GetDouble("TextHeight"); var iEdgeNumber = pCustomEntity.GetLong("EdgeNumber"); var dShapRadius = pCustomEntity.GetDouble("ShapRadius"); var basePoint = pCustomEntity.GetPoint("BasePoint"); // Create an annotation object. var comment = mxOcx.NewEntity("IMxDrawComment"); comment.Text = sText; comment.TextHeight = dTextHeight; comment.EdgeNumber = iEdgeNumber; comment.ShapRadius = dShapRadius; comment.basePoint = basePoint; comment.Position = curPt; // set the text style. pWorldDraw.TextStyle = "MyCommentFont"; // Draw dynamic. pWorldDraw.DrawEntity(comment); }
Dynamic Draw Text:
function ExplodeFun(pCustomEntity, pWorldDraw, txt) { was sGuid = pCustomEntity.Guid; if (sGuid == "TestMxCustomEntity1") { if (!pCustomEntity.IsHave("First")) return; var stp = pCustomEntity.GetPoint("First"); var ept = pCustomEntity.GetPoint("BasePoint"); var dimpt = pCustomEntity.GetPoint("DimPoint"); var txt = pCustomEntity.GetString("Text"); var textH = pCustomEntity.GetDouble("TextHeight"); var edgeNum = pCustomEntity.GetLong("EdgeNumber"); var shapRadius = pCustomEntity.GetDouble("ShapRadius"); var isCircle = pCustomEntity.GetLong("isCircle"); var comment = mxOcx.NewEntity("IMxDrawComment"); comment.Text = txt; comment.TextHeight = textH; comment.EdgeNumber = edgeNum; comment.ShapRadius = shapRadius; comment.basePoint = ept; comment.Position = dimpt; pWorldDraw.TextStyle = "MyCommentFont"; // Draw dynamic. pWorldDraw.DrawEntity(comment); // Draw rectangle. if (isCircle) { was dR = stp.DistanceTo (ept) * 0.5; var vec = stp.SumVector (ept); vec.Mult (0.5); ept.Add(vec); pWorldDraw.DrawCircle(ept.x, ept.y, dR); } else { pWorldDraw.DrawLine(stp.x, stp.y, stp.x, ept.y); pWorldDraw.DrawLine(stp.x, ept.y, ept.x, ept.y); pWorldDraw.DrawLine(ept.x, ept.y, ept.x, stp.y); pWorldDraw.DrawLine(ept.x, stp.y, stp.x, stp.y); } mxOcx.SetEventRet (1); } }
Dynamic Draw Text:
function DoComment3() { var getPt = mxOcx.NewComObject("IMxDrawUiPrPoint"); getPt.message = "point to take a first point"; if (getPt.go() != 1) { return; } was frstPt = getPt.value (); if (frstPt == null) return; was triggered = mxOcx.NewUtility (); var secondPt = utl.GetCorner (frstPt, "point to take a second point"); if (secondPt == null) return; var param = mxOcx.NewResbuf(); param.AddString(""); param.AddDouble(200); var ret = mxOcx.CallEx("Mx_ShowMTextDialog", param); if (ret.AtString(0) != "Ok") { return; } was txt = ret.AtString (1); was txtH = ret.AtDouble (2); was txtColorIndex = ret.AtLong (3); // Add linefeed operator \\ P //txt = txt + "\\PTEST"; // Create a text style, text font for comment. mxOcx.AddTextStyle2 ( "MyCommentFont", "black body", 0.7); // Create an object to interact with the user to take points. var getSecondPt = mxOcx.NewComObject("IMxDrawUiPrPoint"); getSecondPt.message = "Enter the position of the point marked"; getSecondPt.basePoint = secondPt; getSecondPt.setUseBasePt(false); spDrawData = getSecondPt.InitUserDraw ( "DrawComment2"); // set the dynamic rendering parameters. spDrawData.SetPoint("BasePoint", secondPt); spDrawData.SetString("Text", txt); spDrawData.SetDouble("TextHeight", txtH); spDrawData.SetLong("EdgeNumber", 2); spDrawData.SetDouble("ShapRadius", 1); // start to take second spot. if (getSecondPt.go() != 1) return; var ent = mxOcx.DrawCustomEntity("TestMxCustomEntity1", ""); ent.SetPoint("BasePoint", secondPt); ent.SetString("Text", txt); ent.SetDouble("TextHeight", txtH); ent.SetLong("EdgeNumber", 2); ent.SetDouble("ShapRadius", 1); ent.SetPoint("DimPoint", getSecondPt.value()); ent.SetPoint("First", frstPt); ent.TextStyle = "MyCommentFont"; ent.colorIndex = txtColorIndex; }