• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

gisoracle

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

ArcGIS Pro注记编辑

internal class ChangeSymbol : Button
  {
    protected async override void OnClick()
    {
      var annoLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<AnnotationLayer>().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<CIMSymbolLayer>();
            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 <SUP><UND>00</UND></SUP>";
            annoFeature.SetGraphic(textGraphic);
            annoFeature.Store();
            context.Invalidate(annoFeature);
          }, annoLayer.GetTable());

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

Related

    Text Annotation displaying problem
    Formatting in Add-in Description
    Dynamic text renderer
    How to access or set Text Symbol from Table Frame ...
    Number format in colorizer

Related Tags

    arcgis pro sdkarcgis procarcgisprosdkpro sdkarcgisprosdkarcgis pro sdk for .netarcgisarcgis pro sdk 2.5 

View All ≫

 

posted on 2022-05-13 21:09  gisai  阅读(229)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3