2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using global::System.Runtime.InteropServices;
24 /// Simple class for passing around pairs of small unsigned integers.<br />
25 /// Use this for integer dimensions and points with limited range such as image
26 /// sizes and pixel coordinates where a pair of floating point numbers is
27 /// inefficient and illogical (i.e.the data is inherently integer).<br />
28 /// One of these can be passed in a single 32 bit integer register on
29 /// common architectures.<br />
31 internal class Uint16Pair : Disposable
34 internal Uint16Pair(IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
38 protected override void ReleaseSwigCPtr(HandleRef swigCPtr)
40 Interop.Uint16Pair.DeleteUint16Pair(swigCPtr);
44 /// Less than comparison operator for storing in collections (not geometrically meaningful).
46 /// <param name="arg1">A reference for comparison.</param>
47 /// <param name="arg2">A reference for comparison</param>
48 /// <return>True if arg1 less than arg2</return>
49 public static bool operator <(Uint16Pair arg1, Uint16Pair arg2)
51 return arg1.LessThan(arg2);
55 /// More than comparison operator for storing in collections (not geometrically meaningful).
57 /// <param name="arg1">A reference for comparison.</param>
58 /// <param name="arg2">A reference for comparison</param>
59 /// <return>True if arg1 > arg2</return>
60 public static bool operator >(Uint16Pair arg1, Uint16Pair arg2)
62 return arg1.GreaterThan(arg2);
66 /// Default constructor for the(0, 0) tuple.
68 public Uint16Pair() : this(Interop.Uint16Pair.NewUint16Pair(), true)
70 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
74 /// Default constructor for the(0, 0) tuple.
76 /// <param name="width">The width or X dimension of the tuple. Make sure it is less than 65536.</param>
77 /// <param name="height">The height or Y dimension of the tuple.Make sure it is less than 65536.</param>
78 public Uint16Pair(uint width, uint height) : this(Interop.Uint16Pair.NewUint16Pair(width, height), true)
80 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
84 /// Constructor taking separate x and y (width and height) parameters.
86 /// <param name="rhs">A reference to assign.</param>
87 public Uint16Pair(Uint16Pair rhs) : this(Interop.Uint16Pair.NewUint16Pair(Uint16Pair.getCPtr(rhs)), true)
89 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
95 /// <param name="width">The x dimension to be stored in this 2-tuple.</param>
96 public void SetWidth(ushort width)
98 if (SwigCPtr.Handle == IntPtr.Zero)
100 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
102 Interop.Uint16Pair.SetWidth(SwigCPtr, width);
103 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
110 /// The x dimension stored in this 2-tuple.
112 public ushort GetWidth()
114 if (SwigCPtr.Handle == IntPtr.Zero)
116 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
118 ushort ret = Interop.Uint16Pair.GetWidth(SwigCPtr);
119 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
126 /// <param name="height">The y dimension to be stored in this 2-tuple.</param>
127 public void SetHeight(ushort height)
129 if (SwigCPtr.Handle == IntPtr.Zero)
131 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
133 Interop.Uint16Pair.SetHeight(SwigCPtr, height);
134 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
141 /// The y dimension stored in this 2-tuple.
143 public ushort GetHeight()
145 if (SwigCPtr.Handle == IntPtr.Zero)
147 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
149 ushort ret = Interop.Uint16Pair.GetHeight(SwigCPtr);
150 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
155 /// Sets the x dimension.
157 /// <param name="x">The x dimension to be stored in this 2-tuple.</param>
158 public void SetX(ushort x)
160 if (SwigCPtr.Handle == IntPtr.Zero)
162 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
164 Interop.Uint16Pair.SetX(SwigCPtr, x);
165 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
169 /// Get the x dimension.
172 /// The x dimension stored in this 2-tuple.
176 if (SwigCPtr.Handle == IntPtr.Zero)
178 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
180 ushort ret = Interop.Uint16Pair.GetX(SwigCPtr);
181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
186 /// Sets the y dimension.
188 /// <param name="y">The y dimension to be stored in this 2-tuple.</param>
189 public void SetY(ushort y)
191 if (SwigCPtr.Handle == IntPtr.Zero)
193 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
195 Interop.Uint16Pair.SetY(SwigCPtr, y);
196 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
200 /// Get the y dimension.
203 /// The y dimension stored in this 2-tuple.
207 if (SwigCPtr.Handle == IntPtr.Zero)
209 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
211 ushort ret = Interop.Uint16Pair.GetY(SwigCPtr);
212 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
217 /// Constructor taking separate x and y (width and height) parameters.
219 /// <param name="rhs">A reference to assign.</param>
220 /// <return>The created object.</return>
221 public Uint16Pair Assign(Uint16Pair rhs)
223 if (SwigCPtr.Handle == IntPtr.Zero)
225 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
227 Uint16Pair ret = new Uint16Pair(Interop.Uint16Pair.Assign(SwigCPtr, Uint16Pair.getCPtr(rhs)), false);
228 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232 private bool EqualTo(Uint16Pair rhs)
234 if (SwigCPtr.Handle == IntPtr.Zero)
236 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
238 bool ret = Interop.Uint16Pair.EqualTo(SwigCPtr, Uint16Pair.getCPtr(rhs));
239 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
243 private bool NotEqualTo(Uint16Pair rhs)
245 if (SwigCPtr.Handle == IntPtr.Zero)
247 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
249 bool ret = Interop.Uint16Pair.NotEqualTo(SwigCPtr, Uint16Pair.getCPtr(rhs));
250 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254 private bool LessThan(Uint16Pair rhs)
256 if (SwigCPtr.Handle == IntPtr.Zero)
258 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
260 bool ret = Interop.Uint16Pair.LessThan(SwigCPtr, Uint16Pair.getCPtr(rhs));
261 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
265 private bool GreaterThan(Uint16Pair rhs)
267 if (SwigCPtr.Handle == IntPtr.Zero)
269 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
271 bool ret = Interop.Uint16Pair.GreaterThan(SwigCPtr, Uint16Pair.getCPtr(rhs));
272 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();