Guest User

Untitled

a guest
Jan 17th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.77 KB | None | 0 0
  1. public partial class MainWindow : Window, INotifyPropertyChanged
  2. {
  3. /// <summary>
  4. /// Radius of drawn hand circles: Radio de círculos de mano dibujados
  5.  
  6. /// </summary>
  7. private const double HandSize = 30;
  8.  
  9. /// <summary>
  10. /// Thickness of drawn joint lines: Espesor de las líneas de tracción
  11. /// </summary>
  12. private const double JointThickness = 4;
  13.  
  14. /// <summary>
  15. /// Thickness of clip edge rectangles:Espesor de los rectángulos del borde del clip
  16.  
  17. /// </summary>
  18. private const double ClipBoundsThickness = 10;
  19.  
  20. /// <summary>
  21. /// Constant for clamping Z values of camera space points from being negative:Constante para fijar los valores Z de los puntos de espacio de cámara de ser negativo
  22. /// </summary>
  23. private const float InferredZPositionClamp = 0.1f;
  24.  
  25. /// <summary>
  26. /// Brush used for drawing hands that are currently tracked as closed: Pincel utilizado para dibujar manos que actualmente se siguen como cerradas
  27. /// </summary>
  28. private readonly Brush handClosedBrush = new SolidColorBrush(Color.FromArgb(128, 255, 0, 0));
  29.  
  30. /// <summary>
  31. /// Brush used for drawing hands that are currently tracked as opened: Pincel utilizado para dibujar manos que actualmente se siguen como abiertas
  32. /// </summary>
  33. private readonly Brush handOpenBrush = new SolidColorBrush(Color.FromArgb(128, 0, 255, 0));
  34.  
  35. /// <summary>
  36. /// Brush used for drawing hands that are currently tracked as in lasso (pointer) position:Pincel utilizado para dibujar las manos que se rastrean actualmente como en la posición del lazo (puntero)
  37. /// </summary>
  38. private readonly Brush handLassoBrush = new SolidColorBrush(Color.FromArgb(128, 0, 0, 255));
  39.  
  40. /// <summary>
  41. /// Brush used for drawing joints that are currently tracked: Cepillo utilizado para el dibujo de las articulaciones que se siguen actualmente
  42. /// </summary>
  43. private readonly Brush trackedJointBrush = new SolidColorBrush(Color.FromArgb(255, 68, 192, 68));
  44.  
  45. /// <summary>
  46. /// Brush used for drawing joints that are currently inferred:Pincel utilizado para el dibujo de las articulaciones que actualmente se infiere
  47. /// </summary>
  48. private readonly Brush inferredJointBrush = Brushes.Yellow;
  49.  
  50. /// <summary>
  51. /// Pen used for drawing bones that are currently inferred
  52. /// </summary>
  53. private readonly Pen inferredBonePen = new Pen(Brushes.Gray, 1);
  54.  
  55. /// <summary>
  56. /// Drawing group for body rendering output: Grupo de dibujo para la salida de la representación corporal
  57.  
  58. /// </summary>
  59. private DrawingGroup drawingGroup;
  60.  
  61. /// <summary>
  62. /// Drawing image that we will display
  63. /// </summary>
  64. private DrawingImage imageSource;
  65.  
  66. /// <summary>
  67. /// Active Kinect sensor
  68. /// </summary>
  69. private KinectSensor kinectSensor = null;
  70.  
  71. /// <summary>
  72. /// Coordinate mapper to map one type of point to another: Mapeador de coordenadas para asignar un tipo de punto a otro
  73.  
  74. /// </summary>
  75. private CoordinateMapper coordinateMapper = null;
  76.  
  77. /// <summary>
  78. /// Reader for body frames
  79. /// </summary>
  80. private BodyFrameReader bodyFrameReader = null;
  81.  
  82. /// <summary>
  83. /// Array for the bodies: Array para los cuerpos
  84. /// </summary>
  85. private Body[] bodies = null;
  86.  
  87.  
  88. /// <summary>
  89. /// definition of bones
  90. /// </summary>
  91. private List<Tuple<JointType, JointType>> bones;
  92.  
  93. //Dani
  94. // public List<>
  95.  
  96. //Declaracion de una matriz bidimensional
  97. public float [,] MatrizCoordBodyGlobales= new float[2,2];
  98. //float[][,][,] ArraydeMatrices;
  99. //Array rectangular dentro de otro array
  100. public float[][,] ArraydeMatrices = new float[10][,];
  101. public int i =0;
  102. public int j = 0;
  103. // Me da error este tipo de arrays, MIRAR ESTA PARTE, TENEMOS QUE CONSEGUIR METER LA MATRIZ EN UN HUECO DE UN ARRAY
  104.  
  105.  
  106.  
  107. /// <summary>
  108. /// Width of display (depth space)
  109. /// </summary>
  110. private int displayWidth;
  111.  
  112. /// <summary>
  113. /// Height of display (depth space)
  114. /// </summary>
  115. private int displayHeight;
  116.  
  117. /// <summary>
  118. /// List of colors for each body tracked
  119. /// </summary>
  120. private List<Pen> bodyColors;
  121.  
  122. /// <summary>
  123. /// Current status text to display
  124. /// </summary>
  125. private string statusText = null;
  126.  
  127. //Hecho por Dani
  128. //private WriteableBitmap colorBitmap = null;
  129. // private ColorFrameReader colorFrameReader = null;
  130.  
  131.  
  132. /// <summary>
  133. /// Initializes a new instance of the MainWindow class.
  134. /// </summary>
  135. public MainWindow()
  136. {
  137.  
  138. // one sensor is currently supported
  139. this.kinectSensor = KinectSensor.GetDefault();
  140.  
  141. // get the coordinate mapper
  142. this.coordinateMapper = this.kinectSensor.CoordinateMapper;
  143.  
  144. // get the depth (display) extents
  145. //Dani
  146. FrameDescription frameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
  147.  
  148.  
  149. // get size of joint space : Obtener el tamaño del espacio de articulación
  150.  
  151. this.displayWidth = frameDescription.Width;
  152. this.displayHeight = frameDescription.Height;
  153.  
  154.  
  155. // open the reader for the body frames : Abra el lector para los marcos del cuerpo
  156.  
  157. this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();
  158.  
  159. // a bone defined as a line between two joints: Un hueso definido como una línea entre dos
  160. this.bones = new List<Tuple<JointType, JointType>>();
  161.  
  162. // Torso : Añade las distintas lineas de union entre dos partes de una zona concreta del cuerpo, se trata de dibujar el Esqueleto del cuerpo
  163. this.bones.Add(new Tuple<JointType, JointType>(JointType.Head, JointType.Neck));
  164. this.bones.Add(new Tuple<JointType, JointType>(JointType.Neck, JointType.SpineShoulder));
  165. this.bones.Add(new Tuple<JointType, JointType>(JointType.SpineShoulder, JointType.SpineMid));
  166. this.bones.Add(new Tuple<JointType, JointType>(JointType.SpineMid, JointType.SpineBase));
  167. this.bones.Add(new Tuple<JointType, JointType>(JointType.SpineShoulder, JointType.ShoulderRight));
  168. this.bones.Add(new Tuple<JointType, JointType>(JointType.SpineShoulder, JointType.ShoulderLeft));
  169. this.bones.Add(new Tuple<JointType, JointType>(JointType.SpineBase, JointType.HipRight));
  170. this.bones.Add(new Tuple<JointType, JointType>(JointType.SpineBase, JointType.HipLeft));
  171.  
  172.  
  173. // Right Arm
  174. this.bones.Add(new Tuple<JointType, JointType>(JointType.ShoulderRight, JointType.ElbowRight));
  175. this.bones.Add(new Tuple<JointType, JointType>(JointType.ElbowRight, JointType.WristRight));
  176. this.bones.Add(new Tuple<JointType, JointType>(JointType.WristRight, JointType.HandRight));
  177. this.bones.Add(new Tuple<JointType, JointType>(JointType.HandRight, JointType.HandTipRight));
  178. this.bones.Add(new Tuple<JointType, JointType>(JointType.WristRight, JointType.ThumbRight));
  179.  
  180. // Left Arm
  181. this.bones.Add(new Tuple<JointType, JointType>(JointType.ShoulderLeft, JointType.ElbowLeft));
  182. this.bones.Add(new Tuple<JointType, JointType>(JointType.ElbowLeft, JointType.WristLeft));
  183. this.bones.Add(new Tuple<JointType, JointType>(JointType.WristLeft, JointType.HandLeft));
  184. this.bones.Add(new Tuple<JointType, JointType>(JointType.HandLeft, JointType.HandTipLeft));
  185. this.bones.Add(new Tuple<JointType, JointType>(JointType.WristLeft, JointType.ThumbLeft));
  186.  
  187. // Right Leg
  188. this.bones.Add(new Tuple<JointType, JointType>(JointType.HipRight, JointType.KneeRight));
  189. this.bones.Add(new Tuple<JointType, JointType>(JointType.KneeRight, JointType.AnkleRight));
  190. this.bones.Add(new Tuple<JointType, JointType>(JointType.AnkleRight, JointType.FootRight));
  191.  
  192. // Left Leg
  193. this.bones.Add(new Tuple<JointType, JointType>(JointType.HipLeft, JointType.KneeLeft));
  194. this.bones.Add(new Tuple<JointType, JointType>(JointType.KneeLeft, JointType.AnkleLeft));
  195. this.bones.Add(new Tuple<JointType, JointType>(JointType.AnkleLeft, JointType.FootLeft));
  196.  
  197. // populate body colors, one for each BodyIndex
  198. this.bodyColors = new List<Pen>();
  199.  
  200. this.bodyColors.Add(new Pen(Brushes.Red, 6));
  201. this.bodyColors.Add(new Pen(Brushes.Orange, 6));
  202. this.bodyColors.Add(new Pen(Brushes.Green, 6));
  203. this.bodyColors.Add(new Pen(Brushes.Blue, 6));
  204. this.bodyColors.Add(new Pen(Brushes.Indigo, 6));
  205. this.bodyColors.Add(new Pen(Brushes.Violet, 6));
  206.  
  207.  
  208. // set IsAvailableChanged event notifier: En caso de algun cambio, refrescar los datos de marco
  209. this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;
  210.  
  211. // open the sensor
  212. this.kinectSensor.Open();
  213.  
  214. // set the status text
  215. this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText
  216. : Properties.Resources.NoSensorStatusText;
  217.  
  218. // Create the drawing group we'll use for drawing : Crear un grupo de dibujo
  219. this.drawingGroup = new DrawingGroup();
  220.  
  221. // Create an image source that we can use in our image control :Crear una fuente de imagen que podamos usar en nuestro control de imagen
  222. this.imageSource = new DrawingImage(this.drawingGroup);
  223.  
  224. // use the window object as the view model in this simple example
  225. this.DataContext = this;
  226.  
  227.  
  228. // initialize the components (controls) of the window
  229. this.InitializeComponent();
  230.  
  231.  
  232. }
  233.  
  234. /// <summary>
  235. /// INotifyPropertyChangedPropertyChanged event to allow window controls to bind to changeable data: Evento para permitir que los controles de ventana se enlacen a datos cambiables
  236. /// </summary>
  237. public event PropertyChangedEventHandler PropertyChanged;
  238.  
  239. /// <summary>
  240. /// Gets the bitmap to display
  241. /// </summary>
  242. public ImageSource ImageSource
  243. {
  244. get
  245. {
  246. return this.imageSource;
  247. }
  248. }
  249.  
  250. /// <summary>
  251. /// Gets or sets the current status text to display
  252. /// </summary>
  253. public string StatusText
  254. {
  255. get
  256. {
  257. return this.statusText;
  258. }
  259.  
  260. set
  261. {
  262. if (this.statusText != value)
  263. {
  264. this.statusText = value;
  265.  
  266. // notify any bound elements that the text has changed
  267. if (this.PropertyChanged != null)
  268. {
  269. this.PropertyChanged(this, new PropertyChangedEventArgs("StatusText"));
  270. }
  271. }
  272. }
  273. }
  274.  
  275. /// <summary>
  276. /// Execute start up tasks :Ejecutar tareas de inicio
  277. /// </summary>
  278. /// <param name="sender">object sending the event</param>
  279. /// <param name="e">event arguments</param>
  280. private void MainWindow_Loaded(object sender, RoutedEventArgs e)
  281. {
  282. if (this.bodyFrameReader != null)
  283. {
  284. this.bodyFrameReader.FrameArrived += this.Reader_FrameArrived;
  285.  
  286.  
  287. }
  288. }
  289.  
  290. /// <summary>
  291. /// Execute shutdown tasks
  292. /// </summary>
  293. /// <param name="sender">object sending the event</param>
  294. /// <param name="e">event arguments</param>
  295. private void MainWindow_Closing(object sender, CancelEventArgs e)
  296. {
  297. if (this.bodyFrameReader != null)
  298. {
  299. // BodyFrameReader is IDisposable
  300. this.bodyFrameReader.Dispose();
  301. this.bodyFrameReader = null;
  302. }
  303.  
  304. if (this.kinectSensor != null)
  305. {
  306. this.kinectSensor.Close();
  307. this.kinectSensor = null;
  308. }
  309. }
  310.  
  311. /// <summary>
  312. /// Handles the body frame data arriving from the sensor
  313. /// </summary>
  314. /// <param name="sender">object sending the event</param>
  315. /// <param name="e">event arguments</param>
  316. private void Reader_FrameArrived(object sender, BodyFrameArrivedEventArgs e)
  317. {
  318. bool dataReceived = false;
  319.  
  320. using (BodyFrame bodyFrame = e.FrameReference.AcquireFrame())
  321. {
  322. if (bodyFrame != null)
  323. {
  324. if (this.bodies == null)
  325. {
  326. this.bodies = new Body[bodyFrame.BodyCount];
  327. }
  328.  
  329. // The first time GetAndRefreshBodyData is called, Kinect will allocate each Body in the array.
  330. // As long as those body objects are not disposed and not set to null in the array,
  331. // those body objects will be re-used.
  332. bodyFrame.GetAndRefreshBodyData(this.bodies);
  333. dataReceived = true;
  334. }
  335. }
  336.  
  337.  
  338. if (dataReceived)
  339. {
  340. using (DrawingContext dc = this.drawingGroup.Open())
  341. {
  342.  
  343. // Draw a transparent background to set the render size: Se trata de realizar un fondo , en este caso negro
  344. dc.DrawRectangle(Brushes.Black, null, new Rect(0.0, 0.0, this.displayWidth, this.displayHeight));
  345.  
  346.  
  347. int penIndex = 0;
  348. foreach (Body body in this.bodies)
  349. {
  350. Pen drawPen = this.bodyColors[penIndex++];
  351. // Dani ICloneable
  352.  
  353.  
  354.  
  355. if (body.IsTracked)
  356. {
  357. this.DrawClippedEdges(body, dc);
  358.  
  359. IReadOnlyDictionary<JointType, Joint> joints = body.Joints;
  360. // Console.WriteLine("HandRight" + JointType.HandRight);
  361.  
  362. // convert the joint points to depth (display) space
  363. Dictionary<JointType, Point> jointPoints = new Dictionary<JointType, Point>();
  364.  
  365. foreach (JointType jointType in joints.Keys)
  366. {
  367. // sometimes the depth(Z) of an inferred joint may show as negative
  368. // clamp down to 0.1f to prevent coordinatemapper from returning (-Infinity, -Infinity)
  369. CameraSpacePoint position = joints[jointType].Position;
  370. if (position.Z < 0)
  371. {
  372. position.Z = InferredZPositionClamp;
  373. }
  374.  
  375. DepthSpacePoint depthSpacePoint = this.coordinateMapper.MapCameraPointToDepthSpace(position);
  376. jointPoints[jointType] = new Point(depthSpacePoint.X, depthSpacePoint.Y);
  377. }
  378.  
  379. this.DrawBody(joints, jointPoints, dc, drawPen);
  380.  
  381. this.DrawHand(body.HandLeftState, jointPoints[JointType.HandLeft], dc);
  382. this.DrawHand(body.HandRightState, jointPoints[JointType.HandRight], dc);
  383.  
  384. //SE TRATA DE SACAR LOS PUNTOS X E Y DE LA MANO DERECHA
  385. // Distancias sacadas en metros
  386.  
  387. //Mano Derecha
  388. VariablesGlobales.HandRightX = body.Joints[JointType.HandRight].Position.X;
  389. VariablesGlobales.HandRightY = body.Joints[JointType.HandRight].Position.Y;
  390. VariablesGlobales.HandRightZ = body.Joints[JointType.HandRight].Position.Z;
  391. //ManoIzquierda
  392. VariablesGlobales.HandLeftX = body.Joints[JointType.HandLeft].Position.X;
  393. VariablesGlobales.HandLeftY = body.Joints[JointType.HandLeft].Position.Y;
  394. VariablesGlobales.HandLeftZ = body.Joints[JointType.HandLeft].Position.Z;
  395.  
  396.  
  397. //Matriz Rectangular multidimensional
  398. // float[,] MatrizCoordBodyGlobales = { { body.Joints[JointType.HandLeft].Position.X, body.Joints[JointType.HandLeft].Position.Y },
  399. // { body.Joints[JointType.HandRight].Position.X, body.Joints[JointType.HandRight].Position.Y },
  400. //{ body.Joints[JointType.Head].Position.X, body.Joints[JointType.Head].Position.Y },
  401. //{ body.Joints[JointType.SpineMid].Position.X, body.Joints[JointType.SpineMid].Position.Y }};
  402. MatrizCoordBodyGlobales[0, 0] = VariablesGlobales.HandRightX;
  403. MatrizCoordBodyGlobales[0, 1] = VariablesGlobales.HandRightY;
  404. MatrizCoordBodyGlobales[1, 0] = VariablesGlobales.HandLeftX;
  405. MatrizCoordBodyGlobales[1, 1] = VariablesGlobales.HandLeftY;
  406.  
  407. // ArraydeMatrices[0] = MatrizCoordBodyGlobales;
  408. for (j = 0; j <= 200;j++)
  409. {
  410. if(j== 200 )
  411. {
  412. ArraydeMatrices[i] = MatrizCoordBodyGlobales;
  413. j = 0;
  414. i++;
  415. }
  416. }
  417.  
  418.  
  419.  
  420. // Probar sacar ese punto de coordenada y almacenarlo en una variable.
  421. // Se depura , metiendo ventanas-resultados, aqui se pone el punto de parada para depurar
  422.  
  423.  
  424. // mirar tambien como guardar essos parametros en archivos
  425.  
  426.  
  427. }
  428. }
  429.  
  430. // prevent drawing outside of our render area: Evitar el dibujo fuera de nuestro área de de devolucion
  431. this.drawingGroup.ClipGeometry = new RectangleGeometry(new Rect(0.0, 0.0, this.displayWidth, this.displayHeight));
  432. }
  433. }
  434. }
  435.  
  436.  
  437.  
  438. /// <summary>
  439. /// Draws a body
  440. /// </summary>
  441. /// <param name="joints">joints to draw</param>
  442. /// <param name="jointPoints">translated positions of joints to draw</param>
  443. /// <param name="drawingContext">drawing context to draw to</param>
  444. /// <param name="drawingPen">specifies color to draw a specific body</param>
  445. private void DrawBody(IReadOnlyDictionary<JointType, Joint> joints, IDictionary<JointType, Point> jointPoints, DrawingContext drawingContext, Pen drawingPen)
  446. {
  447. // Draw the bones
  448. foreach (var bone in this.bones)
  449. {
  450. this.DrawBone(joints, jointPoints, bone.Item1, bone.Item2, drawingContext, drawingPen);
  451.  
  452. }
  453.  
  454. // Draw the joints: Dibujar las articulaciones
  455. foreach (JointType jointType in joints.Keys)
  456. {
  457. Brush drawBrush = null;
  458.  
  459. TrackingState trackingState = joints[jointType].TrackingState;
  460.  
  461. if (trackingState == TrackingState.Tracked)
  462. {
  463. drawBrush = this.trackedJointBrush;
  464. }
  465. else if (trackingState == TrackingState.Inferred)
  466. {
  467. drawBrush = this.inferredJointBrush;
  468. }
  469.  
  470. if (drawBrush != null)
  471. {
  472. drawingContext.DrawEllipse(drawBrush, null, jointPoints[jointType], JointThickness, JointThickness);
  473. }
  474. }
  475. }
  476.  
  477. /// <summary>
  478. /// Draws one bone of a body (joint to joint)
  479. /// </summary>
  480. /// <param name="joints">joints to draw</param>
  481. /// <param name="jointPoints">translated positions of joints to draw</param>
  482. /// <param name="jointType0">first joint of bone to draw</param>
  483. /// <param name="jointType1">second joint of bone to draw</param>
  484. /// <param name="drawingContext">drawing context to draw to</param>
  485. /// /// <param name="drawingPen">specifies color to draw a specific bone</param>
  486. private void DrawBone(IReadOnlyDictionary<JointType, Joint> joints, IDictionary<JointType, Point> jointPoints, JointType jointType0, JointType jointType1, DrawingContext drawingContext, Pen drawingPen)
  487. {
  488. Joint joint0 = joints[jointType0];
  489. Joint joint1 = joints[jointType1];
  490.  
  491. // If we can't find either of these joints, exit
  492. if (joint0.TrackingState == TrackingState.NotTracked || joint1.TrackingState == TrackingState.NotTracked)
  493. {
  494. return;
  495. }
  496.  
  497. // We assume all drawn bones are inferred unless BOTH joints are tracked
  498. Pen drawPen = this.inferredBonePen;
  499. if ((joint0.TrackingState == TrackingState.Tracked) && (joint1.TrackingState == TrackingState.Tracked))
  500. {
  501. drawPen = drawingPen;
  502. }
  503.  
  504. drawingContext.DrawLine(drawPen, jointPoints[jointType0], jointPoints[jointType1]);
  505. }
  506.  
  507. /// <summary>
  508. /// Draws a hand symbol if the hand is tracked: red circle = closed, green circle = opened; blue circle = lasso ( lazo)
  509. /// </summary>
  510. /// <param name="handState">state of the hand</param>
  511. /// <param name="handPosition">position of the hand</param>
  512. /// <param name="drawingContext">drawing context to draw to</param>
  513. private void DrawHand(HandState handState, Point handPosition, DrawingContext drawingContext)
  514. {
  515. switch (handState)
  516. {
  517. case HandState.Closed:
  518. drawingContext.DrawEllipse(this.handClosedBrush, null, handPosition, HandSize, HandSize);
  519. break;
  520.  
  521.  
  522. case HandState.Open:
  523. drawingContext.DrawEllipse(this.handOpenBrush, null, handPosition, HandSize, HandSize);
  524. break;
  525.  
  526. case HandState.Lasso:
  527. drawingContext.DrawEllipse(this.handLassoBrush, null, handPosition, HandSize, HandSize);
  528. break;
  529. }
  530. }
  531.  
  532. /// <summary>
  533. /// Draws indicators to show which edges are clipping body data
  534. /// Dibuja indicadores para mostrar qué bordes están recortando los datos del cuerpo
  535. /// </summary>
  536. /// <param name="body">body to draw clipping information for</param>
  537. /// <param name="drawingContext">drawing context to draw to</param>
  538. private void DrawClippedEdges(Body body, DrawingContext drawingContext)
  539. {
  540. FrameEdges clippedEdges = body.ClippedEdges;
  541.  
  542. if (clippedEdges.HasFlag(FrameEdges.Bottom))
  543. {
  544. drawingContext.DrawRectangle(Brushes.Red, null, new Rect(0, this.displayHeight - ClipBoundsThickness, this.displayWidth, ClipBoundsThickness));
  545. }
  546.  
  547. if (clippedEdges.HasFlag(FrameEdges.Top))
  548. {
  549. drawingContext.DrawRectangle(Brushes.Red, null, new Rect(0, 0, this.displayWidth, ClipBoundsThickness));
  550. }
  551.  
  552. if (clippedEdges.HasFlag(FrameEdges.Left))
  553. {
  554. drawingContext.DrawRectangle(Brushes.Red, null, new Rect(0, 0, ClipBoundsThickness, this.displayHeight));
  555. }
  556.  
  557. if (clippedEdges.HasFlag(FrameEdges.Right))
  558. {
  559. drawingContext.DrawRectangle(Brushes.Red, null, new Rect(this.displayWidth - ClipBoundsThickness, 0, ClipBoundsThickness, this.displayHeight));
  560. }
  561. }
  562.  
  563. /// <summary>
  564. /// Handles the event which the sensor becomes unavailable (E.g. paused, closed, unplugged).
  565. /// </summary>
  566. /// <param name="sender">object sending the event</param>
  567. /// <param name="e">event arguments</param>
  568. private void Sensor_IsAvailableChanged(object sender, IsAvailableChangedEventArgs e)
  569. {
  570. // on failure, set the status text
  571. this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText
  572. : Properties.Resources.SensorNotAvailableStatusText;
  573. }
  574. }
Add Comment
Please, Sign In to add comment