ArcGIS Pro SDK修改注记文本为下面特殊的

ArcGIS Pro SDK修改注记文本为下面特殊的

来自:https://community.esri.com/t5/arcgis-pro-sdk-questions/about-text-annotation-format/m-p/835389

internal class ChangeSymbol : Button
  {
    protected async override void OnClick()
    {
      var annoLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault();
      if (annoLayer == null)
        return;

      await QueuedTask.Run(() => {

        var select = annoLayer.GetSelection();
        if (select.GetObjectIDs().Count() > 0)
        {
          var oid = select.GetObjectIDs().First();
          QueryFilter qf = new QueryFilter()
          {
            WhereClause = $"OBJECTID = {oid}"
          };
          var rowCursor = annoLayer.GetTable().Search(qf, false);
          rowCursor.MoveNext();
          var annoFeature = rowCursor.Current as ArcGIS.Core.Data.Mapping.AnnotationFeature;
          var graphic = annoFeature.GetGraphic();
          var textGraphic = graphic as CIMTextGraphic;

          var op = new EditOperation();
          op.Name = "Change Anno";
          op.Callback((context) => {
            //make the callout for the circle
            var callOut = new CIMPointSymbolCallout();
            callOut.PointSymbol = new CIMPointSymbol();
            //Circle outline
            var circle_outline = SymbolFactory.Instance.ConstructMarker(40, "ESRI Default Marker") as CIMCharacterMarker;
            circle_outline.Size = 30;
            //eliminate the outline
            foreach (var layer in circle_outline.Symbol.SymbolLayers)
            {
              if (layer is CIMSolidStroke) {
                ((CIMSolidStroke) layer).Width = 0;
              }
            }

            //Circle fill
            var circle_fill = SymbolFactory.Instance.ConstructMarker(172, "ESRI Default Marker") as CIMCharacterMarker;
            circle_fill.Size = 30;
            //eliminate the outline, make sure the fill is white
            foreach (var layer in circle_fill.Symbol.SymbolLayers) {
              if (layer is CIMSolidFill) {
                ((CIMSolidFill)layer).Color = ColorFactory.Instance.WhiteRGB;
              }
              else if (layer is CIMSolidStroke)
              {
                ((CIMSolidStroke)layer).Width = 0;
              }
            }

            var calloutLayers = new List();
            calloutLayers.Add(circle_outline);
            calloutLayers.Add(circle_fill);
            //set the layers on the callout
            callOut.PointSymbol.SymbolLayers = calloutLayers.ToArray();

            //set the callout on the text symbol
            var textSym = textGraphic.Symbol.Symbol as CIMTextSymbol;
            textSym.Callout = callOut;
            textSym.Height = 8;//adjust as needed

            //now set the text
            textGraphic.Text = "12 00";
            annoFeature.SetGraphic(textGraphic);
            annoFeature.Store();
            context.Invalidate(annoFeature);
          }, annoLayer.GetTable());

          op.Execute();
        }
      });
    }
  }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Original: https://www.cnblogs.com/gisoracle/p/16277911.html
Author: gisoracle
Title: ArcGIS Pro SDK修改注记文本为下面特殊的

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/545596/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球