Example #1
0
            public async Task <ActivityResponse> Execute(ActivityArgs args)
            {
                await Task.Delay(10);

                ActivityArgs = args;
                return(Complete("result"));
            }
Example #2
0
 /// <summary>
 /// Method which will be invoked when the running state of the user changes.
 /// </summary>
 /// <param name="sender">The sender of the event</param>
 /// <param name="args">New state of the user</param>
 public void OnRunningDone(object sender, ActivityArgs args)
 {
     IsRunning = ((RunningEventArgs)args).Running;
     if (!IsRunning)
     {
         _stepMemory.Clear();
     }
     OnPropertyChanged(nameof(StepFrequency));
 }
Example #3
0
 public ActivityResponse Execute(ActivityArgs args)
 {
     _retryCount++;
     if (_retryCount == 1)
     {
         throw new InvalidOperationException("exception");
     }
     return(Complete("result"));
 }
 //is called when a step is recognized and refreshes the timeout
 public void OnStepRecognized(object sender, ActivityArgs e)
 {
     _timeout_counter = TIMEOUT_LENGTH;
     //if not running (walking) so far, now
     if (!_runningState)
     {
         ChangeDetected();
     }
 }
Example #5
0
 /// <summary>
 /// Increases the step counter by 1 whenever an event is thrown.
 /// </summary>
 /// <param name="sender">The sender of the event</param>
 /// <param name="args">Ignored</param>
 public override void OnActivityDone(object sender, ActivityArgs args)
 {
     StepCounter++;
     //update step frequency!
     _stepMemory.Enqueue(_timer.ElapsedMilliseconds / 60000f);
     if (_stepMemory.Count > MAX_REGRESSION_LENGTH)
     {
         _stepMemory.Dequeue();
     }
     OnPropertyChanged(nameof(StepFrequency));
 }
Example #6
0
        public async Task Activity_args_can_be_deserialized_into_method_parameters()
        {
            var activityArgs = new ActivityArgs(new Input {
                Id = 10, Details = "det"
            }.ToJson(), "id", "wid", "rid", "token");
            var activity = new ActivityMethodWithArgs();

            await activity.ExecuteAsync(activityArgs);

            Assert.That(activity.Input.Id, Is.EqualTo(10));
            Assert.That(activity.Input.Details, Is.EqualTo("det"));
            Assert.That(activity.TaskToken, Is.EqualTo("token"));
        }
Example #7
0
        protected override void ShowDialog()
        {
            var viewModel = ActivityArgs.GetArgs <DataItemChooserViewModel <T> >();
            var window    = new ViewControllerWindow
            {
                DataContext = viewModel,
                Content     = new DataItemChooserView {
                    Width = 300, Margin = new Thickness(10, 5, 10, 10)
                },
                Title = viewModel.Header,
            }.RemoveIcon().HideMinMaxButton();
            var r      = window.ShowDialog();
            var result = new AsyncActivityResult <DataItemChooserViewModel <T> >(r.GetValueOrDefault(false), viewModel);

            Completion.TrySetResult(result);
        }
Example #8
0
        protected override void ShowDialog()
        {
            var viewModel = ActivityArgs.GetArgs <InputBoxViewModel>() ?? new InputBoxViewModel();
            var window    = new ViewControllerWindow
            {
                DataContext = viewModel,
                Content     = new InputBox {
                    Width = 300, Margin = new Thickness(10, 5, 10, 10)
                },
                Title         = viewModel.Header,
                SizeToContent = SizeToContent.WidthAndHeight,
                ResizeMode    = ResizeMode.NoResize,
            }.RemoveIcon().HideMinMaxButton();
            var r      = window.ShowDialog();
            var result = new AsyncActivityResult <InputBoxViewModel>(r.GetValueOrDefault(false), viewModel);

            Completion.TrySetResult(result);
        }
Example #9
0
 /// <summary>
 /// Increases the active activities' counter by 1 whenever an event is thrown. Updates the progress
 /// and checks for the next activity in the ActivityList if the user has done the required amount
 /// of repetitions. Stops the timer when all activities are done and notifies the user via Text-to-Speech.
 /// </summary>
 /// <param name="sender">The sender of the event</param>
 /// <param name="args">Ignored</param>
 public override async void OnActivityDone(object sender, ActivityArgs args)
 {
     ActiveActivity.Counter++;
     IncreaseResultCounter();
     ProgressLive = Math.Round((double)ActiveActivity.Counter / Repetitions, 2);
     if (ActiveActivity.Counter >= Repetitions)
     {
         ActiveActivity._activity.ActivityDone -= OnActivityDone;
         if (ActivityIterator.MoveNext())
         {
             CheckNextActivity();
         }
         else
         {
             _timer.Stop();
             await _audioService.Speak(AppResources.TrainingDone);
         }
     }
 }
Example #10
0
        private Window PrepareProgressView()
        {
            var options = ActivityArgs.GetArgs <ProgressViewOptions>();

            var window = new ViewControllerWindow
            {
                SizeToContent = SizeToContent.Height,
                DataContext   = new ProgressViewModel(),
                ResizeMode    = ResizeMode.CanMinimize,
                Content       = new ProgressView {
                    Margin = new Thickness(5)
                },
                Title         = options != null ? options.Header : "Copy",
                ShowInTaskbar = true,
                Topmost       = true,
                Width         = 500,
            }.RemoveIcon();

            return(window);
        }
Example #11
0
        protected override void ShowDialog()
        {
            var saveFileDialog = new SaveFileDialog();
            var options        = ActivityArgs.GetArgs <SaveFileOptions>();

            if (options != null)
            {
                saveFileDialog.AddExtension     = options.AddExtension;
                saveFileDialog.InitialDirectory = options.InitialDirectory;
                saveFileDialog.DefaultExt       = options.DefaultExt;
                saveFileDialog.Filter           = options.Filter;
                saveFileDialog.FileName         = options.FileName;
            }

            if (saveFileDialog.ShowDialog() == true)
            {
                Completion.TrySetResult(saveFileDialog.FileName);
            }
            else
            {
                Completion.TrySetResult(null);
            }
        }
 public void OnRunningDone(object sender, ActivityArgs args)
 {
     RunningEventArgs RunningEvent = (RunningEventArgs)args;
     //IsRunning = RunningEvent.Running;
 }
Example #13
0
 public void Setup()
 {
     _activityArgs = new ActivityArgs("input", "id", "wid", "rid", _taskToken);
 }
Example #14
0
 public override void OnActivityDone(object sender, ActivityArgs args)
 {
     throw new NotImplementedException();
 }
Example #15
0
 private void onChangeRecognizedTest(object sender, ActivityArgs args)
 {
     //this method only exists as a parameter for the test TestNoListener.
 }
Example #16
0
        protected override void ShowDialog()
        {
            var viewModel = ActivityArgs.GetArgs <IProgressItemViewModel <T> >();

            StartDialog(viewModel);
        }
Example #17
0
 /// <summary>
 /// Method which is called when events are thrown by the analyse algorithms.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="args">Includes additional Data</param>
 public abstract void OnActivityDone(object sender, ActivityArgs args);
 public override void OnActivityDone(object sender, ActivityArgs args)
 {
     StepCounter++;
 }