Can I create a custom move tool?

351
1
09-13-2019 09:51 AM
AnandhaSudhan
New Contributor II

Can I create a custom Move Tool similar to ArcGIS Pro's Move Tool but only selects a particular feature layer (point) and moves it within a range on a polyline?

Tags (3)
0 Kudos
1 Reply
GKmieliauskas
Esri Regular Contributor

Hi Anandha,

To select features from particular layer set Tool property UseSnapping to true. Then switch off snapping on all map layers except layer you need. In sample all snappable layers are separated by ";" in the input string.

public static async Task ConfigureSnappingAsync(string sLayerNames)

{

// General Snapping

Snapping.IsEnabled = true;

Snapping.SetSnapMode(SnapMode.Point, true);

// Snapping on any point Feature Layers

var flayers = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().ToList();

if (flayers.Count() > 0)

{

//GetDefinition and SetDefinition must be called inside QueuedTask

await QueuedTask.Run(() => {

string sNames = string.Empty;

if (!string.IsNullOrEmpty(sLayerNames))

{

sNames = sLayerNames.ToUpper();

}

foreach (var fl in flayers)

{

var layerDef = fl.GetDefinition() as CIMGeoFeatureLayerBase;

if (string.IsNullOrEmpty(sNames))

{

if (!layerDef.Snappable)

{

layerDef.Snappable = true;

fl.SetDefinition(layerDef);

}

}

else

{

string searchName = fl.Name.ToUpper() + ";";

layerDef.Snappable = sNames.Contains(searchName);

fl.SetDefinition(layerDef);

}

}

});

}

}

The next step is more complicated. There are two ways:

1. Control mouse cursor (set direction you want)

2. Change cursor icon on mouse move then user selects wrong direction and do not accept wrong position on mouse down.

0 Kudos