Example #1
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Performing some task... ");
            using (var progress = new ProgressBar <SimpleProgressInfo>())
                using (new DoubleProgressAdapter(progress, "1"))
                    using (ProgressScope.Start("1", 0, 1, "Starting"))
                    {
                        Thread.Sleep(1000);
                        ProgressScope.Report(0.1, "One");
                        Thread.Sleep(1000);
                        ProgressScope.Report(0.2);
                        Thread.Sleep(1000);
                        using (ProgressScope.Start("2", 0.3, 0.45))
                        {
                            Thread.Sleep(1000);
                            ProgressScope.Report(0.33);
                            Thread.Sleep(1000);
                            ProgressScope.Report(0.66, "tu");
                            Thread.Sleep(1000);
                        }
                        Thread.Sleep(1000);
                        ProgressScope.Report(0.6, "Almost");
                        Thread.Sleep(1000);
                        ProgressScope.Report(0.8);
                        Thread.Sleep(1000);
                    }
            Console.WriteLine("Done.");

            Console.ReadKey();
        }
        public static void AssignTask(IProgressDialogController progress, ITask task)
        {
            var taskManager = new TaskManager(task.Name);

            taskManager.Enqueue(task);

            var progressChangedHandler = new EventHandler((o, e) =>
            {
                progress.SetProgress(taskManager.Progress);
                if (ProgressScope.ProgressEquals(taskManager.Progress, 1.0))
                {
                    progress.CloseAsync();
                }
            });
            var statusMessageChangedHandler = new EventHandler((o, e) => progress.SetMessage(taskManager.StatusMessage));
            var isIndetermineChangedHandler = new EventHandler((o, e) => { if (taskManager.IsIndeterminate)
                                                                           {
                                                                               progress.SetIndeterminate();
                                                                           }
                                                               });

            taskManager.ProgressChanged      += progressChangedHandler;
            taskManager.StatusMessageChanged += statusMessageChangedHandler;
            taskManager.IsIndetermineChanged += isIndetermineChangedHandler;

            taskManager.Process().Wait();

            taskManager.ProgressChanged      -= progressChangedHandler;
            taskManager.StatusMessageChanged -= statusMessageChangedHandler;
            taskManager.IsIndetermineChanged -= isIndetermineChangedHandler;
        }
        private void CreateDocument()
        {
            var template = this.SelectedTemplate;

            if (template == null)
            {
                return;
            }

            this.IsGenerating            = true;
            this.GeneratingProgressScope = ProgressScope.Create("create stats document");

            template.BeginCreateDocument(this.Tank,
                                         this.GeneratingProgressScope,
                                         r =>
            {
                this.Document = r.Document;
                _statVms      = r.StatVms;
                this.UpdateStatsValueMode();

                this.IsGenerating = false;
            });

            //this.Document = template.BeginCreateDocument(this.Tank, out _statVms);
            //this.UpdateStatsValueMode();
        }
Example #4
0
        /// <summary>
        /// 実行
        /// </summary>
        public BuildResult Run()
        {
            BuildResult result = new BuildResult();

            using (var dialog = new ProgressScope("BuildPipeline"))
            {
                //	ビルド処理を順番に行っていく
                PringlesUtils.Log("---------------------[ Build Start ]---------------------");
                for (var i = 0; i < m_steps.Count; i++)
                {
                    var step     = m_steps[i];
                    var progress = Mathf.InverseLerp(0, m_steps.Count, i);
                    dialog.Show(step.ToString(), progress);
                    PringlesUtils.Log($"---------------------[ Start : {step.ToString()} ]---------------------");
                    result = step.Execute();
                    if (result.Type == ResultType.Error)
                    {
                        break;
                    }
                    PringlesUtils.Log($"---------------------[ Done : { result.ToString() } ]---------------------");
                }
                PringlesUtils.Log($"---------------------[ Build Finish : {result.Type } ]---------------------");
                return(result);
            }
        }
        void ProgressBarAnimation_Completed(object sender, EventArgs e)
        {
            if (ProgressScope.ProgressEquals(this.ViewModel.LoadingProgress, 1.0))
            {
                this.ViewModel.LoadingIsIndeterminate = true;
                this.ViewModel.LoadingStatusText      = this.L("splash", "status_preparing");
            }

            _progressBarAnimation.Completed -= ProgressBarAnimation_Completed;
            _progressBarAnimation            = null;
        }
Example #6
0
        void taskManager_ProgressChanged(object sender, EventArgs e)
        {
            var taskManager = (TaskManager)sender;

            _activeTaskManager = taskManager;

            if (ProgressScope.ProgressEquals(taskManager.Progress, 1.0))
            {
                this.RemoveTaskManager(taskManager);
            }
        }
Example #7
0
 public ProgressReporterScope(IProgressReporter reporter, string name)
 {
     _reporter = reporter;
     _scope    = ProgressScope.Named(name);
 }
Example #8
0
 public void Dispose()
 {
     _scope = ProgressScope.Empty;
 }
Example #9
0
 internal ChildProgressScope(string name, ProgressScope parent, double weight)
     : base(name)
 {
     _parent     = parent;
     this.Weight = weight;
 }