예제 #1
0
        private void AnimateProgressBar(CmdExecutorProgress o)
        {
            var             duration        = DurationFactory.FromMilliseconds(250);
            DoubleAnimation doubleAnimation = new DoubleAnimation(o.Percentage, duration);

            ConsoleProgressBar.BeginAnimation(RangeBase.ValueProperty, doubleAnimation);
            ConsoleProgressBar.Value = o.Percentage;
        }
예제 #2
0
        /// <summary>
        /// Executes all commands in the <see cref="CommandQueue"/> asynchronously and removes them from the data structure.
        /// Optionally, notifies of progress.
        /// Can be canceled.
        /// </summary>
        /// <param name="progress">Notifies its caller of progress.</param>
        /// <param name="cancellationToken">Enables canceling</param>
        /// <seealso cref="IProgress{T}"/>
        public virtual async Task ExecuteAsync(IProgress <CmdExecutorProgress> progress,
                                               CancellationToken cancellationToken)
        {
            var message = ChamiUIStrings.StartingExecutionMessage;
            CmdExecutorProgress cmdExecutorProgress = new CmdExecutorProgress(0, null, message);

            progress?.Report(cmdExecutorProgress);
            int currentIndex = 0;

            do
            {
                var environmentVariable = CommandQueue.Dequeue();
                currentIndex++;
                float percentage = 100.0F * currentIndex / CommandQueue.Count;
                await environmentVariable.ExecuteAsync(progress, percentage, cancellationToken);
            } while (CommandQueue.Count > 0);


            progress?.Report(new CmdExecutorProgress(100, null, ChamiUIStrings.ExecutionCompleteMessage));
        }
예제 #3
0
        private void HandleProgressReport(CmdExecutorProgress o)
        {
            if (o.Message != null)
            {
                var message = o.Message;
                message.TrimStart('\n');
                if (!o.Message.EndsWith("\n"))
                {
                    message += "\n";
                }

                ConsoleTextBox.Text += message;
            }

            if (o.OutputStream != null)
            {
                StreamReader reader = new StreamReader(o.OutputStream);
                ConsoleTextBox.Text += reader.ReadToEnd();
            }

            ConsoleTextBox.ScrollToEnd();
            AnimateProgressBar(o);
        }