/// <summary> /// Initializes a new instance of the MainWindow class /// </summary> public MainWindow() { // initialize the MainWindow this.InitializeComponent(); // only one sensor is currently supported this.kinectSensor = KinectSensor.GetDefault(); // open the sensor this.kinectSensor.Open(); // set the initial status text this.UpdateKinectStatusText(); // open the reader for the body frames this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader(); // initialize the BodyViewer object for displaying tracked bodies in the UI this.kinectBodyView = new KinectBodyView(this.kinectSensor); // initialize the SpaceView object this.spaceView = new SpaceView(this.spaceGrid, this.spaceImage); // initialize the GestureDetector object this.gestureResultView = new GestureResultView(false, false, false, false, -1.0f, this.spaceView); this.gestureDetector = new GestureDetector(this.kinectSensor, this.gestureResultView); // set data context objects for display in UI this.DataContext = this; this.kinectBodyViewbox.DataContext = this.kinectBodyView; this.gestureResultGrid.DataContext = this.gestureResultView; this.spaceGrid.DataContext = this.spaceView; this.collisionResultGrid.DataContext = this.spaceView; }
/// <summary> /// Initializes a new instance of the GestureResultView class and sets initial property values /// </summary> /// <param name="isTracked">True, if the body is currently tracked</param> /// <param name="left">True, if the 'Steer_Left' gesture is currently detected</param> /// <param name="right">True, if the 'Steer_Right' gesture is currently detected</param> /// <param name="straight">True, if the 'SteerStraight' gesture is currently detected</param> /// <param name="progress">Progress value of the 'SteerProgress' gesture</param> /// <param name="space">SpaceView object in UI which should be updated with latest gesture result data</param> public GestureResultView(bool isTracked, bool left, bool right, bool straight, float progress, SpaceView space) { if (space == null) { throw new ArgumentNullException("spaceView"); } this.IsTracked = isTracked; this.TurnLeft = left; this.TurnRight = right; this.KeepStraight = straight; this.SteerProgress = progress; this.spaceView = space; }