| | 1 | | using System; |
| | 2 | | using System.ComponentModel; |
| | 3 | | using System.Configuration; |
| | 4 | | using Newtonsoft.Json; |
| | 5 | |
|
| | 6 | | namespace ReFlex.Core.Common.Util |
| | 7 | | { |
| | 8 | | /// <inheritdoc /> |
| | 9 | | /// <summary> |
| | 10 | | /// </summary> |
| | 11 | | [TypeConverter(typeof(StreamParameterConverter))] |
| | 12 | | [SettingsSerializeAs(SettingsSerializeAs.String)] |
| | 13 | | [JsonConverter(typeof(DisableTypeConverterJsonConverter<StreamParameter>))] |
| | 14 | | public class StreamParameter : IEquatable<StreamParameter> |
| | 15 | | { |
| | 16 | | /// <summary> |
| | 17 | | /// The name to distinguish similar Parameters |
| | 18 | | /// </summary> |
| 0 | 19 | | public string Name { get; } |
| | 20 | |
|
| | 21 | | /// <summary> |
| | 22 | | /// The horizontal resolution |
| | 23 | | /// </summary> |
| 0 | 24 | | public int Width { get; } |
| | 25 | |
|
| | 26 | | /// <summary> |
| | 27 | | /// The vertical resolution |
| | 28 | | /// </summary> |
| 0 | 29 | | public int Height { get; } |
| | 30 | |
|
| | 31 | | /// <summary> |
| | 32 | | /// The frame rate |
| | 33 | | /// </summary> |
| 0 | 34 | | public int Framerate { get; } |
| | 35 | |
|
| 0 | 36 | | public DepthImageFormat Format { get; } |
| | 37 | |
|
| | 38 | | /// <summary> |
| | 39 | | /// Gets the description. |
| | 40 | | /// </summary> |
| | 41 | | /// <value> |
| | 42 | | /// The description. |
| | 43 | | /// </value> |
| | 44 | | [JsonIgnore] |
| 0 | 45 | | public string Description => ToString(); |
| | 46 | |
|
| | 47 | | /// <summary> |
| | 48 | | /// Initializes a new instance of the <see cref="StreamParameter"/> class. |
| | 49 | | /// </summary> |
| | 50 | | /// <param name="width">The horizontal resolution.</param> |
| | 51 | | /// <param name="height">The vertical resolution.</param> |
| | 52 | | /// <param name="framerate">The frame rate.</param> |
| | 53 | | /// <param name="name">(Optional) name, to distinguish different parameters with equal specification (e.g. for r |
| 0 | 54 | | public StreamParameter(int width, int height, int framerate, DepthImageFormat format = DepthImageFormat.Rgb24bpp |
| 0 | 55 | | { |
| 0 | 56 | | Name = name; |
| 0 | 57 | | Width = width; |
| 0 | 58 | | Height = height; |
| 0 | 59 | | Framerate = framerate; |
| 0 | 60 | | Format = format; |
| 0 | 61 | | Name = name; |
| 0 | 62 | | } |
| | 63 | |
|
| | 64 | | #region methods |
| | 65 | |
|
| | 66 | | /// <summary> |
| | 67 | | /// Gibt an, ob das aktuelle Objekt gleich einem anderen Objekt des gleichen Typs ist. |
| | 68 | | /// </summary> |
| | 69 | | /// <param name="other">Ein Objekt, das mit diesem Objekt verglichen werden soll.</param> |
| | 70 | | /// <returns> |
| | 71 | | /// <see langword="true" />, wenn das aktuelle Objekt gleich dem <paramref name="other" />-Parameter ist, ande |
| | 72 | | /// </returns> |
| | 73 | | /// <inheritdoc /> |
| | 74 | | public bool Equals(StreamParameter other) |
| 0 | 75 | | => other != null && other.Name == Name && Width == other.Width && Height == other.Height && Framerate == oth |
| | 76 | |
|
| | 77 | | /// <summary> |
| | 78 | | /// Returns a <see cref="string" /> that represents [this] instance. |
| | 79 | | /// </summary> |
| | 80 | | /// <returns> |
| | 81 | | /// A <see cref="string" /> that represents [this] instance. |
| | 82 | | /// </returns> |
| | 83 | | public override string ToString() |
| 0 | 84 | | { |
| 0 | 85 | | var desc = $"{Width} x {Height} x {Framerate}"; |
| 0 | 86 | | if (!string.IsNullOrWhiteSpace(Name)) |
| 0 | 87 | | desc = $"{Name}: ({desc})"; |
| | 88 | |
|
| 0 | 89 | | return desc; |
| 0 | 90 | | } |
| | 91 | |
|
| | 92 | | #endregion |
| | 93 | | } |
| | 94 | | } |