2 * Copyright (c) 2018 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 System.ComponentModel;
24 /// A three-dimensional size.
26 /// <since_tizen> 5 </since_tizen>
27 public class Size : global::System.IDisposable
29 /// <summary>swigCMemOwn.</summary>
30 /// <since_tizen> 5 </since_tizen>
31 protected bool swigCMemOwn;
34 /// A Flat to check if it is already disposed.
36 /// <since_tizen> 5 </since_tizen>
37 protected bool disposed = false;
39 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
41 //A Flag to check who called Dispose(). (By User or DisposeQueue)
42 private bool isDisposeQueued = false;
47 /// <since_tizen> 5 </since_tizen>
48 public Size() : this(Interop.Vector3.new_Vector3__SWIG_0(), true)
50 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
56 /// <param name="x">The x (or width) component.</param>
57 /// <param name="y">The y (or height) component.</param>
58 /// <param name="z">The z (or depth) component.</param>
59 /// <since_tizen> 5 </since_tizen>
60 public Size(float x, float y, float z) : this(Interop.Vector3.new_Vector3__SWIG_1(x, y, z), true)
62 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
68 /// <param name="size2d">Size2D with x (width) and y (height).</param>
69 /// <since_tizen> 5 </since_tizen>
70 public Size(Size2D size2d) : this(Interop.Vector3.new_Vector3__SWIG_3(Size2D.getCPtr(size2d)), true)
72 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
82 isDisposeQueued = true;
83 DisposeQueue.Instance.Add(this);
88 /// The Zero constant, (0.0f, 0.0f, 0.0f).
90 /// <since_tizen> 5 </since_tizen>
91 public static Size Zero
95 global::System.IntPtr cPtr = Interop.Vector3.Vector3_ZERO_get();
96 Size ret = (cPtr == global::System.IntPtr.Zero) ? null : new Size(cPtr, false);
97 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
103 /// The Width property for the width component of size
105 /// <since_tizen> 5 </since_tizen>
110 Interop.Vector3.Vector3_Width_set(swigCPtr, value);
111 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
115 float ret = Interop.Vector3.Vector3_Width_get(swigCPtr);
116 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
122 /// The Height property for the height component of size.
124 /// <since_tizen> 5 </since_tizen>
129 Interop.Vector3.Vector3_Height_set(swigCPtr, value);
130 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
134 float ret = Interop.Vector3.Vector3_Height_get(swigCPtr);
135 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
141 /// The Depth property for the depth component of size.
143 /// <since_tizen> 5 </since_tizen>
148 Interop.Vector3.Vector3_Depth_set(swigCPtr, value);
149 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
153 float ret = Interop.Vector3.Vector3_Depth_get(swigCPtr);
154 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
160 /// The addition operator for A+B.
162 /// <param name="arg1">Size to assign A.</param>
163 /// <param name="arg2">Size to assign B.</param>
164 /// <returns>A size containing the result of the addition.</returns>
165 /// <since_tizen> 5 </since_tizen>
166 public static Size operator +(Size arg1, Size arg2)
168 return arg1.Add(arg2);
172 /// The subtraction operator for A-B.
174 /// <param name="arg1">Size to subtract A.</param>
175 /// <param name="arg2">Size to subtract B.</param>
176 /// <returns>The size containing the result of the subtraction.</returns>
177 /// <since_tizen> 5 </since_tizen>
178 public static Size operator -(Size arg1, Size arg2)
180 return arg1.Subtract(arg2);
184 /// The unary negation operator.
186 /// <param name="arg1">Size for unary negation.</param>
187 /// <returns>A size containing the negation.</returns>
188 /// <since_tizen> 5 </since_tizen>
189 public static Size operator -(Size arg1)
191 return arg1.Subtract();
195 /// The multiplication operator.
197 /// <param name="arg1">Size for multiplication.</param>
198 /// <param name="arg2">The size to multiply.</param>
199 /// <returns>A size containing the result of the multiplication.</returns>
200 /// <since_tizen> 5 </since_tizen>
201 public static Size operator *(Size arg1, Size arg2)
203 return arg1.Multiply(arg2);
207 /// The multiplication operator.
209 /// <param name="arg1">Size for multiplication.</param>
210 /// <param name="arg2">The float value to scale the size.</param>
211 /// <returns>A size containing the result of the scaling.</returns>
212 /// <since_tizen> 5 </since_tizen>
213 public static Size operator *(Size arg1, float arg2)
215 return arg1.Multiply(arg2);
219 /// The division operator.
221 /// <param name="arg1">Size for division.</param>
222 /// <param name="arg2">The size to divide.</param>
223 /// <returns>A size containing the result of the division.</returns>
224 /// <since_tizen> 5 </since_tizen>
225 public static Size operator /(Size arg1, Size arg2)
227 return arg1.Divide(arg2);
231 /// The division operator.
233 /// <param name="arg1">Size for division.</param>
234 /// <param name="arg2">The float value to scale the size by.</param>
235 /// <returns>A Size containing the result of the scaling.</returns>
236 /// <since_tizen> 5 </since_tizen>
237 public static Size operator /(Size arg1, float arg2)
239 return arg1.Divide(arg2);
243 /// The array subscript operator.
245 /// <param name="index">Subscript index.</param>
246 /// <returns>The float at the given index.</returns>
247 /// <since_tizen> 5 </since_tizen>
248 public float this[uint index]
252 return ValueOfIndex(index);
259 /// <since_tizen> 5 </since_tizen>
260 public void Dispose()
262 //Throw excpetion if Dispose() is called in separate thread.
263 if (!Window.IsInstalled())
265 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
270 Dispose(DisposeTypes.Implicit);
274 Dispose(DisposeTypes.Explicit);
275 System.GC.SuppressFinalize(this);
280 /// Determines whether the specified object is equal to the current object.
282 /// <param name="obj">The object to compare with the current object.</param>
283 /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
284 public override bool Equals(System.Object obj)
286 Size size = obj as Size;
288 if (Width == size?.Width && Height == size?.Height && Depth == size?.Depth)
296 /// Gets the the hash code of this Size.
298 /// <returns>The Hash Code.</returns>
299 /// <since_tizen> 6 </since_tizen>
300 public override int GetHashCode()
302 return swigCPtr.Handle.GetHashCode();
306 /// Checks equality.<br />
307 /// Utilizes appropriate machine epsilon values.<br />
309 /// <param name="rhs">The size to test against.</param>
310 /// <returns>True if the sizes are equal.</returns>
311 /// <since_tizen> 5 </since_tizen>
312 public bool EqualTo(Size rhs)
314 bool ret = Interop.Vector3.Vector3_EqualTo(swigCPtr, Size.getCPtr(rhs));
315 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
320 /// Checks inequality.<br />
321 /// Utilizes appropriate machine epsilon values.<br />
323 /// <param name="rhs">The size to test against.</param>
324 /// <returns>True if the sizes are not equal.</returns>
325 /// <since_tizen> 5 </since_tizen>
326 public bool NotEqualTo(Size rhs)
328 bool ret = Interop.Vector3.Vector3_NotEqualTo(swigCPtr, Size.getCPtr(rhs));
329 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
336 /// The type cast operator, Size to Vector3.
338 /// <param name="size">The object of size type.</param>
339 /// <since_tizen> 5 </since_tizen>
340 public static implicit operator Vector3(Size size)
342 return new Vector3(size.Width, size.Height, size.Depth);
346 /// The type cast operator, Vector3 to Size type.
348 /// <param name="vec">The object of Vector3 type.</param>
349 /// <since_tizen> 5 </since_tizen>
350 public static implicit operator Size(Vector3 vec)
352 return new Size(vec.Width, vec.Height, vec.Depth);
355 internal static Size GetSizeFromPtr(global::System.IntPtr cPtr)
357 Size ret = new Size(cPtr, false);
358 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
362 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Size obj)
364 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
367 internal Size(global::System.IntPtr cPtr, bool cMemoryOwn)
369 swigCMemOwn = cMemoryOwn;
370 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
376 /// <since_tizen> 5 </since_tizen>
377 protected virtual void Dispose(DisposeTypes type)
384 if (type == DisposeTypes.Explicit)
387 //Release your own managed resources here.
388 //You should release all of your own disposable objects here.
392 //Release your own unmanaged resources here.
393 //You should not access any managed member here except static instance.
394 //because the execution order of Finalizes is non-deterministic.
396 if (swigCPtr.Handle != global::System.IntPtr.Zero)
401 Interop.Vector3.delete_Vector3(swigCPtr);
403 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
409 private Size Add(Size rhs)
411 Size ret = new Size(Interop.Vector3.Vector3_Add(swigCPtr, Size.getCPtr(rhs)), true);
412 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
416 private Size Subtract(Size rhs)
418 Size ret = new Size(Interop.Vector3.Vector3_Subtract__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
419 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
423 private Size Multiply(Size rhs)
425 Size ret = new Size(Interop.Vector3.Vector3_Multiply__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
426 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
430 private Size Multiply(float rhs)
432 Size ret = new Size(Interop.Vector3.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
433 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
437 private Size Divide(Size rhs)
439 Size ret = new Size(Interop.Vector3.Vector3_Divide__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
440 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
444 private Size Divide(float rhs)
446 Size ret = new Size(Interop.Vector3.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
447 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
451 private Size Subtract()
453 Size ret = new Size(Interop.Vector3.Vector3_Subtract__SWIG_1(swigCPtr), true);
454 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
458 private float ValueOfIndex(uint index)
460 float ret = Interop.Vector3.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
461 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();