Example #1
0
        /// <summary>
        /// Inherited from <see cref="ISerializableByteArray"/>. Sets the current <see cref="SizeShort"/> object from the byte array.
        /// </summary>
        public void FromBytes(byte[] data)
        {
            if (data.Length != SizeInBytes)
            {
                throw new ArgumentException($"Parameter {nameof(data)} must be exactly {SizeInBytes} bytes.");
            }

            this = new SizeShort((short)(((uint)data[0]) << 8 | ((uint)data[1])),
                                 (short)(((uint)data[2]) << 8 | ((uint)data[3])));
        }
Example #2
0
 /// <summary>
 /// Adds two <see cref="SizeShort"/> values together and returns the result.
 /// </summary>
 /// <param name="sz1">The first <see cref="SizeShort"/> to add.</param>
 /// <param name="sz2">The second <see cref="SizeShort"/> to add.</param>
 /// <returns>The sum of the two <see cref="SizeShort"/> structures.</returns>
 public static SizeShort Add(SizeShort sz1, SizeShort sz2) => sz1 + sz2;
Example #3
0
 /// <summary>
 /// Subtracs two <see cref="SizeShort"/> values and returns the result.
 /// </summary>
 /// <param name="sz1">The intial <see cref="SizeShort"/>.</param>
 /// <param name="sz2">The <see cref="SizeShort"/> to subtract.</param>
 /// <returns>The difference between the two <see cref="SizeShort"/> structures.</returns>
 public static SizeShort Subtract(SizeShort sz1, SizeShort sz2) => sz1 - sz2;
Example #4
0
        /// <summary>
        /// Inherited from <see cref="ISerializableByteArray"/>. Sets the current <see cref="SizeShort"/> object from the byte array.
        /// </summary>
        public void FromBytes(byte[] data)
        {
            if (data.Length != SizeInBytes)
            {
                throw new ArgumentException($"Parameter {nameof(data)} must be exactly {SizeInBytes} bytes.");
            }

            this = new SizeShort((short)(((uint)data[0]) << 8 | ((uint)data[1])),
                                 (short)(((uint)data[2]) << 8 | ((uint)data[3])));
        }
Example #5
0
 /// <summary>
 /// Adds two <see cref="SizeShort"/> values together and returns the result.
 /// </summary>
 /// <param name="sz1">The first <see cref="SizeShort"/> to add.</param>
 /// <param name="sz2">The second <see cref="SizeShort"/> to add.</param>
 /// <returns>The sum of the two <see cref="SizeShort"/> structures.</returns>
 public static SizeShort Add(SizeShort sz1, SizeShort sz2) => sz1 + sz2;
Example #6
0
 /// <summary>
 /// Subtracs two <see cref="SizeShort"/> values and returns the result.
 /// </summary>
 /// <param name="sz1">The intial <see cref="SizeShort"/>.</param>
 /// <param name="sz2">The <see cref="SizeShort"/> to subtract.</param>
 /// <returns>The difference between the two <see cref="SizeShort"/> structures.</returns>
 public static SizeShort Subtract(SizeShort sz1, SizeShort sz2) => sz1 - sz2;
Example #7
0
 /// <summary>
 /// Offsets a <see cref="PointShort"/> by the specified <see cref="SizeShort"/>.
 /// </summary>
 /// <param name="pt">The <see cref="PointShort"/> that should be offset.</param>
 /// <param name="sz">The <see cref="SizeShort"/> to offset by.</param>
 /// <returns>A new <see cref="PointShort"/> that has been offset.</returns>
 public static PointShort Add(PointShort pt, SizeShort sz) => pt + sz;
Example #8
0
 /// <summary>
 /// Subtracts a <see cref="PointShort"/> by a <see cref="SizeShort"/>.
 /// </summary>
 /// <param name="pt">The <see cref="PointShort"/> to be subtracted from.</param>
 /// <param name="sz">The <see cref="SizeShort"/> to subtract.</param>
 /// <returns>A <see cref="PointShort"/> representing the difference.</returns>
 public static PointShort Subtract(PointShort pt, SizeShort sz) => pt - sz;
Example #9
0
 /// <summary>
 /// Offsets a <see cref="PointShort"/> by the specified <see cref="SizeShort"/>.
 /// </summary>
 /// <param name="pt">The <see cref="PointShort"/> that should be offset.</param>
 /// <param name="sz">The <see cref="SizeShort"/> to offset by.</param>
 /// <returns>A new <see cref="PointShort"/> that has been offset.</returns>
 public static PointShort Add(PointShort pt, SizeShort sz) => pt + sz;
Example #10
0
 /// <summary>
 /// Subtracts a <see cref="PointShort"/> by a <see cref="SizeShort"/>.
 /// </summary>
 /// <param name="pt">The <see cref="PointShort"/> to be subtracted from.</param>
 /// <param name="sz">The <see cref="SizeShort"/> to subtract.</param>
 /// <returns>A <see cref="PointShort"/> representing the difference.</returns>
 public static PointShort Subtract(PointShort pt, SizeShort sz) => pt - sz;