<?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 Re: Move feature by the mouse in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/move-feature-by-the-mouse/m-p/1186582#M8299</link>
    <description>&lt;P&gt;Hi David,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd recommend taking a look at this section of the map exploration ProConcepts with regards to handling mouse down in a MapTool&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/ArcGIS/arcgis-pro-sdk/wiki/ProConcepts-Map-Exploration#mouse-and-keyboard-events" target="_blank"&gt;https://github.com/ArcGIS/arcgis-pro-sdk/wiki/ProConcepts-Map-Exploration#mouse-and-keyboard-events&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and this sample which offers as example (In particular look at the way the BasicMapTool uses the OnToolMouseDown and HandleMouseDownAsync methods)&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/6078006a3943364f2a7931b19d1eb03c8a99e1cf/Map-Exploration/BasicMapTool" target="_blank"&gt;https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/6078006a3943364f2a7931b19d1eb03c8a99e1cf/Map-Exploration/BasicMapTool&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are similar options for MouseUp and MouseMove on the MapTool.&amp;nbsp; &amp;nbsp;You could incorporate these methods into your solution.&amp;nbsp;&lt;/P&gt;&lt;P&gt;One option would be to note when a left mouse down occurs&amp;nbsp; (ie set a variable - mouseDown = true), trap the mouse move (and perform some action when mousedown == true), and finally note when the mouse up occurs (and clear the mouseDown variable).&amp;nbsp; &amp;nbsp;You could execute the editOperation in the MouseUp if enough distance has been travelled by the mouse.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this gives you some ideas.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Narelle&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jun 2022 04:05:39 GMT</pubDate>
    <dc:creator>NarelleChedzey</dc:creator>
    <dc:date>2022-06-27T04:05:39Z</dc:date>
    <item>
      <title>Move feature by the mouse</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/move-feature-by-the-mouse/m-p/1185885#M8290</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;is there any way to move the selected feature by dragging the mouse? I know this is normal editing in ArcGIS Pro, but I also want to incorporate an element selection that I already have set up.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; internal class PresunAnotaciPodelRamu : MapTool
    {
        public PresunAnotaciPodelRamu()
        {
            IsSketchTool = true;
            SketchType = SketchGeometryType.Point;
            SketchOutputMode = SketchOutputMode.Map;
        }

        protected override Task&amp;lt;bool&amp;gt; OnSketchCompleteAsync(Geometry geometry)
        {
            return QueuedTask.Run(() =&amp;gt; Selection(geometry));
        }

        protected async Task&amp;lt;bool&amp;gt; Selection(Geometry geometry)
        {
            await QueuedTask.Run(() =&amp;gt;
            {
                MapView mapView = MapView.Active;
                const string bodyAnno = "BodyAnno";
                const string body = "Body";
                const string ramyPresahu25 = "ramyPresahu_25";
                var insp = new Inspector();
                AnnotationLayer alBodyAnno = mapView.Map.FindLayers(bodyAnno).FirstOrDefault() as AnnotationLayer;
                FeatureLayer flBody = mapView.Map.FindLayers(body).FirstOrDefault() as FeatureLayer;
                FeatureLayer flRamyPresahu25 = mapView.Map.FindLayers(ramyPresahu25).FirstOrDefault() as FeatureLayer;
                List&amp;lt;FeatureLayer&amp;gt; seznamVrstev = new List&amp;lt;FeatureLayer&amp;gt;()
                    {flBody, flRamyPresahu25};
                if (alBodyAnno == null)
                {
                    MessageBox.Show(@"Neexistuje.");
                    return;
                }

                foreach (var vrstva in seznamVrstev)
                {
                    if (vrstva == null)
                    {
                        MessageBox.Show(@"Neexistuje.");
                        return;
                    }
                }

                var editace = new EditOperation
                {
                    Name = "Posun anotace",
                    SelectNewFeatures = false
                };
                var features = mapView.GetFeatures(geometry);
                if (features.ContainsKey(alBodyAnno))
                {
                    var thisTag = features.FirstOrDefault(t =&amp;gt; t.Key == alBodyAnno);
                    var oidSeznam = thisTag.Value;
                    long oid = 0;
                    string strana = null;
                    foreach (var longOid in oidSeznam)
                    {
                        oid = longOid;
                    }
                    var filter = new QueryFilter
                    {
                        WhereClause = " OBJECTID = " + oid
                    };
                    var anotaceHledana = alBodyAnno.Search(filter);
                    while (anotaceHledana.MoveNext())
                    {
                        var aktual = anotaceHledana.Current;
                        strana = aktual["STRANA"].ToString();
                    }
                    var anotaceZvolena = alBodyAnno.Select(filter);
                    insp.Load(alBodyAnno, oid);
                    AnnotationProperties annoProperties = insp.GetAnnotationProperties();
                    var shape = annoProperties.Shape;
                    var envelope = shape.Extent;
                    var mapPointCentroid = GeometryEngine.Instance.Centroid(envelope);
                    double souradniceStrduX = mapPointCentroid.X;
                    double souradniceStreduY = mapPointCentroid.Y;
                    if (strana == "horni" || strana == "dolni")
                    {
                        if (shape.GeometryType != GeometryType.GeometryBag)
                        {
                            HandleMouseUp(e);
                            var dictionary = GetMousePositionWindowsForms();
                            var souradniceY = dictionary.FirstOrDefault(x =&amp;gt; x.Key == "Y").Value;
                            var posun = GeometryEngine.Instance.Move(shape, souradniceStrduX, souradniceY);
                            annoProperties.Shape = posun;
                        }
                    }
                    else
                    {
                        if (shape.GeometryType != GeometryType.GeometryBag)
                        { 
                            HandleMouseUp(e);
                            var dictionary = GetMousePositionWindowsForms();
                            var souradniceX = dictionary.FirstOrDefault(x =&amp;gt; x.Key == "X").Value;
                            var posun = GeometryEngine.Instance.Move(shape, souradniceX, souradniceStreduY);
                            annoProperties.Shape = posun;
                        }
                    }
                    insp.SetAnnotationProperties(annoProperties);
                    editace.Modify(insp);
                }
                else
                {
                    MessageBox.Show("Nebyla zvolena anotace!");
                    return;
                }
                MouseButtonEventArgs e;//I don't know how to set it up
                OnMouseDoubleClick(editace, e);
            });
            return true;
        }
        void OnMouseDoubleClick(EditOperation editace, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                editace.Execute();
            }
        }
        void HandleMouseUp(MapViewMouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                GetMousePositionWindowsForms();
            }
        }
        public static Dictionary&amp;lt;string,double&amp;gt; GetMousePositionWindowsForms()
        {
            Dictionary&amp;lt;string,double&amp;gt; list = new Dictionary&amp;lt;string, double&amp;gt;();
            var point = Control.MousePosition;
            list.Add("X",point.X);
            list.Add("Y",point.Y);
            return list;
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;Finally, I would like to end the method by double-clicking the mouse. Is it possible to do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 11:53:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/move-feature-by-the-mouse/m-p/1185885#M8290</guid>
      <dc:creator>DavidMrázek</dc:creator>
      <dc:date>2022-06-24T11:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: Move feature by the mouse</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/move-feature-by-the-mouse/m-p/1186582#M8299</link>
      <description>&lt;P&gt;Hi David,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd recommend taking a look at this section of the map exploration ProConcepts with regards to handling mouse down in a MapTool&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/ArcGIS/arcgis-pro-sdk/wiki/ProConcepts-Map-Exploration#mouse-and-keyboard-events" target="_blank"&gt;https://github.com/ArcGIS/arcgis-pro-sdk/wiki/ProConcepts-Map-Exploration#mouse-and-keyboard-events&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and this sample which offers as example (In particular look at the way the BasicMapTool uses the OnToolMouseDown and HandleMouseDownAsync methods)&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/6078006a3943364f2a7931b19d1eb03c8a99e1cf/Map-Exploration/BasicMapTool" target="_blank"&gt;https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/6078006a3943364f2a7931b19d1eb03c8a99e1cf/Map-Exploration/BasicMapTool&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are similar options for MouseUp and MouseMove on the MapTool.&amp;nbsp; &amp;nbsp;You could incorporate these methods into your solution.&amp;nbsp;&lt;/P&gt;&lt;P&gt;One option would be to note when a left mouse down occurs&amp;nbsp; (ie set a variable - mouseDown = true), trap the mouse move (and perform some action when mousedown == true), and finally note when the mouse up occurs (and clear the mouseDown variable).&amp;nbsp; &amp;nbsp;You could execute the editOperation in the MouseUp if enough distance has been travelled by the mouse.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this gives you some ideas.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Narelle&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 04:05:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/move-feature-by-the-mouse/m-p/1186582#M8299</guid>
      <dc:creator>NarelleChedzey</dc:creator>
      <dc:date>2022-06-27T04:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Move feature by the mouse</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/move-feature-by-the-mouse/m-p/1186611#M8301</link>
      <description>&lt;P&gt;Thank you very much, this will definitely help me to make some progress. Thanks again.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 06:48:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/move-feature-by-the-mouse/m-p/1186611#M8301</guid>
      <dc:creator>DavidMrázek</dc:creator>
      <dc:date>2022-06-27T06:48:33Z</dc:date>
    </item>
  </channel>
</rss>

