1 | // -----------------------------------------------------------------------
|
---|
2 | // <copyright file="SkeletonStreamMessage.cs" company="Microsoft">
|
---|
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
|
---|
4 | // </copyright>
|
---|
5 | // -----------------------------------------------------------------------
|
---|
6 |
|
---|
7 | namespace Microsoft.Samples.Kinect.Webserver.Sensor.Serialization
|
---|
8 | {
|
---|
9 | using System;
|
---|
10 | using System.Collections.Generic;
|
---|
11 | using System.Diagnostics.CodeAnalysis;
|
---|
12 |
|
---|
13 | using Microsoft.Kinect;
|
---|
14 |
|
---|
15 | /// <summary>
|
---|
16 | /// Serializable representation of an skeleton stream message to send to client.
|
---|
17 | /// </summary>
|
---|
18 | [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter",
|
---|
19 | Justification = "Lower case names allowed for JSON serialization.")]
|
---|
20 | public class SkeletonStreamMessage : StreamMessage
|
---|
21 | {
|
---|
22 | /// <summary>
|
---|
23 | /// Serializable skeleton array.
|
---|
24 | /// </summary>
|
---|
25 | [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "skeletons", Justification = "Lower case names allowed for JSON serialization.")]
|
---|
26 | [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Array properties allowed for JSON serialization.")]
|
---|
27 | public object[] skeletons { get; set; }
|
---|
28 |
|
---|
29 | /// <summary>
|
---|
30 | /// Update hand pointers from specified user info data.
|
---|
31 | /// </summary>
|
---|
32 | /// <param name="skeletons">
|
---|
33 | /// Enumeration of UserInfo structures.
|
---|
34 | /// </param>
|
---|
35 | public void UpdateSkeletons(Skeleton[] skeletons)
|
---|
36 | {
|
---|
37 | if (skeletons == null)
|
---|
38 | {
|
---|
39 | throw new ArgumentNullException("skeletons");
|
---|
40 | }
|
---|
41 |
|
---|
42 | if (this.skeletons == null || this.skeletons.Length != skeletons.Length)
|
---|
43 | {
|
---|
44 | this.skeletons = new object[skeletons.Length];
|
---|
45 | }
|
---|
46 |
|
---|
47 | for (int i = 0; i < this.skeletons.Length; i ++)
|
---|
48 | {
|
---|
49 | this.skeletons[i] = JsonSerializationExtensions.ExtractSerializableJsonData(skeletons[i]);
|
---|
50 | }
|
---|
51 | }
|
---|
52 | }
|
---|
53 | } |
---|