Ejemplo n.º 1
0
        /// <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();
        }
Ejemplo n.º 2
0
        /// <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));
        }
Ejemplo n.º 3
0
		/// <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));
		}
Ejemplo n.º 4
0
        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();
            }
        }
Ejemplo n.º 5
0
        /// <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);
        }
Ejemplo n.º 6
0
		/// <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);
		}
Ejemplo n.º 7
0
        /// <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();
        }
Ejemplo n.º 8
0
 /// <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);
 }
Ejemplo n.º 9
0
 public ProgressGraphic(IProgressGraphicProgressProvider progressProvider, bool autoClose = _defaultAutoClose, ProgressBarGraphicStyle progressBarStyle = _defaultStyle)
     : this(new LegacyProgressProviderAdapter(progressProvider), autoClose, progressBarStyle)
 {
 }
Ejemplo n.º 10
0
 public LegacyProgressProviderAdapter(IProgressGraphicProgressProvider realProvider)
 {
     _realProvider = realProvider;
 }
Ejemplo n.º 11
0
		public ProgressGraphic(IProgressGraphicProgressProvider progressProvider, bool autoClose = _defaultAutoClose, ProgressBarGraphicStyle progressBarStyle = _defaultStyle)
			: this(new LegacyProgressProviderAdapter(progressProvider), autoClose, progressBarStyle) {}
Ejemplo n.º 12
0
			public LegacyProgressProviderAdapter(IProgressGraphicProgressProvider realProvider)
			{
				_realProvider = realProvider;
			}
Ejemplo n.º 13
0
		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();
		}
Ejemplo n.º 14
0
		/// <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);
		}
Ejemplo n.º 15
0
		/// <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();
		}