public AnnotationProperties GetAnnotationProperties()
Public Function GetAnnotationProperties() As AnnotationProperties
Return Value
The annotation properties for the features currently loaded in the inspector.
public AnnotationProperties GetAnnotationProperties()
Public Function GetAnnotationProperties() As AnnotationProperties
Exception | Description |
---|---|
ArcGIS.Core.CalledOnWrongThreadException | This method or property must be called within the lambda passed to QueuedTask.Run. |
await QueuedTask.Run(() => { //annoLayer is ~your~ Annotation layer... // use the inspector methodology var insp = new Inspector(true); insp.Load(annoLayer, oid); // get the annotation properties AnnotationProperties annoProperties = insp.GetAnnotationProperties(); // set the attribute annoProperties.TextString = "Hello World"; // assign the annotation proeprties back to the inspector insp.SetAnnotationProperties(annoProperties); //create and execute the edit operation EditOperation op = new EditOperation(); op.Name = "Update annotation"; op.Modify(insp); op.Execute(); });
await QueuedTask.Run(() => { //Don't use 'Shape'....Shape is the bounding box of the annotation text. This is NOT what you want... // //var insp = new Inspector(); //insp.Load(annoLayer, oid); //var shape = insp["SHAPE"] as Polygon; //...wrong shape... //Instead, we must use the AnnotationProperties //annoLayer is ~your~ Annotation layer var insp = new Inspector(true); insp.Load(annoLayer, oid); AnnotationProperties annoProperties = insp.GetAnnotationProperties(); var shape = annoProperties.Shape; if (shape.GeometryType != GeometryType.GeometryBag) { var newGeometry = GeometryEngine.Instance.Move(shape, 10, 10); annoProperties.Shape = newGeometry; insp.SetAnnotationProperties(annoProperties); EditOperation op = new EditOperation(); op.Name = "Change annotation angle"; op.Modify(insp); op.Execute(); } });
await QueuedTask.Run(() => { var selection = annoLayer.GetSelection(); if (selection.GetCount() == 0) return; // use the first selelcted feature var insp = new Inspector(true); insp.Load(annoLayer, selection.GetObjectIDs().FirstOrDefault()); // getAnnoProperties should return null if not an annotation feature AnnotationProperties annoProperties = insp.GetAnnotationProperties(); // get the textGraphic CIMTextGraphic textGraphic = annoProperties.TextGraphic; // change text textGraphic.Text = "Hello world"; // set x,y offset via the symbol var symbol = textGraphic.Symbol.Symbol; var textSymbol = symbol as CIMTextSymbol; textSymbol.OffsetX = 2; textSymbol.OffsetY = 3; textSymbol.HorizontalAlignment = HorizontalAlignment.Center; // load the updated textGraphic annoProperties.LoadFromTextGraphic(textGraphic); // assign the annotation properties back insp.SetAnnotationProperties(annoProperties); EditOperation op = new EditOperation(); op.Name = "modify symbol"; op.Modify(insp); bool result = op.Execute(); });
Target Platforms: Windows 11, Windows 10, Windows 8.1