/// <summary> /// Initializes a new instance of the MainWindow class. /// </summary> public MainWindow() { // ws = new WS(); // home = new Home(); superKinectroid = new SuperKinectroid(); // one sensor is currently supported kinectSensor = KinectSensor.GetDefault(); var colorFrameDescription = kinectSensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Bgra); // colorBitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height, 96.0, // 96.0, PixelFormats.Bgr32, null); _bodySource = BodyDriver.GetSource(); _colorBitmap = ColorDriver.GetBitmap(kinectSensor); _infraredBitmap = InfraredDriver.GetBitmap(kinectSensor); // set IsAvailableChanged event notifier kinectSensor.IsAvailableChanged += Sensor_IsAvailableChanged; // open the sensor kinectSensor.Open(); // set the status text StatusText = kinectSensor.IsAvailable ? "Running" : "No ready Kinect found!"; // use the window object as the view model in this simple example DataContext = this; // initialize the components (controls) of the window InitializeComponent(); }
private void SetColor(bool state) { if (state && _colorDriver == null) { _colorDriver = new ColorDriver(kinectSensor, _colorBitmap); ColorVisibility = Visibility.Visible; } else if (!state && _colorDriver != null) { _colorDriver?.Dispose(); _colorDriver = null; ColorVisibility = Visibility.Hidden; } }
/// <summary> /// Execute shutdown tasks /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void MainWindow_Closing(object sender, CancelEventArgs e) { _bodyDriver?.Dispose(); _bodyDriver = null; _colorDriver?.Dispose(); _colorDriver = null; _infraredDriver?.Dispose(); _infraredDriver = null; kinectSensor?.Close(); kinectSensor = null; }