I want to add a progress bar in the Active Map that "spins" left-to-right
while a CreateLayer geoprocessing tool is loading the polygons.
There are 2K+ polygons and so it takes a bit of time to load. Once all are loaded,
I want the progress bar to disappear.
How do I do that with the following code:
private async void BtnRun_Click(object sender, RoutedEventArgs e)
{
sdePath = TboxPath.Text; //E:\WorkingFolder\SWATAddIn\MG_Connection.sde
in_features = TboxInFeature.Text; //MG.dbo.APEX_SWAT_COMP_HUC8
int lyrIndex = 0;
string lyrName = TboxLyrName.Text;
//Create and add a layer to the active map
string url = System.IO.Path.Combine(sdePath, in_features);
Uri uri = new Uri(url);
//Creat a Progress Bar user control
ProgressBar pBar = new ProgressBar();
//Create a MapViewOverlayControl.
var mapViewOverlayControl = new MapViewOverlayControl(pBar, true, true, true, OverlayControlRelativePosition.BottomCenter, .5, .8);
//Configure the progress bar
pBar.Minimum = 0;
pBar.Maximum = 100;
pBar.IsIndeterminate = true;
pBar.Width = 300;
pBar.Value = 10;
pBar.Height = 25;
pBar.Visibility = Visibility.Visible;
//Add to the active map
MapView.Active.AddOverlayControl(mapViewOverlayControl);
//Close this window
Close();
await QueuedTask.Run(() =>
{
Layer lyr = LayerFactory.Instance.CreateLayer(uri, MapView.Active.Map, lyrIndex, lyrName);
});
}
Right now, the progress bar just keeps spinning because I don't know where to call the pBar.Hide() in the above code, without it disappearing BEFORE all polygons are loaded.
Appreciate any help.