Creating an embeddable control implementing IEditingCreateToolControl in construction tool

2763
8
Jump to solution
01-07-2021 10:12 AM
JeffreySauder
New Contributor II

I am trying to write a construction tool that uses an embeddable control so I can control the attributes the users put in when the create the features (points).  I found a pretty informative Dev Summit session video "ArcGIS Pro SDK for .NET Advanced Editing with Focus on UI Customization", that has to do with pretty much what I need to do so I know it's possible.  There is a point in the session where the demo shows the EmbeddableControl implementing IEditingCreateToolControl, and there is also a region in the code for that.  To get that to work, the refID in the config.daml for the embeddablecontrol has to be "esri_editing_tool_options", which I set up, as well as everything else the demo showed to set up.  However, this is still not working for me, I'm thinking maybe a step was left out in the demo?  Or possibly something I set up was wrong, even though I've been through the demo multiple times, double and triple checked spelling, etc.  I've also tried to find samples on github (not much out there for this, the ConstructionTool Buffer Line project was about the only one that I could find.

Thank you in advance for any info that could help me get over this step...

Jeff

 

This is the declaration in the viewmodel:

namespace ProAddressApplication
{
internal class CreatePoints_UIViewModel : EmbeddableControl, IEditingCreateToolControl   (the IEditingCreateToolControl shows underlined in red)
{
public CreatePoints_UIViewModel(XElement options, bool canChangeOptions) : base(options, canChangeOptions) { }

The config.daml text is below:

<ArcGIS defaultAssembly="ProAddressApplication.dll" defaultNamespace="ProAddressApplication" xmlns="http://schemas.esri.com/DADF/Registry" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.esri.com/DADF/Registry file:///C:/Program%20Files/ArcGIS/Pro/bin/ArcGIS.Desktop.Framework.xsd">
<AddInInfo id="{0fdd9676-2c6b-455b-b17d-84afcd1d0981}" version="1.0" desktopVersion="2.7.26828">
<Name>ProAddressApplication</Name>
<Description>ProAddressApplication description</Description>
<Image>Images\AddinDesktop32.png</Image>
<Author>jeffs</Author>
<Company>Acme</Company>
<Date>1/7/2021 8:39:29 AM</Date>
<Subject>Framework</Subject>
<!-- Note subject can be one or more of these topics:
Content, Framework, Editing, Geodatabase, Geometry, Geoprocessing, Layouts, Map Authoring, Map Exploration -->
</AddInInfo>
<modules>
<insertModule id="ProAddressApplication_Module" className="Module1" autoLoad="false" caption="Module1">
<!-- uncomment to have the control hosted on a separate tab-->
<tabs>
<!--<tab id="ProAddressApplication_Tab1" caption="New Tab">
<group refID="ProAddressApplication_Group1"/>
</tab>-->
</tabs>
<groups>
<!-- comment this out if you have no controls on the Addin tab to avoid
an empty group-->
<group id="ProAddressApplication_Group1" caption="Group 1" appearsOnAddInTab="true">
<!-- host controls within groups -->
</group>
</groups>
<controls>
<!-- add your controls here -->
<tool id="ProAddressApplication_AddrApp_CreatePoints"
categoryRefID="esri_editing_construction_point"
caption="AddrApp _CreatePoints"
className="AddrApp_CreatePoints"
loadOnClick="true"
smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonRed16.png"
largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonRed32.png">
<!--note: use esri_editing_construction_polyline, esri_editing_construction_polygon for categoryRefID as needed-->
<tooltip heading="Tooltip Heading">Tooltip text<disabledText /></tooltip>
<content guid="93be836c-5a92-4930-8075-c3ecd893a6be" toolOptionsID="ProAddressApplication_CreatePoints_UI" />
</tool>
</controls>
</insertModule>
</modules>
<categories>
<updateCategory refID="esri_editing_tool_options">
<insertComponent id="ProAddressApplication_CreatePoints_UI" className="CreatePoints_UIViewModel">
<content className="CreatePoints_UIView" />
</insertComponent>
</updateCategory>
</categories>
</ArcGIS>

1 Solution

Accepted Solutions
NarelleChedzey
Esri Contributor

So now... as the compiler error says you will need to override the LoadFromToolOptions method.   This method is used to populate your option value from the internal tool Options structure. 

The BuffereredLineToolOptionsViewModel in the ConstructionToolWithOptions community sample has an example of this function. 

protected override Task LoadFromToolOptions()
{
double? buffer = GetToolOption<double?>(nameof(BufferOptionName), DefaultBuffer, null);
_buffer = buffer.Value;

return Task.CompletedTask;
}

 

View solution in original post

0 Kudos
8 Replies
NarelleChedzey
Esri Contributor

Hi Jeffrey, 

 

If you could answer the following questions that would help me in trying to work out the problem

First... I see from the config.daml desktopVersion attribute that you're using 2.7 with Pro and the Pro SDK.  Can you confirm this please. 

You said that the IEditingCreateToolControl has a red squiggle underline in visual studio.  What does the tooltip say if you hover over the squiggle. 

Also are you able to compile (choose a rebuild rather than just build)?  I wouldn't expect you to be able to compile if there is a red squiggle in the code,  so if you're able to run Pro with the add-in installed it might be running a version that is not up to date and in synch with your code. 

Thanks

Narelle

 

Thanks

Narelle

0 Kudos
JeffreySauder
New Contributor II

Hi Narelle,

I am using Pro 2.7 with the Pro SDK (visual studio 2019).

I remember working on this around a year or so ago, with the same results, probably on Pro 2.4 or 2.5.  I had other projects come up and had to put this one off for a bit.

I attached a screenshot, the text when I hover over the IEditingCreateToolControl is quite large.  You can also see the error list after the rebuild.

0 Kudos
NarelleChedzey
Esri Contributor

Jeffry, 

 

Change your class definition of your viewModel to the following

internal class CreatePoints_UIViewModel : ToolOptionsEmbeddableControl, IEditingCreateToolControl

 

The ToolOptionsEmbeddableControl inherits from EmbeddableControl but also implements the methods of IEditingCreateToolControl.  This should fix your problem. 

 

Looking back at the DevSummit presentation we mentioned adding an EmbeddableControl, but missed mentioning having to change to the ToolOptionsEmbeddableControl. 

 

let me know if you still have problems after making this change. 

 

Narelle

 

0 Kudos
JeffreySauder
New Contributor II

Hi Narelle,

Thanks for the reply.  I did that, i guess it's a little better but still has errors, shown in the screenshot.  I think I did try that before, the ConstructionToolWithOptions sample from github uses that also.

I also don't see the region for the tool, in the screenshot from the Demo in the video

0 Kudos
NarelleChedzey
Esri Contributor

So now... as the compiler error says you will need to override the LoadFromToolOptions method.   This method is used to populate your option value from the internal tool Options structure. 

The BuffereredLineToolOptionsViewModel in the ConstructionToolWithOptions community sample has an example of this function. 

protected override Task LoadFromToolOptions()
{
double? buffer = GetToolOption<double?>(nameof(BufferOptionName), DefaultBuffer, null);
_buffer = buffer.Value;

return Task.CompletedTask;
}

 

0 Kudos
JeffreySauder
New Contributor II

Thank you Narelle, that seems to have got me past that step.  I can now continue moving forward.  I appreciate your assistance very much!

0 Kudos
KirkKuykendall1
Occasional Contributor III
0 Kudos
JeffreySauder
New Contributor II

Kirk,

Thank you for that code, that will definitely help me in figuring all this out.

Much appreciated!

0 Kudos