<?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: Example for &amp;quot;Set Start Location&amp;quot; button in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/example-for-quot-set-start-location-quot-button/m-p/802684#M2026</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Steve,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's one way of accomplishing this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Create a new MapTool.&amp;nbsp; &amp;nbsp;&amp;nbsp;In the constructor set the SketchType to be SketchGeometryType.Point.&amp;nbsp; &amp;nbsp;In the OnSketchCompleteAsync method add the following code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;protected override Task&amp;lt;bool&amp;gt; OnSketchCompleteAsync(Geometry geometry)&lt;BR /&gt; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if (geometry == null)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; return Task.FromResult(true);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;var geomType = geometry.GeometryType;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if (geomType != GeometryType.Point)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; return Task.FromResult(true);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;var point = geometry as ArcGIS.Core.Geometry.MapPoint;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;double x = point?.X ?? 0.0;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;double y = point?.Y ?? 0.0;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;double z = point?.Z ?? 0.0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;// throw an event with x, y, z&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;return Task.FromResult(true);&lt;BR /&gt; }&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Code a custom event which has the X, Y, Z values as part of the event arguments.&amp;nbsp; See the following sample&amp;nbsp;&lt;A class="link-titled" href="https://github.com/ArcGIS/arcgis-pro-sdk-community-samples/tree/master/Framework/CustomEvent" title="https://github.com/ArcGIS/arcgis-pro-sdk-community-samples/tree/master/Framework/CustomEvent"&gt;https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Framework/CustomEvent&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as a guide.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. In your tool, publish the event with the x, y, z values in the OnSketchCompleteAsync.&amp;nbsp; In your dockpane viewmodel subscribe to the event and use the x, y, z coordinates passed as appropriate.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4.&amp;nbsp;Set up the toggle button on the dockpane view to bind to&amp;nbsp;two properties on your viewmodel.&amp;nbsp; The buttons IsChecked property should bind to IsCoordinatesToolActive and the Command property should bind to GetCoordinatesCommand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5. Add the following code to the&amp;nbsp;dock pane view model.&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;protected GetCoordinatesDockPaneViewModel()&lt;BR /&gt; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;// set up the command&lt;BR /&gt;&amp;nbsp; &amp;nbsp;_getCoordinatesCommand = new RelayCommand(() =&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // replace with your daml id for the GetCoordinates tool&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; FrameworkApplication.SetCurrentToolAsync("Sample_GetCoordinates");&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // subscribe to the active tool event&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ActiveToolChangedEvent.Subscribe(OnActiveToolChanged);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;});&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// occurs when the active tool is changed&amp;nbsp;&lt;/P&gt;&lt;P&gt;private void OnActiveToolChanged(ToolEventArgs e)&lt;BR /&gt; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;// is it the getCoordinates tool?&amp;nbsp; &amp;nbsp; - replace with your daml id&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;bool bGetCoordsActive = e?.CurrentID == "Sample_GetCoordinates";&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if (!bGetCoordsActive)&lt;BR /&gt;&amp;nbsp; &amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // if not active, set the flag to false and unsubscribe to the event&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; IsCoordinatesToolActive = false;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ActiveToolChangedEvent.Unsubscribe(OnActiveToolChanged);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp; &amp;nbsp;else&lt;BR /&gt;&amp;nbsp; &amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // if active, set the flag to true and execute the command&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; IsCoordinatesToolActive = true;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; _getCoordinatesCommand.Execute(null);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// bind the buttons Command property to this in your view&lt;/P&gt;&lt;P&gt;private RelayCommand _getCoordinatesCommand;&lt;/P&gt;&lt;P&gt;public ICommand GetCoordinatesCommand =&amp;gt; _getCoordinatesCommand;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//&amp;nbsp; bind the buttons IsChecked property to this in your view&lt;/P&gt;&lt;P&gt;private bool _IsCoordinatesToolActive;&lt;BR /&gt; public bool IsCoordinatesToolActive&lt;BR /&gt; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp;get =&amp;gt; _IsCoordinatesToolActive;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;set&lt;BR /&gt;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (!value)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// if not checked, ensure that the default tool is set&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;FrameworkApplication.SetCurrentToolAsync("esri_mapping_exploreTool");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; SetProperty(ref _IsCoordinatesToolActive, value);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt; }&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Narelle&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 31 Jul 2018 17:10:48 GMT</pubDate>
    <dc:creator>NarelleChedzey</dc:creator>
    <dc:date>2018-07-31T17:10:48Z</dc:date>
    <item>
      <title>Example for "Set Start Location" button</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/example-for-quot-set-start-location-quot-button/m-p/802683#M2025</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all - I'm looking for a code example of using a button on a dock pane to return coordinates from a map.&amp;nbsp; I'm looking for the same basic functionality as the Traverse tool uses to get the starting point of a traverse using the tools "Set Start Location" button.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/416560_pastedImage_2.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2018 15:06:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/example-for-quot-set-start-location-quot-button/m-p/802683#M2025</guid>
      <dc:creator>SteveHolmes</dc:creator>
      <dc:date>2018-07-31T15:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: Example for "Set Start Location" button</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/example-for-quot-set-start-location-quot-button/m-p/802684#M2026</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Steve,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's one way of accomplishing this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Create a new MapTool.&amp;nbsp; &amp;nbsp;&amp;nbsp;In the constructor set the SketchType to be SketchGeometryType.Point.&amp;nbsp; &amp;nbsp;In the OnSketchCompleteAsync method add the following code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;protected override Task&amp;lt;bool&amp;gt; OnSketchCompleteAsync(Geometry geometry)&lt;BR /&gt; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if (geometry == null)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; return Task.FromResult(true);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;var geomType = geometry.GeometryType;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if (geomType != GeometryType.Point)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; return Task.FromResult(true);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;var point = geometry as ArcGIS.Core.Geometry.MapPoint;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;double x = point?.X ?? 0.0;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;double y = point?.Y ?? 0.0;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;double z = point?.Z ?? 0.0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;// throw an event with x, y, z&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;return Task.FromResult(true);&lt;BR /&gt; }&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Code a custom event which has the X, Y, Z values as part of the event arguments.&amp;nbsp; See the following sample&amp;nbsp;&lt;A class="link-titled" href="https://github.com/ArcGIS/arcgis-pro-sdk-community-samples/tree/master/Framework/CustomEvent" title="https://github.com/ArcGIS/arcgis-pro-sdk-community-samples/tree/master/Framework/CustomEvent"&gt;https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Framework/CustomEvent&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as a guide.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. In your tool, publish the event with the x, y, z values in the OnSketchCompleteAsync.&amp;nbsp; In your dockpane viewmodel subscribe to the event and use the x, y, z coordinates passed as appropriate.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4.&amp;nbsp;Set up the toggle button on the dockpane view to bind to&amp;nbsp;two properties on your viewmodel.&amp;nbsp; The buttons IsChecked property should bind to IsCoordinatesToolActive and the Command property should bind to GetCoordinatesCommand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5. Add the following code to the&amp;nbsp;dock pane view model.&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;protected GetCoordinatesDockPaneViewModel()&lt;BR /&gt; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;// set up the command&lt;BR /&gt;&amp;nbsp; &amp;nbsp;_getCoordinatesCommand = new RelayCommand(() =&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // replace with your daml id for the GetCoordinates tool&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; FrameworkApplication.SetCurrentToolAsync("Sample_GetCoordinates");&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // subscribe to the active tool event&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ActiveToolChangedEvent.Subscribe(OnActiveToolChanged);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;});&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// occurs when the active tool is changed&amp;nbsp;&lt;/P&gt;&lt;P&gt;private void OnActiveToolChanged(ToolEventArgs e)&lt;BR /&gt; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;// is it the getCoordinates tool?&amp;nbsp; &amp;nbsp; - replace with your daml id&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;bool bGetCoordsActive = e?.CurrentID == "Sample_GetCoordinates";&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if (!bGetCoordsActive)&lt;BR /&gt;&amp;nbsp; &amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // if not active, set the flag to false and unsubscribe to the event&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; IsCoordinatesToolActive = false;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ActiveToolChangedEvent.Unsubscribe(OnActiveToolChanged);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp; &amp;nbsp;else&lt;BR /&gt;&amp;nbsp; &amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // if active, set the flag to true and execute the command&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; IsCoordinatesToolActive = true;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; _getCoordinatesCommand.Execute(null);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// bind the buttons Command property to this in your view&lt;/P&gt;&lt;P&gt;private RelayCommand _getCoordinatesCommand;&lt;/P&gt;&lt;P&gt;public ICommand GetCoordinatesCommand =&amp;gt; _getCoordinatesCommand;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//&amp;nbsp; bind the buttons IsChecked property to this in your view&lt;/P&gt;&lt;P&gt;private bool _IsCoordinatesToolActive;&lt;BR /&gt; public bool IsCoordinatesToolActive&lt;BR /&gt; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp;get =&amp;gt; _IsCoordinatesToolActive;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;set&lt;BR /&gt;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (!value)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// if not checked, ensure that the default tool is set&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;FrameworkApplication.SetCurrentToolAsync("esri_mapping_exploreTool");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; SetProperty(ref _IsCoordinatesToolActive, value);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt; }&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Narelle&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2018 17:10:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/example-for-quot-set-start-location-quot-button/m-p/802684#M2026</guid>
      <dc:creator>NarelleChedzey</dc:creator>
      <dc:date>2018-07-31T17:10:48Z</dc:date>
    </item>
  </channel>
</rss>

