/// <summary> /// Creates and displays a <see cref="ProgressGraphic"/>. /// </summary> /// <remarks> /// This method will invoke the graphic's <see cref="IDrawable.Draw"/> method, so do not call it from a draw routine in the same scene graph! /// </remarks> /// <param name="source">The source from which progress information is retrieved and displayed.</param> /// <param name="parentCollection">The graphics collection on which the progress graphic should be shown.</param> /// <param name="autoClose">A value indicating whether or not the progress graphic should be automatically removed when the task is terminated.</param> /// <param name="progressBarGraphicStyle">The style of the progress bar.</param> public static void Show(IProgressGraphicProgressProvider source, GraphicCollection parentCollection, bool autoClose, ProgressBarGraphicStyle progressBarGraphicStyle) { ProgressGraphic progressGraphic = new ProgressGraphic(source, autoClose, progressBarGraphicStyle); parentCollection.Add(progressGraphic); progressGraphic.Draw(); }
/// <summary> /// Initializes a new <see cref="ProgressGraphic"/>. /// </summary> /// <param name="progressProvider">The provider of progress information for which the <see cref="ProgressGraphic"/> will display updates.</param> /// <param name="autoClose">A value indicating whether or not the <see cref="ProgressGraphic"/> should automatically remove and dispose itself when the progress provider reports task completion or cancellation.</param> /// <param name="progressBarStyle">The style of progress bar to be displayed.</param> public ProgressGraphic(IProgressGraphicProgressProvider progressProvider, bool autoClose, ProgressBarGraphicStyle progressBarStyle) { _progressProvider = progressProvider; _autoClose = autoClose; _progressBarStyle = progressBarStyle; base.Graphics.Add(_graphics = new ProgressCompositeGraphic(_progressBarStyle)); }
/// <summary> /// Initializes a new <see cref="ProgressGraphic"/>. /// </summary> /// <param name="progressProvider">The provider of progress information for which the <see cref="ProgressGraphic"/> will display updates.</param> /// <param name="autoClose">A value indicating whether or not the <see cref="ProgressGraphic"/> should automatically remove and dispose itself when the progress provider reports task completion or cancellation.</param> /// <param name="progressBarStyle">The style of progress bar to be displayed.</param> public ProgressGraphic(IProgressGraphicProgressProvider progressProvider, bool autoClose, ProgressBarGraphicStyle progressBarStyle) { _progressProvider = progressProvider; _autoClose = autoClose; _progressBarStyle = progressBarStyle; base.Graphics.Add(_graphics = new ProgressCompositeGraphic(_progressBarStyle)); }
public static void Show(IProgressGraphicProgressProvider source, GraphicCollection parentCollection, bool autoClose = _defaultAutoClose, ProgressBarGraphicStyle progressBarStyle = _defaultStyle, bool drawImmediately = _defaultDrawImmediately) { ProgressGraphic progressGraphic = new ProgressGraphic(source, autoClose, progressBarStyle); parentCollection.Add(progressGraphic); if (drawImmediately) { progressGraphic.Draw(); } }
/// <summary> /// Releases all resources used by this <see cref="ProgressGraphic"/>. /// </summary> protected override void Dispose(bool disposing) { if (disposing) { _progressProvider = null; _synchronizationContext = null; if (_updateTask != null) { _updateTask.RequestCancel(); _updateTask = null; } } base.Dispose(disposing); }
/// <summary> /// Releases all resources used by this <see cref="ProgressGraphic"/>. /// </summary> protected override void Dispose(bool disposing) { if (disposing) { _progressProvider = null; _synchronizationContext = null; if (_updateTask != null) { _updateTask.RequestCancel(); _updateTask = null; } } base.Dispose(disposing); }
/// <summary> /// Called by the framework just before the <see cref="ProgressGraphic"/> is rendered. /// </summary> public override void OnDrawing() { if (_synchronizationContext == null) { _synchronizationContext = SynchronizationContext.Current; } if (_progressProvider != null) { float progress; string message; if (_progressProvider.IsRunning(out progress, out message)) { if (_updateTask == null && _synchronizationContext != null) { _updateTask = new BackgroundTask(UpdateProgressBar, true, null); _updateTask.Terminated += OnTaskTerminated; _updateTask.Run(); } } else { _progressProvider = null; if (_updateTask != null) { _updateTask.RequestCancel(); _updateTask = null; } if (_autoClose && _synchronizationContext != null) { _synchronizationContext.Post(s => Close(), null); } } _graphics.Progress = progress; _graphics.Text = message; } base.OnDrawing(); }
/// <summary> /// Creates and displays a <see cref="ProgressGraphic"/>. /// </summary> /// <remarks> /// This method will invoke the graphic's <see cref="IDrawable.Draw"/> method, so do not call it from a draw routine in the same scene graph! /// </remarks> /// <param name="source">The source from which progress information is retrieved and displayed.</param> /// <param name="parentCollection">The graphics collection on which the progress graphic should be shown.</param> /// <param name="autoClose">A value indicating whether or not the progress graphic should be automatically removed when the task is terminated.</param> public static void Show(IProgressGraphicProgressProvider source, GraphicCollection parentCollection, bool autoClose) { Show(source, parentCollection, autoClose, ProgressBarGraphicStyle.Blocks); }
public ProgressGraphic(IProgressGraphicProgressProvider progressProvider, bool autoClose = _defaultAutoClose, ProgressBarGraphicStyle progressBarStyle = _defaultStyle) : this(new LegacyProgressProviderAdapter(progressProvider), autoClose, progressBarStyle) { }
public LegacyProgressProviderAdapter(IProgressGraphicProgressProvider realProvider) { _realProvider = realProvider; }
public ProgressGraphic(IProgressGraphicProgressProvider progressProvider, bool autoClose = _defaultAutoClose, ProgressBarGraphicStyle progressBarStyle = _defaultStyle) : this(new LegacyProgressProviderAdapter(progressProvider), autoClose, progressBarStyle) {}
public LegacyProgressProviderAdapter(IProgressGraphicProgressProvider realProvider) { _realProvider = realProvider; }
public static void Show(IProgressGraphicProgressProvider source, GraphicCollection parentCollection, bool autoClose = _defaultAutoClose, ProgressBarGraphicStyle progressBarStyle = _defaultStyle) { ProgressGraphic progressGraphic = new ProgressGraphic(source, autoClose, progressBarStyle); parentCollection.Add(progressGraphic); progressGraphic.Draw(); }
/// <summary> /// Creates and displays a <see cref="ProgressGraphic"/>. /// </summary> /// <remarks> /// This method will invoke the graphic's <see cref="IDrawable.Draw"/> method, so do not call it from a draw routine in the same scene graph! /// </remarks> /// <param name="source">The source from which progress information is retrieved and displayed.</param> /// <param name="parentCollection">The graphics collection on which the progress graphic should be shown.</param> /// <param name="autoClose">A value indicating whether or not the progress graphic should be automatically removed when the task is terminated.</param> public static void Show(IProgressGraphicProgressProvider source, GraphicCollection parentCollection, bool autoClose) { Show(source, parentCollection, autoClose, ProgressBarGraphicStyle.Blocks); }
/// <summary> /// Called by the framework just before the <see cref="ProgressGraphic"/> is rendered. /// </summary> public override void OnDrawing() { if (_synchronizationContext == null) _synchronizationContext = SynchronizationContext.Current; if (_progressProvider != null) { float progress; string message; if (_progressProvider.IsRunning(out progress, out message)) { if (_updateTask == null && _synchronizationContext != null) { _updateTask = new BackgroundTask(UpdateProgressBar, true, null); _updateTask.Terminated += OnTaskTerminated; _updateTask.Run(); } } else { _progressProvider = null; if (_updateTask != null) { _updateTask.RequestCancel(); _updateTask = null; } if (_autoClose && _synchronizationContext != null) { _synchronizationContext.Post(s => Close(), null); } } _graphics.Progress = progress; _graphics.Text = message; } base.OnDrawing(); }