Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Controller"/> class.
        /// </summary>
        /// <param name="win">The main window controlled by this instance</param>
        public Controller(MainWindow win)
        {
            SettingsModel = new SettingsModel();
            SettingsModel.PropertyChanged += _SettingsModel_PropertyChanged;
            Client = new DataClient("127.0.0.1", 10000);
            PostureActivity  poseActivity = new PostureActivity(Client);
            ExerciseActivity execActivity = new ExerciseActivity(this);

            execActivity.OnExerciseStart += (paths) =>
            {
                win.Show();
                win.SetContent(win.ExerciseContent);
                win.ExerciseContent.ShowGifs(paths);
                ActivityScheduler.Pause();
            };

            poseActivity.OnImageUpdate += PoseActivity_OnImageUpdate;
            ActivityScheduler           = new ActivityScheduler(new Dictionary <IActivity, int>()
            {
                { poseActivity, 15 },
                { execActivity, 30 }
            });
            ActivityScheduler.Start();

            Window             = win;
            Window.OnMaximize += Window_OnMaximize;
            Window.OnMinimize += Window_OnMinimize;
            Window.Closing    += _Window_Closing;
        }
Ejemplo n.º 2
0
 private void PoseActivity_OnImageUpdate(Image image, string description)
 {
     ActivityScheduler.Pause();
     Window.WebcamContent.Image       = ConvertDrawingImageToWpfImage(image);
     Window.WebcamContent.Description = description;
     Window.SetContent(Window.WebcamContent);
     Window.Show();
 }
Ejemplo n.º 3
0
 private void _Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     try
     {
         ActivityScheduler.Pause();
         _Process.Kill();
         Environment.Exit(0);
     }
     catch
     {
         // ignored
     }
 }
Ejemplo n.º 4
0
 private void Window_OnMaximize() => ActivityScheduler.Pause();