/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Generated/Int32Rect.cs

https://github.com/dotnet/wpf · C# · 438 lines · 189 code · 81 blank · 168 comment · 15 complexity · cbf013e5c1ae638167bc29b03e380dfe MD5 · raw file

  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. //
  5. //
  6. // This file was generated, please do not edit it directly.
  7. //
  8. // Please see MilCodeGen.html for more information.
  9. //
  10. using MS.Internal;
  11. using MS.Internal.WindowsBase;
  12. using System;
  13. using System.Collections;
  14. using System.ComponentModel;
  15. using System.Diagnostics;
  16. using System.Globalization;
  17. using System.Reflection;
  18. using System.Runtime.InteropServices;
  19. using System.ComponentModel.Design.Serialization;
  20. using System.Windows.Markup;
  21. using System.Windows.Converters;
  22. using System.Windows;
  23. // These types are aliased to match the unamanaged names used in interop
  24. using BOOL = System.UInt32;
  25. using WORD = System.UInt16;
  26. using Float = System.Single;
  27. namespace System.Windows
  28. {
  29. [Serializable]
  30. [TypeConverter(typeof(Int32RectConverter))]
  31. [ValueSerializer(typeof(Int32RectValueSerializer))] // Used by MarkupWriter
  32. partial struct Int32Rect : IFormattable
  33. {
  34. //------------------------------------------------------
  35. //
  36. // Public Methods
  37. //
  38. //------------------------------------------------------
  39. #region Public Methods
  40. /// <summary>
  41. /// Compares two Int32Rect instances for exact equality.
  42. /// Note that double values can acquire error when operated upon, such that
  43. /// an exact comparison between two values which are logically equal may fail.
  44. /// Furthermore, using this equality operator, Double.NaN is not equal to itself.
  45. /// </summary>
  46. /// <returns>
  47. /// bool - true if the two Int32Rect instances are exactly equal, false otherwise
  48. /// </returns>
  49. /// <param name='int32Rect1'>The first Int32Rect to compare</param>
  50. /// <param name='int32Rect2'>The second Int32Rect to compare</param>
  51. public static bool operator == (Int32Rect int32Rect1, Int32Rect int32Rect2)
  52. {
  53. return int32Rect1.X == int32Rect2.X &&
  54. int32Rect1.Y == int32Rect2.Y &&
  55. int32Rect1.Width == int32Rect2.Width &&
  56. int32Rect1.Height == int32Rect2.Height;
  57. }
  58. /// <summary>
  59. /// Compares two Int32Rect instances for exact inequality.
  60. /// Note that double values can acquire error when operated upon, such that
  61. /// an exact comparison between two values which are logically equal may fail.
  62. /// Furthermore, using this equality operator, Double.NaN is not equal to itself.
  63. /// </summary>
  64. /// <returns>
  65. /// bool - true if the two Int32Rect instances are exactly unequal, false otherwise
  66. /// </returns>
  67. /// <param name='int32Rect1'>The first Int32Rect to compare</param>
  68. /// <param name='int32Rect2'>The second Int32Rect to compare</param>
  69. public static bool operator != (Int32Rect int32Rect1, Int32Rect int32Rect2)
  70. {
  71. return !(int32Rect1 == int32Rect2);
  72. }
  73. /// <summary>
  74. /// Compares two Int32Rect instances for object equality. In this equality
  75. /// Double.NaN is equal to itself, unlike in numeric equality.
  76. /// Note that double values can acquire error when operated upon, such that
  77. /// an exact comparison between two values which
  78. /// are logically equal may fail.
  79. /// </summary>
  80. /// <returns>
  81. /// bool - true if the two Int32Rect instances are exactly equal, false otherwise
  82. /// </returns>
  83. /// <param name='int32Rect1'>The first Int32Rect to compare</param>
  84. /// <param name='int32Rect2'>The second Int32Rect to compare</param>
  85. public static bool Equals (Int32Rect int32Rect1, Int32Rect int32Rect2)
  86. {
  87. if (int32Rect1.IsEmpty)
  88. {
  89. return int32Rect2.IsEmpty;
  90. }
  91. else
  92. {
  93. return int32Rect1.X.Equals(int32Rect2.X) &&
  94. int32Rect1.Y.Equals(int32Rect2.Y) &&
  95. int32Rect1.Width.Equals(int32Rect2.Width) &&
  96. int32Rect1.Height.Equals(int32Rect2.Height);
  97. }
  98. }
  99. /// <summary>
  100. /// Equals - compares this Int32Rect with the passed in object. In this equality
  101. /// Double.NaN is equal to itself, unlike in numeric equality.
  102. /// Note that double values can acquire error when operated upon, such that
  103. /// an exact comparison between two values which
  104. /// are logically equal may fail.
  105. /// </summary>
  106. /// <returns>
  107. /// bool - true if the object is an instance of Int32Rect and if it's equal to "this".
  108. /// </returns>
  109. /// <param name='o'>The object to compare to "this"</param>
  110. public override bool Equals(object o)
  111. {
  112. if ((null == o) || !(o is Int32Rect))
  113. {
  114. return false;
  115. }
  116. Int32Rect value = (Int32Rect)o;
  117. return Int32Rect.Equals(this,value);
  118. }
  119. /// <summary>
  120. /// Equals - compares this Int32Rect with the passed in object. In this equality
  121. /// Double.NaN is equal to itself, unlike in numeric equality.
  122. /// Note that double values can acquire error when operated upon, such that
  123. /// an exact comparison between two values which
  124. /// are logically equal may fail.
  125. /// </summary>
  126. /// <returns>
  127. /// bool - true if "value" is equal to "this".
  128. /// </returns>
  129. /// <param name='value'>The Int32Rect to compare to "this"</param>
  130. public bool Equals(Int32Rect value)
  131. {
  132. return Int32Rect.Equals(this, value);
  133. }
  134. /// <summary>
  135. /// Returns the HashCode for this Int32Rect
  136. /// </summary>
  137. /// <returns>
  138. /// int - the HashCode for this Int32Rect
  139. /// </returns>
  140. public override int GetHashCode()
  141. {
  142. if (IsEmpty)
  143. {
  144. return 0;
  145. }
  146. else
  147. {
  148. // Perform field-by-field XOR of HashCodes
  149. return X.GetHashCode() ^
  150. Y.GetHashCode() ^
  151. Width.GetHashCode() ^
  152. Height.GetHashCode();
  153. }
  154. }
  155. /// <summary>
  156. /// Parse - returns an instance converted from the provided string using
  157. /// the culture "en-US"
  158. /// <param name="source"> string with Int32Rect data </param>
  159. /// </summary>
  160. public static Int32Rect Parse(string source)
  161. {
  162. IFormatProvider formatProvider = System.Windows.Markup.TypeConverterHelper.InvariantEnglishUS;
  163. TokenizerHelper th = new TokenizerHelper(source, formatProvider);
  164. Int32Rect value;
  165. String firstToken = th.NextTokenRequired();
  166. // The token will already have had whitespace trimmed so we can do a
  167. // simple string compare.
  168. if (firstToken == "Empty")
  169. {
  170. value = Empty;
  171. }
  172. else
  173. {
  174. value = new Int32Rect(
  175. Convert.ToInt32(firstToken, formatProvider),
  176. Convert.ToInt32(th.NextTokenRequired(), formatProvider),
  177. Convert.ToInt32(th.NextTokenRequired(), formatProvider),
  178. Convert.ToInt32(th.NextTokenRequired(), formatProvider));
  179. }
  180. // There should be no more tokens in this string.
  181. th.LastTokenRequired();
  182. return value;
  183. }
  184. #endregion Public Methods
  185. //------------------------------------------------------
  186. //
  187. // Public Properties
  188. //
  189. //------------------------------------------------------
  190. #region Public Properties
  191. /// <summary>
  192. /// X - int. Default value is 0.
  193. /// </summary>
  194. public int X
  195. {
  196. get
  197. {
  198. return _x;
  199. }
  200. set
  201. {
  202. _x = value;
  203. }
  204. }
  205. /// <summary>
  206. /// Y - int. Default value is 0.
  207. /// </summary>
  208. public int Y
  209. {
  210. get
  211. {
  212. return _y;
  213. }
  214. set
  215. {
  216. _y = value;
  217. }
  218. }
  219. /// <summary>
  220. /// Width - int. Default value is 0.
  221. /// </summary>
  222. public int Width
  223. {
  224. get
  225. {
  226. return _width;
  227. }
  228. set
  229. {
  230. _width = value;
  231. }
  232. }
  233. /// <summary>
  234. /// Height - int. Default value is 0.
  235. /// </summary>
  236. public int Height
  237. {
  238. get
  239. {
  240. return _height;
  241. }
  242. set
  243. {
  244. _height = value;
  245. }
  246. }
  247. #endregion Public Properties
  248. //------------------------------------------------------
  249. //
  250. // Protected Methods
  251. //
  252. //------------------------------------------------------
  253. #region Protected Methods
  254. #endregion ProtectedMethods
  255. //------------------------------------------------------
  256. //
  257. // Internal Methods
  258. //
  259. //------------------------------------------------------
  260. #region Internal Methods
  261. #endregion Internal Methods
  262. //------------------------------------------------------
  263. //
  264. // Internal Properties
  265. //
  266. //------------------------------------------------------
  267. #region Internal Properties
  268. /// <summary>
  269. /// Creates a string representation of this object based on the current culture.
  270. /// </summary>
  271. /// <returns>
  272. /// A string representation of this object.
  273. /// </returns>
  274. public override string ToString()
  275. {
  276. // Delegate to the internal method which implements all ToString calls.
  277. return ConvertToString(null /* format string */, null /* format provider */);
  278. }
  279. /// <summary>
  280. /// Creates a string representation of this object based on the IFormatProvider
  281. /// passed in. If the provider is null, the CurrentCulture is used.
  282. /// </summary>
  283. /// <returns>
  284. /// A string representation of this object.
  285. /// </returns>
  286. public string ToString(IFormatProvider provider)
  287. {
  288. // Delegate to the internal method which implements all ToString calls.
  289. return ConvertToString(null /* format string */, provider);
  290. }
  291. /// <summary>
  292. /// Creates a string representation of this object based on the format string
  293. /// and IFormatProvider passed in.
  294. /// If the provider is null, the CurrentCulture is used.
  295. /// See the documentation for IFormattable for more information.
  296. /// </summary>
  297. /// <returns>
  298. /// A string representation of this object.
  299. /// </returns>
  300. string IFormattable.ToString(string format, IFormatProvider provider)
  301. {
  302. // Delegate to the internal method which implements all ToString calls.
  303. return ConvertToString(format, provider);
  304. }
  305. /// <summary>
  306. /// Creates a string representation of this object based on the format string
  307. /// and IFormatProvider passed in.
  308. /// If the provider is null, the CurrentCulture is used.
  309. /// See the documentation for IFormattable for more information.
  310. /// </summary>
  311. /// <returns>
  312. /// A string representation of this object.
  313. /// </returns>
  314. internal string ConvertToString(string format, IFormatProvider provider)
  315. {
  316. if (IsEmpty)
  317. {
  318. return "Empty";
  319. }
  320. // Helper to get the numeric list separator for a given culture.
  321. char separator = MS.Internal.TokenizerHelper.GetNumericListSeparator(provider);
  322. return String.Format(provider,
  323. "{1:" + format + "}{0}{2:" + format + "}{0}{3:" + format + "}{0}{4:" + format + "}",
  324. separator,
  325. _x,
  326. _y,
  327. _width,
  328. _height);
  329. }
  330. #endregion Internal Properties
  331. //------------------------------------------------------
  332. //
  333. // Dependency Properties
  334. //
  335. //------------------------------------------------------
  336. #region Dependency Properties
  337. #endregion Dependency Properties
  338. //------------------------------------------------------
  339. //
  340. // Internal Fields
  341. //
  342. //------------------------------------------------------
  343. #region Internal Fields
  344. internal int _x;
  345. internal int _y;
  346. internal int _width;
  347. internal int _height;
  348. #endregion Internal Fields
  349. #region Constructors
  350. //------------------------------------------------------
  351. //
  352. // Constructors
  353. //
  354. //------------------------------------------------------
  355. #endregion Constructors
  356. }
  357. }