Esempio n. 1
0
        public MainViewModel(IKinectService kinectService,
                             ICarControllerService carControllerService, ICarCameraService carCameraService, IControlLogic controlLogic)
            : this()
        {
            //Setup Camera
            _carCameraService             = carCameraService;
            _carCameraService.ImageReady += (sender, args) => CarCameraImage = args.BitmapImage;

            //Setup Car Controller
            _carControllerService = carControllerService;
            CarControllerStatus   = _carControllerService.Status;
            _carControllerService.CarControllerStatusChanged += CarControllerServiceOnCarControllerStatusChanged;

            //Setup Kinect
            _kinectService     = kinectService;
            KinectSensorStatus = _kinectService.Status;
            _kinectService.KinectStatusChanged += KinectServiceOnKinectStatusChanged;
            _kinectService.SkeletonFrameReady  += KinectServiceOnSkeletonFrameReady;
            _kinectService.ColorImageReady     += (sender, args) => KinectCameraImage = args.BitmapSource;

            //setup Control logic (business logic)
            _controlLogic = controlLogic;
            _controlLogic.ControllingEvent  += (sender, args) => IsControlling = args.IsControlling;
            _controlLogic.NewDirectionEvent += (sender, args) => Direction = args.Direction;
            _controlLogic.NewVelocityEvent  += (sender, args) => Velocity = args.Velocity;
            _controlLogic.TimeLeftTickEvent += (sender, args) => CountDown = args.TickTime;
            CountDown = _controlLogic.OriginalTime;

            //Setup Commands
            RetryCommand          = new DelegateCommand(Retry);
            CancelCommand         = new DelegateCommand(Cancel);
            ConnectCommand        = new DelegateCommand(Connect);
            SetKinectAngleCommand = new DelegateCommand(SetKinectAngle);
        }
Esempio n. 2
0
        public MainViewModel(IKinectService kinectService,
		                     ICarControllerService carControllerService, ICarCameraService carCameraService, IControlLogic controlLogic)
            : this()
        {
            //Setup Camera
            _carCameraService = carCameraService;
            _carCameraService.ImageReady += (sender, args) => CarCameraImage = args.BitmapImage;

            //Setup Car Controller
            _carControllerService = carControllerService;
            CarControllerStatus = _carControllerService.Status;
            _carControllerService.CarControllerStatusChanged += CarControllerServiceOnCarControllerStatusChanged;

            //Setup Kinect
            _kinectService = kinectService;
            KinectSensorStatus = _kinectService.Status;
            _kinectService.KinectStatusChanged += KinectServiceOnKinectStatusChanged;
            _kinectService.SkeletonFrameReady += KinectServiceOnSkeletonFrameReady;
            _kinectService.ColorImageReady += (sender, args) => KinectCameraImage = args.BitmapSource;

            //setup Control logic (business logic)
            _controlLogic = controlLogic;
            _controlLogic.ControllingEvent += (sender, args) => IsControlling = args.IsControlling;
            _controlLogic.NewDirectionEvent += (sender, args) => Direction = args.Direction;
            _controlLogic.NewVelocityEvent += (sender, args) => Velocity = args.Velocity;
            _controlLogic.TimeLeftTickEvent += (sender, args) => CountDown = args.TickTime;
            CountDown = _controlLogic.OriginalTime;

            //Setup Commands
            RetryCommand = new DelegateCommand(Retry);
            CancelCommand = new DelegateCommand(Cancel);
            ConnectCommand = new DelegateCommand(Connect);
            SetKinectAngleCommand = new DelegateCommand(SetKinectAngle);
        }