using JeuHoy_WPF_Natif.Presenter; using JeuHoy_WPF_Natif.View; using Microsoft.Kinect; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace JeuHoy_WPF.View { /// /// Auteur: Hugo St-Louis /// Description: Permet de faire l'entrainement des différentes figures de danse. /// Date: 2023-04-17 /// public partial class wEntrainement : Window, IwEntrainement { private Dictionary _dicImgFigure = new Dictionary(); private JouerSon _son = new JouerSon(); private int _positionEnCours = 1; private PresentateurWEntrainement _presentateur; public event EventHandler EntrainementEvt; public Image Image { get => picKinect; set => picKinect = value; } public string Console { get => txtConsole.Text; set => txtConsole.Text = value; } public Canvas Canvas { get => pDessinSquelette; set => pDessinSquelette = value; } /// /// Constructeur /// public wEntrainement() { InitializeComponent(); _presentateur = new PresentateurWEntrainement(this); for (int x = 1; x <= CstApplication.NBFIGURE; ++x) if (File.Exists("HoyContent/fig" + x.ToString() + ".png")) _dicImgFigure.Add("fig" + x, new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"./HoyContent/fig" + x.ToString() + ".png", UriKind.Absolute))); ChargerFigure(); _son.JouerSonAsync(@"./HoyContent/hoy.wav"); } /// /// Charger la figure de danse en cours. /// private void ChargerFigure() { BitmapImage imgValue; bool bResultat; if (_positionEnCours > CstApplication.NBFIGURE) _positionEnCours = 1; if (_positionEnCours < 1) _positionEnCours = CstApplication.NBFIGURE; lblFigureEnCours.Content = _positionEnCours.ToString(); bResultat = _dicImgFigure.TryGetValue("fig" + _positionEnCours, out imgValue); if (bResultat == true) picPositionAFaire.Source = imgValue; } /// /// Fermeture de la fenêtre. /// /// /// private void picRetour_Click(object sender, EventArgs e) { this.Close(); } /// /// Change le curseur lorsque le curseur est sur l'image /// /// /// private void picRetour_MouseHover(object sender, EventArgs e) { this.Cursor = Cursors.Hand; } /// /// Change le curseur lorsque le curseur est sur l'image /// /// /// private void picRetour_MouseLeave(object sender, EventArgs e) { this.Cursor = Cursors.Arrow; } /// /// Lorsqu'on appuie sur le bouton suivant ou précédent, modifier la figure en conséquence. /// /// /// private void btnClickChangerFigure_Click(object sender, RoutedEventArgs e) { Control bouton = (Control)sender; if (bouton.Name == "btnSuivant") _positionEnCours++; else if (bouton.Name == "btnPrecedent") _positionEnCours--; ChargerFigure(); } /// /// Apprentissage avec la position obtenu à partir de la Kinect versus l'image affichée. /// /// /// private void btnApprendre_Click(object sender, RoutedEventArgs e) { //Ajouter du code ICI EntrainementEvt(this, e); } public int GetPositionEnCour() { return _positionEnCours; } } }