Maptool
I created a map-tool which splits a line. If the user has not selected anything and the tool is active, I want the tool to act as a selection tool and after the selection has been made, the tool should revert to a split line tool. This is what I have so far. The await ActivateSelectAsync does not return a value. I tried to set it to a result but I kept getting compile errors.
I thought about adding a timer before calling StartSketchAsync?
Do you have any ideas on how I might get this to work.
Thanks,
protected override async Task OnToolActivateAsync(bool hasMapViewChanged)
{
if (_attributeVM == null)
{
_attributeVM = this.EmbeddableControl as SplitParcelViewModel;
}
if (MapView.Active.Map.SelectionCount == 0)
{
IsSketchTool = false;
_attributeVM.Norecords = System.Windows.Visibility.Visible;
_attributeVM.typeofmessage = ArcGIS.Desktop.Internal.Framework.Controls.MessageType.Error;
_attributeVM.Changetext = "Nothing selected: Please select a segment to split";
await ActivateSelectAsync(true);
//need to wait for user to select something.
//MessageBox.Show("Please Select a line");
//This happens immediately. I need to ensure that the user has selected something before proceeding.
if (UseSelection == true)
{
IsSketchTool = true;
//MessageBox.Show("Something selected");
await StartSketchAsync();
//return Task.FromResult(true);
}
else
{
MessageBox.Show("Nothing selected");
//return Task.FromResult(false);
}
}
else
{
IsSketchTool = true;
_attributeVM.Norecords = System.Windows.Visibility.Collapsed;
//return Task.FromResult(true);
}
}