<?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 Can I draw  different geometry types with a MapTool? in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/can-i-draw-different-geometry-types-with-a-maptool/m-p/1314465#M10128</link>
    <description>&lt;P&gt;I need to draw different geometry types, eg. point and polyline, depending on the state of the CTRL key. I created a MapTool and am overriding HandleKeyDownAsync/HandleKeyUpAsync but it appears the MapTool.SketchType property has no effect once the tool is activated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        public DrawFireTargetMapTool()
        {
            IsSketchTool = true;
            SketchOutputMode = SketchOutputMode.Map;
            SketchType = Module1.SelectedFireGeometryType;       
        }

        protected override Task HandleKeyUpAsync(MapViewKeyEventArgs args)
        {
            if (args.Key == System.Windows.Input.Key.LeftCtrl)
            {
                SketchType = Module1.SelectedFireGeometryType;
            }

            return base.HandleKeyUpAsync(args);
        }

        protected override Task HandleKeyDownAsync(MapViewKeyEventArgs args)
        {
            if (args.Key == System.Windows.Input.Key.LeftCtrl)
            {
                SketchType = Module1.SelectedTargetGeometryType;
            }

            return base.HandleKeyDownAsync(args);
        }&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 02 Aug 2023 08:43:56 GMT</pubDate>
    <dc:creator>ViktorSafar</dc:creator>
    <dc:date>2023-08-02T08:43:56Z</dc:date>
    <item>
      <title>Can I draw  different geometry types with a MapTool?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/can-i-draw-different-geometry-types-with-a-maptool/m-p/1314465#M10128</link>
      <description>&lt;P&gt;I need to draw different geometry types, eg. point and polyline, depending on the state of the CTRL key. I created a MapTool and am overriding HandleKeyDownAsync/HandleKeyUpAsync but it appears the MapTool.SketchType property has no effect once the tool is activated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        public DrawFireTargetMapTool()
        {
            IsSketchTool = true;
            SketchOutputMode = SketchOutputMode.Map;
            SketchType = Module1.SelectedFireGeometryType;       
        }

        protected override Task HandleKeyUpAsync(MapViewKeyEventArgs args)
        {
            if (args.Key == System.Windows.Input.Key.LeftCtrl)
            {
                SketchType = Module1.SelectedFireGeometryType;
            }

            return base.HandleKeyUpAsync(args);
        }

        protected override Task HandleKeyDownAsync(MapViewKeyEventArgs args)
        {
            if (args.Key == System.Windows.Input.Key.LeftCtrl)
            {
                SketchType = Module1.SelectedTargetGeometryType;
            }

            return base.HandleKeyDownAsync(args);
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 02 Aug 2023 08:43:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/can-i-draw-different-geometry-types-with-a-maptool/m-p/1314465#M10128</guid>
      <dc:creator>ViktorSafar</dc:creator>
      <dc:date>2023-08-02T08:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: Can I draw  different geometry types with a MapTool?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/can-i-draw-different-geometry-types-with-a-maptool/m-p/1314678#M10132</link>
      <description>&lt;P&gt;tools can only have one sketch type. consider implementing a tool palette. This is how the Pro selection tool is implemented. Read:&amp;nbsp;&lt;A href="https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-Palettes-and-Split-Buttons#how-to-declare-a-tool-palette" target="_blank"&gt;https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-Palettes-and-Split-Buttons#how-to-declare-a-tool-palette&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Pro selection tool declaration:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;!-- from ADmapping.daml --&amp;gt;

&amp;lt;toolPalette id="esri_mapping_selectToolPalette" itemsInRow="1" showItemCaption="true" caption="Select" extendedCaption="Open select tool palette" keytip="SE"&amp;gt;
          &amp;lt;tool refID="esri_mapping_selectByRectangleTool" /&amp;gt;
          &amp;lt;tool refID="esri_mapping_selectByPolygonTool" /&amp;gt;
          &amp;lt;tool refID="esri_mapping_selectByLassoTool" /&amp;gt;
          &amp;lt;tool refID="esri_mapping_selectByCircleTool" /&amp;gt;
          &amp;lt;tool refID="esri_mapping_selectByLineTool" /&amp;gt;
          &amp;lt;tool refID="esri_mapping_selectByTraceTool"/&amp;gt;
          &amp;lt;tool refID="esri_mapping_selectByBoxTool" /&amp;gt;
          &amp;lt;tool refID="esri_mapping_selectBySphereTool"/&amp;gt;
          &amp;lt;tool refID="esri_mapping_selectByCylinderTool"/&amp;gt;
        &amp;lt;/toolPalette&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 17:13:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/can-i-draw-different-geometry-types-with-a-maptool/m-p/1314678#M10132</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2023-08-02T17:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Can I draw  different geometry types with a MapTool?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/can-i-draw-different-geometry-types-with-a-maptool/m-p/1314925#M10134</link>
      <description>&lt;P&gt;Thanks for the reply, &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/145101"&gt;@CharlesMacleod&lt;/a&gt;. The tool activation is done from custom code, not from Pro&amp;nbsp; buttons.&lt;/P&gt;&lt;P&gt;I have changed approach and am now attempting to activate 2 separate tools from each other's HandleKeyDownAsync methods (aka DrawFireMapTool activates DrawTargetMapTool and vice versa).&lt;/P&gt;&lt;P&gt;I have put breakpoints into&amp;nbsp;OnToolDeactivateAsync and see that it is not being called on the 1st tool when the 1st tool activates the 2nd tool. So I am assuming this approach won't work either?&lt;/P&gt;&lt;P&gt;How does the palette switch tools? Can I deactivate a tool from within itself?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// DrawFireMapTool.cs
        protected override async Task HandleKeyDownAsync(MapViewKeyEventArgs args)
        {
            if (args.Key == System.Windows.Input.Key.LeftCtrl)
            {
                // activate Target tool
                await FrameworkApplication.SetCurrentToolAsync(DrawTargetMapTool.DamlId);
            }
            else
            {
                await base.HandleKeyDownAsync(args);
            }
        }



// DrawTargetMapTool.cs
        protected override async Task HandleKeyUpAsync(MapViewKeyEventArgs args)
        {
            if (args.Key == System.Windows.Input.Key.LeftCtrl)
            {
                // activate Fire tool             
                await FrameworkApplication.SetCurrentToolAsync(DrawFireMapTool.DamlId);
            }
            else
            {
                await base.HandleKeyUpAsync(args);
            }   
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 06:58:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/can-i-draw-different-geometry-types-with-a-maptool/m-p/1314925#M10134</guid>
      <dc:creator>ViktorSafar</dc:creator>
      <dc:date>2023-08-03T06:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: Can I draw  different geometry types with a MapTool?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/can-i-draw-different-geometry-types-with-a-maptool/m-p/1315921#M10152</link>
      <description>&lt;P&gt;Go back to your first approach and try calling base.StartSketchAsync() after you've changed the SketchType.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;Internally the sketch is started on tool activation with the current SketchType.&amp;nbsp; If you change the SketchType after this moment, you need to tell the tool to re-initialize the sketch.&amp;nbsp; &amp;nbsp;This is accomplished by the StartSketchAsync method.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Narelle&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2023 06:57:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/can-i-draw-different-geometry-types-with-a-maptool/m-p/1315921#M10152</guid>
      <dc:creator>NarelleChedzey</dc:creator>
      <dc:date>2023-08-07T06:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: Can I draw  different geometry types with a MapTool?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/can-i-draw-different-geometry-types-with-a-maptool/m-p/1321028#M10223</link>
      <description>&lt;P&gt;It actually works out of the box!&amp;nbsp;I am not sure what I did wrong in the beginning, but changing the&amp;nbsp;SketchType after the tool has been activated indeed has an effect on the geometry being drawn.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public DrawFireTargetMapTool()
{
	IsSketchTool = true;
	SketchType = SketchGeometryType.Rectangle;
	SketchOutputMode = SketchOutputMode.Map;
}

protected override Task OnToolActivateAsync(bool active)
{
	SketchType = &amp;lt;some other SketchType&amp;gt;;
	return Task.CompletedTask;
}

/// &amp;lt;summary&amp;gt;
/// This is used only to trigger OnToolKeyUp
/// &amp;lt;/summary&amp;gt;        
protected override Task HandleKeyUpAsync(MapViewKeyEventArgs args)
{
	args.Handled = true;
	return base.HandleKeyUpAsync(args);
}

protected override void OnToolKeyUp(MapViewKeyEventArgs args)
{
	if (_handledKeys.Contains(args.Key))
	{
		SketchType = &amp;lt;yet another SketchType&amp;gt;;
	}
	else
	{
		base.OnToolKeyUp(args);
	}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 08:32:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/can-i-draw-different-geometry-types-with-a-maptool/m-p/1321028#M10223</guid>
      <dc:creator>ViktorSafar</dc:creator>
      <dc:date>2023-08-22T08:32:38Z</dc:date>
    </item>
  </channel>
</rss>

