After drawing a polygon on my map. i am required to get a direction Polyline from the user. In ArcObjects, I was able to accomplish this like the following. This would give me a line that a user drew that represented a "direction"
IActiveView activeView <SPAN class="operator token">=</SPAN> pDocument<SPAN class="punctuation token">.</SPAN>ActiveView<SPAN class="punctuation token">;</SPAN>
IScreenDisplay screenDisplay <SPAN class="operator token">=</SPAN> activeView<SPAN class="punctuation token">.</SPAN>ScreenDisplay<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">string</SPAN> cursorLocation <SPAN class="operator token">=</SPAN> ProMapSettings<SPAN class="punctuation token">.</SPAN>AssemblyDirectory <SPAN class="operator token">+</SPAN> @ProMapSettings<SPAN class="punctuation token">.</SPAN>CursorFileLocation <SPAN class="operator token">+</SPAN> <SPAN class="string token">"RowDirection.cur"</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">bool</SPAN> cursorLocationExists <SPAN class="operator token">=</SPAN> File<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Exists</SPAN><SPAN class="punctuation token">(</SPAN>cursorLocation<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>cursorLocationExists<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
System<SPAN class="punctuation token">.</SPAN>Windows<SPAN class="punctuation token">.</SPAN>Forms<SPAN class="punctuation token">.</SPAN>Cursor newCursor <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">System<SPAN class="punctuation token">.</SPAN>Windows<SPAN class="punctuation token">.</SPAN>Forms<SPAN class="punctuation token">.</SPAN>Cursor</SPAN><SPAN class="punctuation token">(</SPAN>cursorLocation<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
System<SPAN class="punctuation token">.</SPAN>Windows<SPAN class="punctuation token">.</SPAN>Forms<SPAN class="punctuation token">.</SPAN>Cursor<SPAN class="punctuation token">.</SPAN>Current <SPAN class="operator token">=</SPAN> newCursor<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
screenDisplay<SPAN class="punctuation token">.</SPAN><SPAN class="token function">StartDrawing</SPAN><SPAN class="punctuation token">(</SPAN>screenDisplay<SPAN class="punctuation token">.</SPAN>hDC<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">(</SPAN>System<SPAN class="punctuation token">.</SPAN>Int16<SPAN class="punctuation token">)</SPAN>esriScreenCache<SPAN class="punctuation token">.</SPAN>esriNoScreenCache<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
IGeometry lineGeom <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">PolylineClass</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
IRubberBand rubberBand <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">RubberLineClass</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>rubberBand<SPAN class="punctuation token">.</SPAN><SPAN class="token function">TrackExisting</SPAN><SPAN class="punctuation token">(</SPAN>screenDisplay<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">,</SPAN> lineGeom<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
lineGeom <SPAN class="operator token">=</SPAN> rubberBand<SPAN class="punctuation token">.</SPAN><SPAN class="token function">TrackNew</SPAN><SPAN class="punctuation token">(</SPAN>screenDisplay<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> IPolyline<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
screenDisplay<SPAN class="punctuation token">.</SPAN><SPAN class="token function">FinishDrawing</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
polyline <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>IPolyline<SPAN class="punctuation token">)</SPAN>lineGeom<SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>In ArcGIS Pro, i understand how to create overlays and use map tools to create features, but can't quite figure out how to get a drawing from a user from within the code. If there was a way I could trigger a MapTool that would be great too, but can't quite figure out how to get that to work and wait for it in code. I want something like this.
<SPAN class="comment token">//I need something like this to work, and then get result back to use the geometry </SPAN>
AddOverlayTool adt <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">AddOverlayTool</SPAN><SPAN class="punctuation token">(</SPAN>RowLine<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
Polyline mPolyline <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">await</SPAN> adt<SPAN class="punctuation token">.</SPAN><SPAN class="token function">startSketch</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Then I use that line to get the angle and do more work </SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="operator token">!</SPAN>mPolyline<SPAN class="punctuation token">.</SPAN><SPAN class="token function">IsNullOrEmpty</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>