// Merging - initial busy indicator state public static void EnableForMerging(this BusyCancelIndicator busyCancelIndicator, bool isBusy) { busyCancelIndicator.IsBusy = isBusy; busyCancelIndicator.Message = isBusy ? "Merging databases. Please wait..." : "Please wait..."; busyCancelIndicator.CancelButtonIsEnabled = false; busyCancelIndicator.CancelButtonText = isBusy ? "Merging databases..." : "Cancel"; }
//Set the busy indicator and set it to various intial states depending upon what it is being invoked for. // If its busy, it sets it to the various specific messages. // If its not busy, it sets it to some neutral messages // Note: I'm not really sure if setting the messages are even necessary, as that is usually overwritten in the progress handler // File selection - initial busy indicator state public static void EnableForSelection(this BusyCancelIndicator busyCancelIndicator, bool isBusy) { busyCancelIndicator.IsBusy = isBusy; busyCancelIndicator.Message = isBusy ? "Selecting Files from the database. Please wait..." : "Please wait..."; busyCancelIndicator.CancelButtonIsEnabled = false; busyCancelIndicator.CancelButtonText = isBusy ? "Querying the database" : "Cancel"; }
static private void UpdateProgressBar(BusyCancelIndicator busyCancelIndicator, int percent, string message, bool isCancelEnabled, bool isIndeterminate) { Application.Current.Dispatcher.Invoke(() => { // Code to run on the GUI thread. // Check the arguments for null ThrowIf.IsNullArgument(busyCancelIndicator, nameof(busyCancelIndicator)); // Set it as a progressive or indeterminate bar busyCancelIndicator.IsIndeterminate = isIndeterminate; // Set the progress bar position (only visible if determinate) busyCancelIndicator.Percent = percent; // Update the text message busyCancelIndicator.Message = message; // Update the cancel button to reflect the cancelEnabled argument busyCancelIndicator.CancelButtonIsEnabled = isCancelEnabled; busyCancelIndicator.CancelButtonText = isCancelEnabled ? "Cancel" : "Processing CSV file..."; }); }
private void UpdateFolderLoadProgress(BusyCancelIndicator BusyCancelIndicator, BitmapSource bitmap, int percent, string message, bool isCancelEnabled, bool isIndeterminate) { if (bitmap != null) { this.MarkableCanvas.SetNewImage(bitmap, null); } // Check the arguments for null ThrowIf.IsNullArgument(BusyCancelIndicator, nameof(BusyCancelIndicator)); // Set it as a progressive or indeterminate bar BusyCancelIndicator.IsIndeterminate = isIndeterminate; // Set the progress bar position (only visible if determinate) BusyCancelIndicator.Percent = percent; // Update the text message BusyCancelIndicator.Message = message; // Update the cancel button to reflect the cancelEnabled argument BusyCancelIndicator.CancelButtonIsEnabled = isCancelEnabled; BusyCancelIndicator.CancelButtonText = isCancelEnabled ? "Cancel" : "Writing data..."; }
/// <summary> /// Update the progress bar in the BusyCancelIndicator. /// </summary> /// <param name="busyCancelIndicator"></param> /// <param name="percent">A number between 0-100 that reflects the percentage done (ignored if isIndeterminate is true)</param> /// <param name="message">The message to show in the progress bar</param> /// <param name="cancelMessage">the message to show in the cancel button</param> /// <param name="isCancelEnabled">whether the Cancel button should be enabled</param> /// <param name="isIndeterminate">whether the displayed bar is indeterminatne (just going back and forth) or showing the actual %progress</param> static private void UpdateProgressBar(BusyCancelIndicator busyCancelIndicator, int percent, string message, string cancelMessage, bool isCancelEnabled, bool isIndeterminate) { Application.Current.Dispatcher.Invoke(() => { // Code to run on the GUI thread. // Check the arguments for null ThrowIf.IsNullArgument(busyCancelIndicator, nameof(busyCancelIndicator)); // Set it as a progressive or indeterminate bar busyCancelIndicator.IsIndeterminate = isIndeterminate; // Set the progress bar position (only visible if indeterminate is false, otherwise it doesn't have any effect) busyCancelIndicator.Percent = percent; // Update the primary text message in the busyCancelIndicator busyCancelIndicator.Message = message; // Enable/disable the cancel button text // If cancel is enabled, set the button's text to 'Cancel' otherwise set its text to the cancelMessage (e.g., to give more information about this operation) busyCancelIndicator.CancelButtonIsEnabled = isCancelEnabled; busyCancelIndicator.CancelButtonText = isCancelEnabled ? "Cancel" : cancelMessage; }); }