<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Changing geometry of an element in graphics layer is extremely slow in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/changing-geometry-of-an-element-in-graphics-layer/m-p/1146774#M7826</link>
    <description>&lt;P&gt;I am trying to set up a tool to allow the user to click a graphic element in the graphics layer and move it around the map. Moving the graphic is extremely slow and I'm wondering if there is a better way to do what I'm trying to do.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;    internal class MoveGraphics : MapTool
    {
        private int? movingGraphic = null;
        private IReadOnlyList&amp;lt;GraphicElement&amp;gt; currentElements;

        public MoveGraphics()
        {
            IsSketchTool = false;
            SketchType = SketchGeometryType.Point;
            SketchOutputMode = SketchOutputMode.Map;
        }

        protected override Task OnToolActivateAsync(bool active)
        {
            return base.OnToolActivateAsync(active);
        }

        protected override void OnToolMouseUp(MapViewMouseButtonEventArgs e)
        {
            movingGraphic = null;
            base.OnToolMouseUp(e);
        }

        protected override void OnToolMouseDown(MapViewMouseButtonEventArgs e)
        {
            e.Handled = true;
        }

        protected override Task HandleMouseDownAsync(MapViewMouseButtonEventArgs e)
        {
            return QueuedTask.Run(() =&amp;gt;
            {
                var mp = MapView.Active.ClientToMap(e.ClientPoint);
                currentElements = Module1.Current.SelectedGraphicsLayerTOC.GetElementsAsFlattenedList();
                var coordinates = currentElements.Select(graphic =&amp;gt; graphic.GetAnchorPoint());
                var multiPoint = MultipointBuilder.CreateMultipoint(coordinates, Module1.Current.SelectedGraphicsLayerTOC.GetSpatialReference());
                var proximityResult = GeometryEngine.Instance.NearestVertex(multiPoint, mp);
                if (proximityResult.Distance &amp;lt; 0.0004)
                {
                    movingGraphic = proximityResult.PointIndex;
                }
            });
        }

        protected override void OnToolMouseMove(MapViewMouseEventArgs e)
        {
            if (!movingGraphic.HasValue) return;

            QueuedTask.Run(() =&amp;gt;
            {
                var element = currentElements[movingGraphic.Value];
                var mp = MapView.Active.ClientToMap(e.ClientPoint);
                var graphic = element.GetGraphic() as CIMPointGraphic;
                graphic.Location = mp;
                element.SetGraphic(graphic);
            });
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;When the user clicks on the map, I determine which point was closest to the click using the GeometryEngine's NearestVertex method. When the mouse is moved if a graphic is selected, I get the GraphicElement object, I get the MapPoint of the mouse, I set the Location property of the graphic to the new MapPoint, and update the graphic of the element using SetGraphic. I have also tried using the SetAnchorPoint method as well. Both of these methods have been very slow and take a few seconds to move the point to the new mouse position. Does anyone have a better/faster way of moving point graphics?&lt;/P&gt;</description>
    <pubDate>Tue, 22 Feb 2022 23:51:30 GMT</pubDate>
    <dc:creator>Kbperri</dc:creator>
    <dc:date>2022-02-22T23:51:30Z</dc:date>
    <item>
      <title>Changing geometry of an element in graphics layer is extremely slow</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/changing-geometry-of-an-element-in-graphics-layer/m-p/1146774#M7826</link>
      <description>&lt;P&gt;I am trying to set up a tool to allow the user to click a graphic element in the graphics layer and move it around the map. Moving the graphic is extremely slow and I'm wondering if there is a better way to do what I'm trying to do.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;    internal class MoveGraphics : MapTool
    {
        private int? movingGraphic = null;
        private IReadOnlyList&amp;lt;GraphicElement&amp;gt; currentElements;

        public MoveGraphics()
        {
            IsSketchTool = false;
            SketchType = SketchGeometryType.Point;
            SketchOutputMode = SketchOutputMode.Map;
        }

        protected override Task OnToolActivateAsync(bool active)
        {
            return base.OnToolActivateAsync(active);
        }

        protected override void OnToolMouseUp(MapViewMouseButtonEventArgs e)
        {
            movingGraphic = null;
            base.OnToolMouseUp(e);
        }

        protected override void OnToolMouseDown(MapViewMouseButtonEventArgs e)
        {
            e.Handled = true;
        }

        protected override Task HandleMouseDownAsync(MapViewMouseButtonEventArgs e)
        {
            return QueuedTask.Run(() =&amp;gt;
            {
                var mp = MapView.Active.ClientToMap(e.ClientPoint);
                currentElements = Module1.Current.SelectedGraphicsLayerTOC.GetElementsAsFlattenedList();
                var coordinates = currentElements.Select(graphic =&amp;gt; graphic.GetAnchorPoint());
                var multiPoint = MultipointBuilder.CreateMultipoint(coordinates, Module1.Current.SelectedGraphicsLayerTOC.GetSpatialReference());
                var proximityResult = GeometryEngine.Instance.NearestVertex(multiPoint, mp);
                if (proximityResult.Distance &amp;lt; 0.0004)
                {
                    movingGraphic = proximityResult.PointIndex;
                }
            });
        }

        protected override void OnToolMouseMove(MapViewMouseEventArgs e)
        {
            if (!movingGraphic.HasValue) return;

            QueuedTask.Run(() =&amp;gt;
            {
                var element = currentElements[movingGraphic.Value];
                var mp = MapView.Active.ClientToMap(e.ClientPoint);
                var graphic = element.GetGraphic() as CIMPointGraphic;
                graphic.Location = mp;
                element.SetGraphic(graphic);
            });
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;When the user clicks on the map, I determine which point was closest to the click using the GeometryEngine's NearestVertex method. When the mouse is moved if a graphic is selected, I get the GraphicElement object, I get the MapPoint of the mouse, I set the Location property of the graphic to the new MapPoint, and update the graphic of the element using SetGraphic. I have also tried using the SetAnchorPoint method as well. Both of these methods have been very slow and take a few seconds to move the point to the new mouse position. Does anyone have a better/faster way of moving point graphics?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Feb 2022 23:51:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/changing-geometry-of-an-element-in-graphics-layer/m-p/1146774#M7826</guid>
      <dc:creator>Kbperri</dc:creator>
      <dc:date>2022-02-22T23:51:30Z</dc:date>
    </item>
  </channel>
</rss>

