diff --git a/KinectConnection/KinectConnection.csproj b/KinectConnection/KinectConnection.csproj index 7083fc9..50fb200 100644 --- a/KinectConnection/KinectConnection.csproj +++ b/KinectConnection/KinectConnection.csproj @@ -12,6 +12,8 @@ v4.8 512 true + + true @@ -31,11 +33,37 @@ 4 + + ..\packages\CommunityToolkit.Mvvm.8.2.2\lib\netstandard2.0\CommunityToolkit.Mvvm.dll + + + ..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll + ..\packages\Microsoft.Kinect.2.0.1410.19000\lib\net45\Microsoft.Kinect.dll + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + ..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll + + + + ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + @@ -51,4 +79,11 @@ + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + \ No newline at end of file diff --git a/KinectConnection/KinectManager.cs b/KinectConnection/KinectManager.cs index d234027..b1dba36 100644 --- a/KinectConnection/KinectManager.cs +++ b/KinectConnection/KinectManager.cs @@ -1,4 +1,5 @@ -using Microsoft.Kinect; +using CommunityToolkit.Mvvm.ComponentModel; +using Microsoft.Kinect; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,60 +11,69 @@ using System.Threading.Tasks; namespace KinectConnection { - public class KinectManager + /// + /// Classe KinectManager permettant la gestion des évènements autour du Kinect + /// + public class KinectManager : ObservableObject { + private KinectSensor kinectSensor; + private bool status; + private string statusText; + /// + /// Constructeur de la classe KinectManager + /// public KinectManager() { this.kinectSensor = KinectSensor.GetDefault(); + this.Status = false; } - // properties - public KinectSensor kinectSensor; - - public bool Status; - - public event PropertyChangedEventHandler PropertyChanged; + /// + /// Propriété définissant le statut de l'état actuel du Kinect sous la forme d'un booléen + /// + public bool Status + { + get { return status; } + set { SetProperty(ref status, value); } + } - private string statusText; + /// + /// Propriété définissant le statut de l'état actuel du Kinect sous la forme d'un string + /// public string StatusText { - get - { - return this.statusText; - } - - set - { - if (this.statusText != value) - { - this.statusText = value; - - if(this.PropertyChanged != null) - { - this.PropertyChanged(this, new PropertyChangedEventArgs("StatusText")); - } - } - } - } + get { return statusText; } + set { SetProperty(ref statusText, value); } + } - // methods + /// + /// Méthode permettant de lancer la méthode Open du KinectSensor et de s'abonner à l'évènement "IsAvailableChanged" + /// public void StartSensor() { this.kinectSensor.Open(); this.kinectSensor.IsAvailableChanged += this.KinectSensor_IsAvailableChanged; } + /// + /// Méthode permettant de lancer la méthode Close du KinectSensor et de se désabonner à l'évènement "IsAvailableChanged" + /// public void StopSensor() { this.kinectSensor.IsAvailableChanged -= this.KinectSensor_IsAvailableChanged; this.kinectSensor.Close(); } + /// + /// Évènement IsAvailableChanged permettant de mettre à jour les propriétés du KinectManager en fonction de l'état du kinect + /// + /// + /// private void KinectSensor_IsAvailableChanged(object sender, IsAvailableChangedEventArgs args) { this.StatusText = this.kinectSensor.IsAvailable ? "Kinect Available" : "Kinect Not Available"; + this.Status = this.kinectSensor.IsAvailable; } - } } diff --git a/KinectConnection/packages.config b/KinectConnection/packages.config index 6350273..7fc340b 100644 --- a/KinectConnection/packages.config +++ b/KinectConnection/packages.config @@ -1,4 +1,12 @@  + + + + + + + + \ No newline at end of file diff --git a/KinectSensor/Class1.cs b/KinectSensor/Class1.cs deleted file mode 100644 index dcdb6d8..0000000 --- a/KinectSensor/Class1.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace KinectSensor -{ - public class Class1 - { - } -} diff --git a/KinectSensor/KinectSensor.csproj b/KinectSensor/KinectSensor.csproj deleted file mode 100644 index 61e4742..0000000 --- a/KinectSensor/KinectSensor.csproj +++ /dev/null @@ -1,54 +0,0 @@ - - - - - Debug - AnyCPU - cef75546-05f1-41a2-91ab-b4016a5436c4 - Library - Properties - KinectSensor - KinectSensor - v4.8 - 512 - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - diff --git a/KinectSensor/Properties/AssemblyInfo.cs b/KinectSensor/Properties/AssemblyInfo.cs deleted file mode 100644 index 0da80af..0000000 --- a/KinectSensor/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// Les informations générales relatives à un assembly dépendent de -// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations -// associées à un assembly. -[assembly: AssemblyTitle("KinectSensor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("KinectSensor")] -[assembly: AssemblyCopyright("Copyright © 2024")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly -// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de -// COM, affectez la valeur true à l'attribut ComVisible sur ce type. -[assembly: ComVisible(false)] - -// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM -[assembly: Guid("cef75546-05f1-41a2-91ab-b4016a5436c4")] - -// Les informations de version pour un assembly se composent des quatre valeurs suivantes : -// -// Version principale -// Version secondaire -// Numéro de build -// Révision -// -// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut -// en utilisant '*', comme indiqué ci-dessous : -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/KinectSensorStreams/Converter/KinectStatusToColorConverter.cs b/KinectSensorStreams/Converter/KinectStatusToColorConverter.cs new file mode 100644 index 0000000..8d163d5 --- /dev/null +++ b/KinectSensorStreams/Converter/KinectStatusToColorConverter.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows.Media; + +namespace KinectSensorStreams.Converter +{ + /// + /// Converter permettant de convertir un bool (état du Kinect) en une couleur (Ellipse de la page principale) + /// + public class KinectStatusToColorConverter : IValueConverter + { + /// + /// Méthode pour convertir la valeur reçue + /// + /// Valeur à convertir (boolean) + /// Type de la valeur à retourner (BrushColor) + /// Paramètre (non utilisé ici) + /// Culture (non utilisée ici) + /// + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is bool status && targetType == typeof(Brush)) + { + return status ? new SolidColorBrush(Colors.Green) : new SolidColorBrush(Colors.Red); + } + + return new SolidColorBrush(Colors.Transparent); + } + + /// + /// Méthode pour convertir à l'inverse + /// + /// + /// + /// + /// + /// + /// + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/KinectSensorStreams/View/MainWindow.xaml b/KinectSensorStreams/View/MainWindow.xaml index a65eb0b..a29acfd 100644 --- a/KinectSensorStreams/View/MainWindow.xaml +++ b/KinectSensorStreams/View/MainWindow.xaml @@ -5,9 +5,14 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:toolkit="clr-namespace:CommunityToolkit.Mvvm.Input;assembly=CommunityToolkit.Mvvm" xmlns:local="clr-namespace:KinectSensorStreams.View" + xmlns:converter="clr-namespace:KinectSensorStreams.Converter" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800"> - + + + + + @@ -28,7 +33,7 @@ + /// Propriété liée à la commande appelée au démarrage de la page principale + /// public ICommand StartCommand { get; set; } + /// + /// Propriété liée à l'objet KinectManager + /// public KinectManager KinectManager { get; set; } #endregion #region Constructor + /// + /// Constructeur du ViewModel de la page principale + /// public MainWindowVM() { - EllipseColor = new SolidColorBrush(Colors.Green); KinectManager = new KinectManager(); StartCommand = new RelayCommand(Start); } @@ -38,10 +43,12 @@ namespace KinectSensorStreams.ViewModel #region Methods + /// + /// Méthode initialisée au lancement de la page principale pour savoir si le Kinect est disponible ou non + /// private void Start() { - KinectManager.kinectSensor.Open(); - EllipseColor = new SolidColorBrush(Colors.Green); + KinectManager.StartSensor(); } #endregion diff --git a/KinnectConnection/Class1.cs b/KinnectConnection/Class1.cs deleted file mode 100644 index 9555f99..0000000 --- a/KinnectConnection/Class1.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace KinnectConnection -{ - public class Class1 - { - } -} diff --git a/KinnectConnection/KinnectConnection.csproj b/KinnectConnection/KinnectConnection.csproj deleted file mode 100644 index 80b5043..0000000 --- a/KinnectConnection/KinnectConnection.csproj +++ /dev/null @@ -1,54 +0,0 @@ - - - - - Debug - AnyCPU - 570a503f-20af-47cd-809f-646d6de12d43 - Library - Properties - KinnectConnection - KinnectConnection - v4.8 - 512 - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - diff --git a/KinnectConnection/Properties/AssemblyInfo.cs b/KinnectConnection/Properties/AssemblyInfo.cs deleted file mode 100644 index 4a6d647..0000000 --- a/KinnectConnection/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// Les informations générales relatives à un assembly dépendent de -// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations -// associées à un assembly. -[assembly: AssemblyTitle("KinnectConnection")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("KinnectConnection")] -[assembly: AssemblyCopyright("Copyright © 2024")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly -// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de -// COM, affectez la valeur true à l'attribut ComVisible sur ce type. -[assembly: ComVisible(false)] - -// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM -[assembly: Guid("570a503f-20af-47cd-809f-646d6de12d43")] - -// Les informations de version pour un assembly se composent des quatre valeurs suivantes : -// -// Version principale -// Version secondaire -// Numéro de build -// Révision -// -// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut -// en utilisant '*', comme indiqué ci-dessous : -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")]