Selecting the Geometry in CreationMode/EditMode for easily moving it.

302
4
08-11-2017 10:52 AM
Highlighted
New Contributor III

When I am in Creation Mode or Edit Mode in SketchEditor.StartAsync, I have to click the geometry to select it first, and then move it. Is it possilble to be able to move the geometry when in Creation/Edit mode without having to do that extra click? Tried to put isSelected as true but doesn't really work for moving the geometry. 

SketchEditor.EditConfiguration has AllowMove property but it is just bool.

Thanks!

4 Replies
Highlighted
New Contributor

Hi!

I have a similar problem. I want to move vertices of a geometry without extra selection. 

I found the property RequireSelectionBeforeDrag in the SketchEditor.EditConfiguration , but it makes no difference if set to true or false. I always have to preselect the vertices I want to move. In Runtime 10.2.7 it worked! 

On the other hand I want to disable moving the whole geometry and set the property AllowMove to false. However, I still can move my geometry! 

I am using Runtime Quartz 100.3

Thanks

Reply
0 Kudos
Highlighted
Frequent Contributor

RequireSelectionBeforeDrag=False should allow you to drag the geometry or vertices provided move gesture hit the geometry outline or vertex.

Perhaps the difference is that in v10.x, geometry can be moved even if you hit the fill/center of polygon feature. We already have an open design issue to reconsider this behavior.

Reply
0 Kudos
Highlighted
New Contributor

RequireSelectionBeforeDrag=False or AllowMove = false don't effect anything, if set in the EditConfiguration of the SketchEditor.

No matter if I hit the fill/Center or the outline. 

However, after A LOT OF tests, if found a workaround: If you use the overload of the SketchEditor.StartAsync(...) , and pass an EditConfiguration extra, it works.  You even can take just the previously modified Editor -  EditConfiguration.

If I am completely wrong, please provide a full best practice sample of how to use the EditConfiguration with customized properties correctly.
For me, this is a bug.

// my "pseudocode" test method

 private static async void TestEditor(
            MapView mapView , Geometry editGeometry)
        {

            mapView.SketchEditor.EditConfiguration.AllowMove = false;

            mapView.SketchEditor.EditConfiguration.RequireSelectionBeforeDrag = false;
 // IN CASE OF CREATE
            //   THIS DOES NOT WORK
            Geometry res =  await mapView.SketchEditor.StartAsync(SketchCreationMode.Polygon,false);
            // OR
            Geometry res1 = await mapView.SketchEditor.StartAsync(SketchCreationMode.Polygon,true);
            //THIS WORKS  if used in the overload:
           SketchEditConfiguration sec = mapView.SketchEditor.EditConfiguration;
            var res2 = await mapView.SketchEditor.StartAsync( SketchCreationMode.Polygon,sec );
// IN CASE OF EDIT
            // THIS DOES NOT WORK
            var res4 = await mapView.SketchEditor.StartAsync( editGeometry );
            //  THIS WORKS with extra definition of the CreationMode and SketchEditConfiguration in the overload !
            SketchCreationMode scm = Editor.CreationMode;
            var res3 = await mapView.SketchEditor.StartAsync( editGeometry,
                                                scm,
                                                sec );
}
Reply
0 Kudos
Highlighted
Frequent Contributor

Hi Karin,

Thank you for this clarification. It's actually by design that EditConfiguration properties are determined at run-time based on SketchCreationMode parameter. For example, SketchCreationMode.Polygon will enable AllowVertexEditing whereas SketchCreationMode.Point or SketchCreationMode.FreehandPolygon will disable this. 

You can still overwrite these properties in XAML through binding, or

<CheckBox IsChecked="{Binding ElementName=MyMapView, Path=SketchEditor.EditConfiguration.RequireSelectionBeforeDrag, Mode=TwoWay}"
          Content="RequireSelectionBeforeDrag"/>

in code, after StartAsync

var drawTask = MyMapView.SketchEditor.StartAsync(SketchCreationMode.Polygon);
MyMapView.SketchEditor.EditConfiguration.RequireSelectionBeforeDrag = false;
var geometry = await drawTask;

However if EditConfiguration is also passed as parameter to StartAsync, we honor the properties set as much as the geometry type or creation mode would allow.

You brought up a fair point though that there are EditConfiguration properties like RequireSelectionByDrag that don't necessarily depend on the geometry type or creation mode which we probably should not overwrite. I have logged an issue to address this.

Thank you both for your feedback.