Hello, I've been using ArcGIS Pro 2.9.4, and using ArcGIS SDK to implement progress bar to show how long it will take until the process ends.
I want nothing under the progress bar, but status "finishing up..." always show up.
How could I get rid of it?
Assuming that you are using the CancelableProgressorSource:
You can try setting the following properties for the CancelableProgressorSource instance to change the Progress bar UI:
// Gets or sets the message of the progress dialog displayed while the associated
// Task is executing.
public string Message { get; set; }
// Gets or sets the status of the progress dialog displayed while the associated
// Task is executing.
public string Status { get; set; }
// Gets or sets the extended status of the progress dialog displayed while the associated
// Task is executing.
public string ExtendedStatus { get; set; }
// Gets or sets the progress bar position within the progress dialog displayed while
// the associated Task is executing.
public uint Value { get; set; }
// Gets or sets the progress bar maximum value within the dialog displayed while
// the associated Task is executing.
public uint Max { get; set; }
Unfortunately, this class is not listed in our API Reference, I am trying to get this fixed with the next release.
Below is a sample tool that i using the progress bar and changes its properties:
/// <summary>
/// This tool can be used to digitize a polygon on a map and once complete
/// the tool performs a series of buffer operations with expanding buffers
/// During the buffer creation process the Progress Dialog is displayed
/// </remarks>
internal class MultiBufferTool : MapTool
{
/// <summary>
/// Constructor of BufferGeometry tool
/// </summary>
public MultiBufferTool()
{
IsSketchTool = true;
SketchType = SketchGeometryType.Polygon;
SketchOutputMode = SketchOutputMode.Map;
}
/// <summary>
/// Constructs the value array to be passed as parameter to ExecuteToolAsync
/// Runs the Buffer tool of Analysis toolbox
/// </summary>
/// <param name="geometry"></param>
/// <returns>Geoprocessing result object as a Task</returns>
protected override async Task<bool> OnSketchCompleteAsync(Geometry geometry)
{
uint numBuffers = 7;
// create and initialize the progress dialog
// Note: Progress dialogs are not displayed when debugging in Visual Studio
var progDlg = new ProgressDialog($@"Creating {numBuffers} buffers", "Canceled", false);
var progsrc=new CancelableProgressorSource(progDlg);
for (uint iBuffer = 1; iBuffer <= numBuffers; iBuffer++)
{
var valueArray = await QueuedTask.Run<IReadOnlyList<string>>(() =>
{
var geometries = new List<object>() { geometry };
// Creates a 100-meter buffer around the geometry object
// null indicates a default output name is used
var valueArray = Geoprocessing.MakeValueArray(geometries, null, $@"{iBuffer*100} Meters");
return valueArray;
});
progsrc.ExtendedStatus = $@"Creating buffer #: {iBuffer} of {numBuffers}";
progsrc.Value = 100 * (iBuffer-1);
progsrc.Max = 100 * numBuffers + 1;
var gpResult = await Geoprocessing.ExecuteToolAsync("analysis.Buffer", valueArray, null, progsrc.Progressor);
if(gpResult.IsFailed)
{
// display error messages if the tool fails, otherwise shows the default messages
if (gpResult.Messages.Count() != 0)
{
Geoprocessing.ShowMessageBox(gpResult.Messages, progsrc.Message,
gpResult.IsFailed ?
GPMessageBoxStyle.Error : GPMessageBoxStyle.Default);
}
else
{
MessageBox.Show($@"{progsrc.Message} failed with errorcode, check parameters.");
}
break;
}
// check if the operator cancelled
if (progsrc.CancellationTokenSource.IsCancellationRequested) break;
}
if (progsrc.CancellationTokenSource.IsCancellationRequested)
{
MessageBox.Show("The operation was cancelled.");
}
return true;
}
}
The above sample code displays the progressbar like this: