Exemplo n.º 1
0
        private void OnProgress(object sender, NefsProgressEventArgs e)
        {
            /* Constrain the progress percentage to appropriate range */
            var value = Math.Min((int)(e.Progress * 100), this.progressBar.Maximum);

            value = Math.Max(value, 0);

            /* Update the form controls - must do on UI thread */
            this.UiService.Dispatcher.Invoke(() =>
            {
                this.progressBar.Value = value;
                this.statusLabel.Text  = $"{e.Message}\r\n{e.SubMessage}";
            });
        }
Exemplo n.º 2
0
        public void BeginTask_Message_ProgressChangedRaised()
        {
            var ct = new CancellationTokenSource().Token;
            var p  = new NefsProgress(ct);

            NefsProgressEventArgs args = null;

            p.ProgressChanged += (o, e) => args = e;

            p.BeginTask(1.0f, "A");
            Assert.Equal(p.StatusMessage, args.Message);
            Assert.Equal(p.StatusSubMessage, args.SubMessage);
            Assert.Equal(p.Percent, args.Progress);
        }
Exemplo n.º 3
0
        public void BeginSubTask_Valid_ProgressChangedRaised()
        {
            var ct = new CancellationTokenSource().Token;
            var p  = new NefsProgress(ct);

            p.BeginTask(1.0f, "A");
            {
                NefsProgressEventArgs args = null;
                p.ProgressChanged += (o, e) => args = e;

                p.BeginSubTask(1.0f, "sub");
                this.Verify(p, 0.0f, "A", "sub");
                Assert.Equal("A", args.Message);
                Assert.Equal("sub", args.SubMessage);
                Assert.Equal(0.0f, args.Progress);

                p.EndTask();
                this.Verify(p, 1.0f, "A", "");
            }
            p.EndTask();
            this.Verify(p, 1.0f, "", "");
        }