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 if (swigCPtr.Handle == IntPtr.Zero)
42 //Log.Fatal("NUI", "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!");
43 //Log.Fatal("NUI", "Error! just return here! this can cause unknown error or crash in next step");
45 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!");
47 Interop.Uint16Pair.DeleteUint16Pair(swigCPtr);
51 /// Less than comparison operator for storing in collections (not geometrically meaningful).
53 /// <param name="arg1">A reference for comparison.</param>
54 /// <param name="arg2">A reference for comparison</param>
55 /// <return>True if arg1 less than arg2</return>
56 public static bool operator <(Uint16Pair arg1, Uint16Pair arg2)
58 return arg1.LessThan(arg2);
62 /// More than comparison operator for storing in collections (not geometrically meaningful).
64 /// <param name="arg1">A reference for comparison.</param>
65 /// <param name="arg2">A reference for comparison</param>
66 /// <return>True if arg1 > arg2</return>
67 public static bool operator >(Uint16Pair arg1, Uint16Pair arg2)
69 return arg1.GreaterThan(arg2);
73 /// Default constructor for the(0, 0) tuple.
75 public Uint16Pair() : this(Interop.Uint16Pair.NewUint16Pair(), true)
77 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81 /// Default constructor for the(0, 0) tuple.
83 /// <param name="width">The width or X dimension of the tuple. Make sure it is less than 65536.</param>
84 /// <param name="height">The height or Y dimension of the tuple.Make sure it is less than 65536.</param>
85 public Uint16Pair(uint width, uint height) : this(Interop.Uint16Pair.NewUint16Pair(width, height), true)
87 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
91 /// Constructor taking separate x and y (width and height) parameters.
93 /// <param name="rhs">A reference to assign.</param>
94 public Uint16Pair(Uint16Pair rhs) : this(Interop.Uint16Pair.NewUint16Pair(Uint16Pair.getCPtr(rhs)), true)
96 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
102 /// <param name="width">The x dimension to be stored in this 2-tuple.</param>
103 public void SetWidth(ushort width)
105 if (SwigCPtr.Handle == IntPtr.Zero)
107 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!");
109 Interop.Uint16Pair.SetWidth(SwigCPtr, width);
110 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
117 /// The x dimension stored in this 2-tuple.
119 public ushort GetWidth()
121 if (SwigCPtr.Handle == IntPtr.Zero)
123 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!");
125 ushort ret = Interop.Uint16Pair.GetWidth(SwigCPtr);
126 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
133 /// <param name="height">The y dimension to be stored in this 2-tuple.</param>
134 public void SetHeight(ushort height)
136 if (SwigCPtr.Handle == IntPtr.Zero)
138 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!");
140 Interop.Uint16Pair.SetHeight(SwigCPtr, height);
141 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
148 /// The y dimension stored in this 2-tuple.
150 public ushort GetHeight()
152 if (SwigCPtr.Handle == IntPtr.Zero)
154 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!");
156 ushort ret = Interop.Uint16Pair.GetHeight(SwigCPtr);
157 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162 /// Sets the x dimension.
164 /// <param name="x">The x dimension to be stored in this 2-tuple.</param>
165 public void SetX(ushort x)
167 if (SwigCPtr.Handle == IntPtr.Zero)
169 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!");
171 Interop.Uint16Pair.SetX(SwigCPtr, x);
172 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
176 /// Get the x dimension.
179 /// The x dimension stored in this 2-tuple.
183 if (SwigCPtr.Handle == IntPtr.Zero)
185 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!");
187 ushort ret = Interop.Uint16Pair.GetX(SwigCPtr);
188 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
193 /// Sets the y dimension.
195 /// <param name="y">The y dimension to be stored in this 2-tuple.</param>
196 public void SetY(ushort y)
198 if (SwigCPtr.Handle == IntPtr.Zero)
200 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!");
202 Interop.Uint16Pair.SetY(SwigCPtr, y);
203 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
207 /// Get the y dimension.
210 /// The y dimension stored in this 2-tuple.
214 if (SwigCPtr.Handle == IntPtr.Zero)
216 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!");
218 ushort ret = Interop.Uint16Pair.GetY(SwigCPtr);
219 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
224 /// Constructor taking separate x and y (width and height) parameters.
226 /// <param name="rhs">A reference to assign.</param>
227 /// <return>The created object.</return>
228 public Uint16Pair Assign(Uint16Pair rhs)
230 if (SwigCPtr.Handle == IntPtr.Zero)
232 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!");
234 Uint16Pair ret = new Uint16Pair(Interop.Uint16Pair.Assign(SwigCPtr, Uint16Pair.getCPtr(rhs)), false);
235 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
239 private bool EqualTo(Uint16Pair rhs)
241 if (SwigCPtr.Handle == IntPtr.Zero)
243 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!");
245 bool ret = Interop.Uint16Pair.EqualTo(SwigCPtr, Uint16Pair.getCPtr(rhs));
246 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
250 private bool NotEqualTo(Uint16Pair rhs)
252 if (SwigCPtr.Handle == IntPtr.Zero)
254 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!");
256 bool ret = Interop.Uint16Pair.NotEqualTo(SwigCPtr, Uint16Pair.getCPtr(rhs));
257 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
261 private bool LessThan(Uint16Pair rhs)
263 if (SwigCPtr.Handle == IntPtr.Zero)
265 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!");
267 bool ret = Interop.Uint16Pair.LessThan(SwigCPtr, Uint16Pair.getCPtr(rhs));
268 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
272 private bool GreaterThan(Uint16Pair rhs)
274 if (SwigCPtr.Handle == IntPtr.Zero)
276 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!");
278 bool ret = Interop.Uint16Pair.GreaterThan(SwigCPtr, Uint16Pair.getCPtr(rhs));
279 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();