Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProgressModel"/> class.
        /// </summary>
        /// <param name="context">The context that is used to execute actions on the UI thread.</param>
        /// <param name="progressReporter">The object that provides progress notifications for all the processes.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="context"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="progressReporter"/> is <see langword="null" />.
        /// </exception>
        public ProgressModel(IContextAware context, ICollectProgressReports progressReporter)
            : base(context)
        {
            {
                Lokad.Enforce.Argument(() => progressReporter);
            }

            m_Reporter = progressReporter;
            m_Reporter.OnStartProgress += HandleOnStartProgress;
            m_Reporter.OnProgress      += HandleOnProgress;
            m_Reporter.OnStopProgress  += HandleOnStopProgress;
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProgressModel"/> class.
        /// </summary>
        /// <param name="context">The context that is used to execute actions on the UI thread.</param>
        /// <param name="progressReporter">The object that provides progress notifications for all the processes.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="context"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="progressReporter"/> is <see langword="null" />.
        /// </exception>
        public ProgressModel(IContextAware context, ICollectProgressReports progressReporter)
            : base(context)
        {
            {
                Lokad.Enforce.Argument(() => progressReporter);
            }

            m_Reporter = progressReporter;
            m_Reporter.OnStartProgress += HandleOnStartProgress;
            m_Reporter.OnProgress += HandleOnProgress;
            m_Reporter.OnStopProgress += HandleOnStopProgress;
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShellWindow"/> class.
        /// </summary>
        /// <param name="exitCommand">The command used to exit the application.</param>
        /// <param name="progressReporter">The object that reports progress for all of the application.</param>
        /// <exception cref="ArgumentNullException">
        /// Thrown if <paramref name="exitCommand"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="progressReporter"/> is <see langword="null" />.
        /// </exception>
        public ShellWindow(ExitCommand exitCommand, ICollectProgressReports progressReporter)
            : this()
        {
            {
                Enforce.Argument(() => exitCommand);
                Enforce.Argument(() => progressReporter);
            }

            m_ExitCommand = exitCommand;

            // Handle the start progress event.
            {
                progressReporter.OnStartProgress +=
                    (s, e) =>
                {
                    Action action = () => taskbarItemInfo.ProgressState = TaskbarItemProgressState.Indeterminate;
                    Dispatcher.Invoke(action);
                };
            }

            // Handle the progress event.
            {
                Action <int, bool> action =
                    (progress, hasErrors) =>
                {
                    taskbarItemInfo.ProgressState = hasErrors ? TaskbarItemProgressState.Error : TaskbarItemProgressState.Normal;
                    taskbarItemInfo.ProgressValue = progress / 100.0;
                };
                progressReporter.OnProgress +=
                    (s, e) =>
                {
                    Dispatcher.Invoke(action, e.Progress, e.HasErrors);
                };
            }

            // Handle the stop progress event.
            {
                progressReporter.OnStopProgress +=
                    (s, e) =>
                {
                    Action action = () => taskbarItemInfo.ProgressState = TaskbarItemProgressState.None;
                    Dispatcher.Invoke(action);
                };
            }
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShellWindow"/> class.
        /// </summary>
        /// <param name="exitCommand">The command used to exit the application.</param>
        /// <param name="progressReporter">The object that reports progress for all of the application.</param>
        /// <exception cref="ArgumentNullException">
        /// Thrown if <paramref name="exitCommand"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="progressReporter"/> is <see langword="null" />.
        /// </exception>
        public ShellWindow(ExitCommand exitCommand, ICollectProgressReports progressReporter)
            : this()
        {
            {
                Enforce.Argument(() => exitCommand);
                Enforce.Argument(() => progressReporter);
            }

            m_ExitCommand = exitCommand;

            // Handle the start progress event.
            {
                progressReporter.OnStartProgress +=
                    (s, e) =>
                    {
                        Action action = () => taskbarItemInfo.ProgressState = TaskbarItemProgressState.Indeterminate;
                        Dispatcher.Invoke(action);
                    };
            }

            // Handle the progress event.
            {
                Action<int, bool> action =
                    (progress, hasErrors) =>
                    {
                        taskbarItemInfo.ProgressState = hasErrors ? TaskbarItemProgressState.Error : TaskbarItemProgressState.Normal;
                        taskbarItemInfo.ProgressValue = progress / 100.0;
                    };
                progressReporter.OnProgress +=
                    (s, e) =>
                    {
                        Dispatcher.Invoke(action, e.Progress, e.HasErrors);
                    };
            }

            // Handle the stop progress event.
            {
                progressReporter.OnStopProgress +=
                    (s, e) =>
                    {
                        Action action = () => taskbarItemInfo.ProgressState = TaskbarItemProgressState.None;
                        Dispatcher.Invoke(action);
                    };
            }
        }