Help with layout

274
0
05-25-2023 05:27 AM
mstranovsky
New Contributor II

I am creating a textbox with a balloon callout inside on a layout.   My textbox anchor is the lr corner but it is placing the callout in the ur corner (see attached image).   How can i force the callout to the lr?  

Here is a snippet of my code:

// Add notify box
string notifyTxt = "NOTIFY: XXXX,\r\nXXXXX...";
Coordinate2D notifyCoord = new Coordinate2D(8.1, 1.2);
CIMTextSymbol arial10reg = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlackRGB, 10, "Arial", "Regular");
var balloonCallout = new CIMBalloonCallout();
balloonCallout.BalloonStyle = BalloonCalloutStyle.Rectangle;
var notifyPoly = SymbolFactory.Instance.ConstructPolygonSymbol(SymbolFactory.Instance.ConstructSolidFill(ColorFactory.Instance.CreateRGBColor(225, 225, 225, 100)), SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.CreateRGBColor(110, 110, 110, 100), 1));
balloonCallout.BackgroundSymbol = notifyPoly;
balloonCallout.Margin = new CIMTextMargin
{
Left = 6,
Right = 6,
Bottom = 6,
Top = 6
};
arial10reg.Callout = balloonCallout;
//GraphicElement notifyTxtElm = ElementFactory.Instance.CreateTextGraphicElement(layout_local, TextType.PointText, notifyCoord.ToMapPoint(), arial10reg, notifyTxt);
GraphicElement notifyTxtElm = ElementFactory.Instance.CreateTextGraphicElement(layout_local, TextType.RectangleParagraph, notifyCoord.ToMapPoint(), arial10reg, notifyTxt);
notifyTxtElm.SetName("Notify Text");
notifyTxtElm.SetAnchor(Anchor.BottomRightCorner);
notifyTxtElm.SetX(8.1);
notifyTxtElm.SetY(1.2);

string NotifyBox = "";
LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals(newMapName));
if (layoutItem != null)
{
Layout layout = layoutItem.GetLayout();
if (layout != null)
{
foreach (var item in notifyList)
{
if ((item.Substring(0, 7) == "NOTIFY:"))
{
NotifyBox = item;
}
else
{
NotifyBox = NotifyBox + Environment.NewLine + item;
}
}
ArcGIS.Desktop.Layouts.TextElement txtNotifyElm = layout.FindElement("Notify Text") as ArcGIS.Desktop.Layouts.TextElement;

Geometry geo1 = bLayer.QueryExtent();
Envelope env = geo1.Extent;
MapFrame mf = layout.Elements.FirstOrDefault(item => item.Name.Equals("New Map Frame")) as MapFrame;
mf.SetCamera(env);
if (NotifyBox.Length <= 😎
{
txtNotifyElm.SetVisible(false);
}
else
{
TextProperties txtNotifyProperties = new TextProperties(NotifyBox, "Arial", 9, "Bold");
txtNotifyElm.SetTextProperties(txtNotifyProperties);
txtNotifyElm.SetLockedAspectRatio(false);
txtNotifyElm.SetAnchor(Anchor.BottomRightCorner);
txtNotifyElm.SetX(8.10);
txtNotifyElm.SetY(1.20);
}
}
}

 

 

 

0 Kudos
0 Replies