|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
using Microsoft.Kinect;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
|
|
|
|
namespace Lib
|
|
|
|
|
{
|
|
|
|
@ -18,6 +19,17 @@ namespace Lib
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private SolidColorBrush _kinectStatusColor = new SolidColorBrush(Colors.Red); // Couleur rouge par défaut, signifiant inactive
|
|
|
|
|
public SolidColorBrush KinectStatusColor
|
|
|
|
|
{
|
|
|
|
|
get { return _kinectStatusColor; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_kinectStatusColor = value;
|
|
|
|
|
OnPropertyChanged(nameof(KinectStatusColor));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
protected virtual void OnPropertyChanged(string propertyName)
|
|
|
|
|
{
|
|
|
|
@ -27,21 +39,11 @@ namespace Lib
|
|
|
|
|
public KinectManager()
|
|
|
|
|
{
|
|
|
|
|
sensor = KinectSensor.GetDefault();
|
|
|
|
|
if (Sensor == null)
|
|
|
|
|
{
|
|
|
|
|
StatusText = "Kinect n'est pas connecté";
|
|
|
|
|
}
|
|
|
|
|
else if (!Sensor.IsOpen)
|
|
|
|
|
{
|
|
|
|
|
StatusText = "Kinect n'est pas ouvert";
|
|
|
|
|
}
|
|
|
|
|
else if (Sensor.IsAvailable)
|
|
|
|
|
{
|
|
|
|
|
StatusText = "Kinect est disponible";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
UpdateStatusProperties();
|
|
|
|
|
// Abonnez-vous à l'événement IsAvailableChanged
|
|
|
|
|
if (sensor != null)
|
|
|
|
|
{
|
|
|
|
|
StatusText = "Kinect n'est pas disponible";
|
|
|
|
|
sensor.IsAvailableChanged += KinectSensor_IsAvailableChanged;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void StartSensor()
|
|
|
|
@ -79,25 +81,33 @@ namespace Lib
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void KinectSensor_IsAvailableChanged(object sender, IsAvailableChangedEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
if (Sensor == null)
|
|
|
|
|
{
|
|
|
|
|
StatusText = "Kinect n'est pas connecté";
|
|
|
|
|
}
|
|
|
|
|
else if (!Sensor.IsOpen)
|
|
|
|
|
{
|
|
|
|
|
StatusText = "Kinect n'est pas ouvert";
|
|
|
|
|
}
|
|
|
|
|
else if (Sensor.IsAvailable)
|
|
|
|
|
{
|
|
|
|
|
StatusText = "Kinect est disponible";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
StatusText = "Kinect n'est pas disponible";
|
|
|
|
|
}
|
|
|
|
|
private void KinectSensor_IsAvailableChanged(object sender, IsAvailableChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UpdateStatusProperties();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private void UpdateStatusProperties()
|
|
|
|
|
{
|
|
|
|
|
if (Sensor == null)
|
|
|
|
|
{
|
|
|
|
|
StatusText = "Kinect n'est pas connecté";
|
|
|
|
|
KinectStatusColor = new SolidColorBrush(Colors.Red);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (!Sensor.IsOpen)
|
|
|
|
|
{
|
|
|
|
|
StatusText = "Kinect n'est pas ouvert";
|
|
|
|
|
KinectStatusColor = new SolidColorBrush(Colors.Yellow);
|
|
|
|
|
}
|
|
|
|
|
else if (Sensor.IsAvailable)
|
|
|
|
|
{
|
|
|
|
|
StatusText = "Kinect est disponible";
|
|
|
|
|
KinectStatusColor = new SolidColorBrush(Colors.Green);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
StatusText = "Kinect n'est pas disponible";
|
|
|
|
|
KinectStatusColor = new SolidColorBrush(Colors.Orange);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|