Changed license to Apache License 2.0
This commit is contained in:
parent
857917aad5
commit
0037b7de46
47 changed files with 5942 additions and 5849 deletions
|
@ -1,114 +1,113 @@
|
|||
#region CPL License
|
||||
/*
|
||||
Nuclex Framework
|
||||
Copyright (C) 2002-2019 Nuclex Development Labs
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
published by the IBM Corporation; either version 1.0 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
IBM Common Public License for more details.
|
||||
|
||||
You should have received a copy of the IBM Common Public
|
||||
License along with this library
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Nuclex.Support.Tracking;
|
||||
|
||||
namespace Nuclex.Windows.Forms {
|
||||
|
||||
/// <summary>Tracking bar that can be hosted in a tool strip container</summary>
|
||||
public class ToolStripTrackingBar : ToolStripControlHost {
|
||||
|
||||
/// <summary>Initializes a new tool strip tracking bar</summary>
|
||||
public ToolStripTrackingBar() : base(createTrackingBar()) {
|
||||
hideControlAtRuntime();
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new tool strip tracking bar with a name</summary>
|
||||
/// <param name="name">Name of the tracking bar control</param>
|
||||
public ToolStripTrackingBar(string name) : base(createTrackingBar(), name) {
|
||||
hideControlAtRuntime();
|
||||
}
|
||||
|
||||
/// <summary>The tracking bar control being hosted by the tool strip host</summary>
|
||||
public TrackingBar TrackingBarControl {
|
||||
get { return base.Control as TrackingBar; }
|
||||
}
|
||||
|
||||
/// <summary>Tracks the specified transaction in the tracking bar</summary>
|
||||
/// <param name="transaction">Transaction to be tracked</param>
|
||||
public void Track(Transaction transaction) {
|
||||
TrackingBarControl.Track(transaction);
|
||||
}
|
||||
|
||||
/// <summary>Tracks the specified transaction in the tracking bar</summary>
|
||||
/// <param name="transaction">Transaction to be tracked</param>
|
||||
/// <param name="weight">Weight of this transaction in the total progress</param>
|
||||
public void Track(Transaction transaction, float weight) {
|
||||
TrackingBarControl.Track(transaction, weight);
|
||||
}
|
||||
|
||||
/// <summary>Stops tracking the specified transaction</summary>
|
||||
/// <param name="transaction">Transaction to stop tracking</param>
|
||||
public void Untrack(Transaction transaction) {
|
||||
TrackingBarControl.Untrack(transaction);
|
||||
}
|
||||
|
||||
/// <summary>Default size of the hosted control</summary>
|
||||
protected override Size DefaultSize {
|
||||
get { return new Size(100, 15); }
|
||||
}
|
||||
|
||||
/// <summary>Default margin to leave around the control in the tool strip</summary>
|
||||
protected override Padding DefaultMargin {
|
||||
get {
|
||||
if((base.Owner != null) && (base.Owner is StatusStrip)) {
|
||||
return new Padding(1, 3, 1, 3);
|
||||
}
|
||||
|
||||
return new Padding(1, 2, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Creates a new tracking bar</summary>
|
||||
/// <returns>A new tracking bar</returns>
|
||||
private static TrackingBar createTrackingBar() {
|
||||
TrackingBar trackingBar = new TrackingBar();
|
||||
trackingBar.Size = new Size(100, 15);
|
||||
return trackingBar;
|
||||
}
|
||||
|
||||
/// <summary>Hides the control during runtime usage</summary>
|
||||
private void hideControlAtRuntime() {
|
||||
TrackingBarControl.VisibleChanged += new EventHandler(trackingBarVisibleChanged);
|
||||
|
||||
LicenseUsageMode usageMode = System.ComponentModel.LicenseManager.UsageMode;
|
||||
if(usageMode == LicenseUsageMode.Runtime) {
|
||||
base.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toggles the visibility of the tool strip host when the tracking bar control's
|
||||
/// visibility changes.
|
||||
/// </summary>
|
||||
/// <param name="sender">Tracking bar control whose visiblity has changed</param>
|
||||
/// <param name="arguments">Not used</param>
|
||||
private void trackingBarVisibleChanged(object sender, EventArgs arguments) {
|
||||
base.Visible = TrackingBarControl.Visible;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace Nuclex.Windows.Forms
|
||||
#region Apache License 2.0
|
||||
/*
|
||||
Nuclex .NET Framework
|
||||
Copyright (C) 2002-2024 Markus Ewald / Nuclex Development Labs
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
#endregion // Apache License 2.0
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Nuclex.Support.Tracking;
|
||||
|
||||
namespace Nuclex.Windows.Forms {
|
||||
|
||||
/// <summary>Tracking bar that can be hosted in a tool strip container</summary>
|
||||
public class ToolStripTrackingBar : ToolStripControlHost {
|
||||
|
||||
/// <summary>Initializes a new tool strip tracking bar</summary>
|
||||
public ToolStripTrackingBar() : base(createTrackingBar()) {
|
||||
hideControlAtRuntime();
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new tool strip tracking bar with a name</summary>
|
||||
/// <param name="name">Name of the tracking bar control</param>
|
||||
public ToolStripTrackingBar(string name) : base(createTrackingBar(), name) {
|
||||
hideControlAtRuntime();
|
||||
}
|
||||
|
||||
/// <summary>The tracking bar control being hosted by the tool strip host</summary>
|
||||
public TrackingBar TrackingBarControl {
|
||||
get { return base.Control as TrackingBar; }
|
||||
}
|
||||
|
||||
/// <summary>Tracks the specified transaction in the tracking bar</summary>
|
||||
/// <param name="transaction">Transaction to be tracked</param>
|
||||
public void Track(Transaction transaction) {
|
||||
TrackingBarControl.Track(transaction);
|
||||
}
|
||||
|
||||
/// <summary>Tracks the specified transaction in the tracking bar</summary>
|
||||
/// <param name="transaction">Transaction to be tracked</param>
|
||||
/// <param name="weight">Weight of this transaction in the total progress</param>
|
||||
public void Track(Transaction transaction, float weight) {
|
||||
TrackingBarControl.Track(transaction, weight);
|
||||
}
|
||||
|
||||
/// <summary>Stops tracking the specified transaction</summary>
|
||||
/// <param name="transaction">Transaction to stop tracking</param>
|
||||
public void Untrack(Transaction transaction) {
|
||||
TrackingBarControl.Untrack(transaction);
|
||||
}
|
||||
|
||||
/// <summary>Default size of the hosted control</summary>
|
||||
protected override Size DefaultSize {
|
||||
get { return new Size(100, 15); }
|
||||
}
|
||||
|
||||
/// <summary>Default margin to leave around the control in the tool strip</summary>
|
||||
protected override Padding DefaultMargin {
|
||||
get {
|
||||
if((base.Owner != null) && (base.Owner is StatusStrip)) {
|
||||
return new Padding(1, 3, 1, 3);
|
||||
}
|
||||
|
||||
return new Padding(1, 2, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Creates a new tracking bar</summary>
|
||||
/// <returns>A new tracking bar</returns>
|
||||
private static TrackingBar createTrackingBar() {
|
||||
TrackingBar trackingBar = new TrackingBar();
|
||||
trackingBar.Size = new Size(100, 15);
|
||||
return trackingBar;
|
||||
}
|
||||
|
||||
/// <summary>Hides the control during runtime usage</summary>
|
||||
private void hideControlAtRuntime() {
|
||||
TrackingBarControl.VisibleChanged += new EventHandler(trackingBarVisibleChanged);
|
||||
|
||||
LicenseUsageMode usageMode = System.ComponentModel.LicenseManager.UsageMode;
|
||||
if(usageMode == LicenseUsageMode.Runtime) {
|
||||
base.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toggles the visibility of the tool strip host when the tracking bar control's
|
||||
/// visibility changes.
|
||||
/// </summary>
|
||||
/// <param name="sender">Tracking bar control whose visiblity has changed</param>
|
||||
/// <param name="arguments">Not used</param>
|
||||
private void trackingBarVisibleChanged(object sender, EventArgs arguments) {
|
||||
base.Visible = TrackingBarControl.Visible;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace Nuclex.Windows.Forms
|
||||
|
|
101
Source/TrackingBar/TrackingBar.Designer.cs
generated
101
Source/TrackingBar/TrackingBar.Designer.cs
generated
|
@ -1,51 +1,50 @@
|
|||
#region CPL License
|
||||
/*
|
||||
Nuclex Framework
|
||||
Copyright (C) 2002-2019 Nuclex Development Labs
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
published by the IBM Corporation; either version 1.0 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
IBM Common Public License for more details.
|
||||
|
||||
You should have received a copy of the IBM Common Public
|
||||
License along with this library
|
||||
*/
|
||||
#endregion
|
||||
|
||||
namespace Nuclex.Windows.Forms {
|
||||
|
||||
partial class TrackingBar {
|
||||
/// <summary>Required designer variable.</summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary> Clean up any resources being used.</summary>
|
||||
/// <param name="disposing">
|
||||
/// true if managed resources should be disposed; otherwise, false.
|
||||
/// </param>
|
||||
protected override void Dispose(bool disposing) {
|
||||
if(disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
} // namespace Nuclex.Windows.Forms
|
||||
#region Apache License 2.0
|
||||
/*
|
||||
Nuclex .NET Framework
|
||||
Copyright (C) 2002-2024 Markus Ewald / Nuclex Development Labs
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
#endregion // Apache License 2.0
|
||||
|
||||
namespace Nuclex.Windows.Forms {
|
||||
|
||||
partial class TrackingBar {
|
||||
/// <summary>Required designer variable.</summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary> Clean up any resources being used.</summary>
|
||||
/// <param name="disposing">
|
||||
/// true if managed resources should be disposed; otherwise, false.
|
||||
/// </param>
|
||||
protected override void Dispose(bool disposing) {
|
||||
if(disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
} // namespace Nuclex.Windows.Forms
|
||||
|
|
|
@ -1,134 +1,133 @@
|
|||
#region CPL License
|
||||
/*
|
||||
Nuclex Framework
|
||||
Copyright (C) 2002-2019 Nuclex Development Labs
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
published by the IBM Corporation; either version 1.0 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
IBM Common Public License for more details.
|
||||
|
||||
You should have received a copy of the IBM Common Public
|
||||
License along with this library
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Threading;
|
||||
|
||||
using Nuclex.Support.Tracking;
|
||||
|
||||
namespace Nuclex.Windows.Forms {
|
||||
|
||||
/// <summary>Progress bar for tracking the progress of background operations</summary>
|
||||
public partial class TrackingBar : AsyncProgressBar {
|
||||
|
||||
/// <summary>Initializes a new tracking bar</summary>
|
||||
public TrackingBar() {
|
||||
InitializeComponent();
|
||||
|
||||
// We start off being in the idle state (and thus, being invisible)
|
||||
this.isIdle = true;
|
||||
this.Visible = false;
|
||||
|
||||
// Initialize the delegates we use to update the control's state and those
|
||||
// we use to register ourselfes to the tracker's events
|
||||
this.updateIdleStateDelegate = new MethodInvoker(updateIdleState);
|
||||
this.asyncIdleStateChangedDelegate = new EventHandler<IdleStateEventArgs>(
|
||||
asyncIdleStateChanged
|
||||
);
|
||||
this.asyncProgressUpdateDelegate = new EventHandler<ProgressReportEventArgs>(
|
||||
asyncProgressUpdated
|
||||
);
|
||||
|
||||
// Create the tracker and attach ourselfes to its events
|
||||
this.tracker = new ProgressTracker();
|
||||
this.tracker.AsyncIdleStateChanged += this.asyncIdleStateChangedDelegate;
|
||||
this.tracker.AsyncProgressChanged += this.asyncProgressUpdateDelegate;
|
||||
}
|
||||
|
||||
/// <summary>Tracks the specified transaction in the tracking bar</summary>
|
||||
/// <param name="transaction">Transaction to be tracked</param>
|
||||
public void Track(Transaction transaction) {
|
||||
this.tracker.Track(transaction);
|
||||
}
|
||||
|
||||
/// <summary>Tracks the specified transaction in the tracking bar</summary>
|
||||
/// <param name="transaction">Transaction to be tracked</param>
|
||||
/// <param name="weight">Weight of this transaction in the total progress</param>
|
||||
public void Track(Transaction transaction, float weight) {
|
||||
this.tracker.Track(transaction, weight);
|
||||
}
|
||||
|
||||
/// <summary>Stops tracking the specified transaction</summary>
|
||||
/// <param name="transaction">Transaction to stop tracking</param>
|
||||
public void Untrack(Transaction transaction) {
|
||||
this.tracker.Untrack(transaction);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the summed progressed of the tracked transaction has changed
|
||||
/// </summary>
|
||||
/// <param name="sender">Transaction whose progress has changed</param>
|
||||
/// <param name="arguments">Contains the progress achieved by the transaction</param>
|
||||
private void asyncProgressUpdated(
|
||||
object sender, ProgressReportEventArgs arguments
|
||||
) {
|
||||
AsyncSetValue(arguments.Progress);
|
||||
}
|
||||
|
||||
/// <summary>Called when the tracker becomes enters of leaves the idle state</summary>
|
||||
/// <param name="sender">Tracker that has entered or left the idle state</param>
|
||||
/// <param name="arguments">Contains the new idle state</param>
|
||||
private void asyncIdleStateChanged(object sender, IdleStateEventArgs arguments) {
|
||||
|
||||
// Do a fully synchronous update of the idle state. This update must not be
|
||||
// lost because otherwise, the progress bar might stay on-screen when in fact,
|
||||
// the background operation has already finished and nothing is happening anymore.
|
||||
this.isIdle = arguments.Idle;
|
||||
|
||||
// Update the bar's idle state
|
||||
if(InvokeRequired) {
|
||||
Invoke(this.updateIdleStateDelegate);
|
||||
} else {
|
||||
updateIdleState();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the idle state of the progress bar
|
||||
/// (controls whether the progress bar is shown or invisible)
|
||||
/// </summary>
|
||||
private void updateIdleState() {
|
||||
|
||||
// Only show the progress bar when something is happening
|
||||
base.Visible = !this.isIdle;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>Whether the progress bar is in the idle state</summary>
|
||||
private volatile bool isIdle;
|
||||
/// <summary>Tracker used to sum and update the total progress</summary>
|
||||
private ProgressTracker tracker;
|
||||
/// <summary>Delegate for the idle state update method</summary>
|
||||
private MethodInvoker updateIdleStateDelegate;
|
||||
/// <summary>Delegate for the asyncIdleStateChanged() method</summary>
|
||||
private EventHandler<IdleStateEventArgs> asyncIdleStateChangedDelegate;
|
||||
/// <summary>Delegate for the asyncProgressUpdate() method</summary>
|
||||
private EventHandler<ProgressReportEventArgs> asyncProgressUpdateDelegate;
|
||||
|
||||
}
|
||||
|
||||
} // namespace Nuclex.Windows.Forms
|
||||
#region Apache License 2.0
|
||||
/*
|
||||
Nuclex .NET Framework
|
||||
Copyright (C) 2002-2024 Markus Ewald / Nuclex Development Labs
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
#endregion // Apache License 2.0
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Threading;
|
||||
|
||||
using Nuclex.Support.Tracking;
|
||||
|
||||
namespace Nuclex.Windows.Forms {
|
||||
|
||||
/// <summary>Progress bar for tracking the progress of background operations</summary>
|
||||
public partial class TrackingBar : AsyncProgressBar {
|
||||
|
||||
/// <summary>Initializes a new tracking bar</summary>
|
||||
public TrackingBar() {
|
||||
InitializeComponent();
|
||||
|
||||
// We start off being in the idle state (and thus, being invisible)
|
||||
this.isIdle = true;
|
||||
this.Visible = false;
|
||||
|
||||
// Initialize the delegates we use to update the control's state and those
|
||||
// we use to register ourselfes to the tracker's events
|
||||
this.updateIdleStateDelegate = new MethodInvoker(updateIdleState);
|
||||
this.asyncIdleStateChangedDelegate = new EventHandler<IdleStateEventArgs>(
|
||||
asyncIdleStateChanged
|
||||
);
|
||||
this.asyncProgressUpdateDelegate = new EventHandler<ProgressReportEventArgs>(
|
||||
asyncProgressUpdated
|
||||
);
|
||||
|
||||
// Create the tracker and attach ourselfes to its events
|
||||
this.tracker = new ProgressTracker();
|
||||
this.tracker.AsyncIdleStateChanged += this.asyncIdleStateChangedDelegate;
|
||||
this.tracker.AsyncProgressChanged += this.asyncProgressUpdateDelegate;
|
||||
}
|
||||
|
||||
/// <summary>Tracks the specified transaction in the tracking bar</summary>
|
||||
/// <param name="transaction">Transaction to be tracked</param>
|
||||
public void Track(Transaction transaction) {
|
||||
this.tracker.Track(transaction);
|
||||
}
|
||||
|
||||
/// <summary>Tracks the specified transaction in the tracking bar</summary>
|
||||
/// <param name="transaction">Transaction to be tracked</param>
|
||||
/// <param name="weight">Weight of this transaction in the total progress</param>
|
||||
public void Track(Transaction transaction, float weight) {
|
||||
this.tracker.Track(transaction, weight);
|
||||
}
|
||||
|
||||
/// <summary>Stops tracking the specified transaction</summary>
|
||||
/// <param name="transaction">Transaction to stop tracking</param>
|
||||
public void Untrack(Transaction transaction) {
|
||||
this.tracker.Untrack(transaction);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the summed progressed of the tracked transaction has changed
|
||||
/// </summary>
|
||||
/// <param name="sender">Transaction whose progress has changed</param>
|
||||
/// <param name="arguments">Contains the progress achieved by the transaction</param>
|
||||
private void asyncProgressUpdated(
|
||||
object sender, ProgressReportEventArgs arguments
|
||||
) {
|
||||
AsyncSetValue(arguments.Progress);
|
||||
}
|
||||
|
||||
/// <summary>Called when the tracker becomes enters of leaves the idle state</summary>
|
||||
/// <param name="sender">Tracker that has entered or left the idle state</param>
|
||||
/// <param name="arguments">Contains the new idle state</param>
|
||||
private void asyncIdleStateChanged(object sender, IdleStateEventArgs arguments) {
|
||||
|
||||
// Do a fully synchronous update of the idle state. This update must not be
|
||||
// lost because otherwise, the progress bar might stay on-screen when in fact,
|
||||
// the background operation has already finished and nothing is happening anymore.
|
||||
this.isIdle = arguments.Idle;
|
||||
|
||||
// Update the bar's idle state
|
||||
if(InvokeRequired) {
|
||||
Invoke(this.updateIdleStateDelegate);
|
||||
} else {
|
||||
updateIdleState();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the idle state of the progress bar
|
||||
/// (controls whether the progress bar is shown or invisible)
|
||||
/// </summary>
|
||||
private void updateIdleState() {
|
||||
|
||||
// Only show the progress bar when something is happening
|
||||
base.Visible = !this.isIdle;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>Whether the progress bar is in the idle state</summary>
|
||||
private volatile bool isIdle;
|
||||
/// <summary>Tracker used to sum and update the total progress</summary>
|
||||
private ProgressTracker tracker;
|
||||
/// <summary>Delegate for the idle state update method</summary>
|
||||
private MethodInvoker updateIdleStateDelegate;
|
||||
/// <summary>Delegate for the asyncIdleStateChanged() method</summary>
|
||||
private EventHandler<IdleStateEventArgs> asyncIdleStateChangedDelegate;
|
||||
/// <summary>Delegate for the asyncProgressUpdate() method</summary>
|
||||
private EventHandler<ProgressReportEventArgs> asyncProgressUpdateDelegate;
|
||||
|
||||
}
|
||||
|
||||
} // namespace Nuclex.Windows.Forms
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue