2 * Copyright (c) 2017 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;
23 // Please do not use! This will be changed to internal class.
25 /// A three-dimensional size.
27 /// <since_tizen> 3 </since_tizen>
28 [EditorBrowsable(EditorBrowsableState.Never)]
29 public class Size : global::System.IDisposable
31 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
32 /// <summary>swigCMemOwn.</summary>
33 /// <since_tizen> 3 </since_tizen>
34 protected bool swigCMemOwn;
36 internal Size(global::System.IntPtr cPtr, bool cMemoryOwn)
38 swigCMemOwn = cMemoryOwn;
39 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
42 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Size obj)
44 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
47 //A Flag to check who called Dispose(). (By User or DisposeQueue)
48 private bool isDisposeQueued = false;
50 /// A Flat to check if it is already disposed.
52 /// <since_tizen> 3 </since_tizen>
53 protected bool disposed = false;
62 isDisposeQueued = true;
63 DisposeQueue.Instance.Add(this);
70 /// <since_tizen> 3 </since_tizen>
73 //Throw excpetion if Dispose() is called in separate thread.
74 if (!Window.IsInstalled())
76 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
81 Dispose(DisposeTypes.Implicit);
85 Dispose(DisposeTypes.Explicit);
86 System.GC.SuppressFinalize(this);
93 /// <since_tizen> 3 </since_tizen>
94 protected virtual void Dispose(DisposeTypes type)
101 if (type == DisposeTypes.Explicit)
104 //Release your own managed resources here.
105 //You should release all of your own disposable objects here.
109 //Release your own unmanaged resources here.
110 //You should not access any managed member here except static instance.
111 //because the execution order of Finalizes is non-deterministic.
113 if (swigCPtr.Handle != global::System.IntPtr.Zero)
118 NDalicPINVOKE.delete_Vector3(swigCPtr);
120 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
127 /// The addition operator for A+B.
129 /// <param name="arg1">Size to assign A.</param>
130 /// <param name="arg2">Size to assign B.</param>
131 /// <returns>A size containing the result of the addition.</returns>
132 /// <since_tizen> 3 </since_tizen>
133 public static Size operator +(Size arg1, Size arg2)
135 return arg1.Add(arg2);
139 /// The subtraction operator for A-B.
141 /// <param name="arg1">Size to subtract A.</param>
142 /// <param name="arg2">Size to subtract B.</param>
143 /// <returns>The size containing the result of the subtraction.</returns>
144 /// <since_tizen> 3 </since_tizen>
145 public static Size operator -(Size arg1, Size arg2)
147 return arg1.Subtract(arg2);
151 /// The unary negation operator.
153 /// <param name="arg1">Size for unary negation.</param>
154 /// <returns>A size containing the negation.</returns>
155 /// <since_tizen> 3 </since_tizen>
156 public static Size operator -(Size arg1)
158 return arg1.Subtract();
162 /// The multiplication operator.
164 /// <param name="arg1">Size for multiplication.</param>
165 /// <param name="arg2">The size to multiply.</param>
166 /// <returns>A size containing the result of the multiplication.</returns>
167 /// <since_tizen> 3 </since_tizen>
168 public static Size operator *(Size arg1, Size arg2)
170 return arg1.Multiply(arg2);
174 /// The multiplication operator.
176 /// <param name="arg1">Size for multiplication.</param>
177 /// <param name="arg2">The float value to scale the size.</param>
178 /// <returns>A size containing the result of the scaling.</returns>
179 /// <since_tizen> 3 </since_tizen>
180 public static Size operator *(Size arg1, float arg2)
182 return arg1.Multiply(arg2);
186 /// The division operator.
188 /// <param name="arg1">Size for division.</param>
189 /// <param name="arg2">The size to divide.</param>
190 /// <returns>A size containing the result of the division.</returns>
191 /// <since_tizen> 3 </since_tizen>
192 public static Size operator /(Size arg1, Size arg2)
194 return arg1.Divide(arg2);
198 /// The division operator.
200 /// <param name="arg1">Size for division.</param>
201 /// <param name="arg2">The float value to scale the size by.</param>
202 /// <returns>A Size containing the result of the scaling.</returns>
203 /// <since_tizen> 3 </since_tizen>
204 public static Size operator /(Size arg1, float arg2)
206 return arg1.Divide(arg2);
210 /// The array subscript operator.
212 /// <param name="index">Subscript index.</param>
213 /// <returns>The float at the given index.</returns>
214 /// <since_tizen> 3 </since_tizen>
215 public float this[uint index]
219 return ValueOfIndex(index);
223 internal static Size GetSizeFromPtr(global::System.IntPtr cPtr)
225 Size ret = new Size(cPtr, false);
226 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
233 /// <since_tizen> 3 </since_tizen>
234 public Size() : this(NDalicPINVOKE.new_Vector3__SWIG_0(), true)
236 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
242 /// <param name="x">The x (or width) component.</param>
243 /// <param name="y">The y (or height) component.</param>
244 /// <param name="z">The z (or depth) component.</param>
245 /// <since_tizen> 3 </since_tizen>
246 public Size(float x, float y, float z) : this(NDalicPINVOKE.new_Vector3__SWIG_1(x, y, z), true)
248 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254 /// <param name="size2d">Size2D with x (width) and y (height).</param>
255 /// <since_tizen> 3 </since_tizen>
256 public Size(Size2D size2d) : this(NDalicPINVOKE.new_Vector3__SWIG_3(Size2D.getCPtr(size2d)), true)
258 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
262 /// The Zero constant, (0.0f, 0.0f, 0.0f).
264 /// <since_tizen> 3 </since_tizen>
265 public static Size Zero
269 global::System.IntPtr cPtr = NDalicPINVOKE.Vector3_ZERO_get();
270 Size ret = (cPtr == global::System.IntPtr.Zero) ? null : new Size(cPtr, false);
271 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
276 private Size Add(Size rhs)
278 Size ret = new Size(NDalicPINVOKE.Vector3_Add(swigCPtr, Size.getCPtr(rhs)), true);
279 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
283 private Size Subtract(Size rhs)
285 Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
286 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
290 private Size Multiply(Size rhs)
292 Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
293 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
297 private Size Multiply(float rhs)
299 Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
300 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
304 private Size Divide(Size rhs)
306 Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
307 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
311 private Size Divide(float rhs)
313 Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
314 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
318 private Size Subtract()
320 Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_1(swigCPtr), true);
321 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
325 private float ValueOfIndex(uint index)
327 float ret = NDalicPINVOKE.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
328 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
333 /// Checks equality.<br />
334 /// Utilizes appropriate machine epsilon values.<br />
336 /// <param name="rhs">The size to test against.</param>
337 /// <returns>True if the sizes are equal.</returns>
338 /// <since_tizen> 3 </since_tizen>
339 public bool EqualTo(Size rhs)
341 bool ret = NDalicPINVOKE.Vector3_EqualTo(swigCPtr, Size.getCPtr(rhs));
342 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
347 /// Checks inequality.<br />
348 /// Utilizes appropriate machine epsilon values.<br />
350 /// <param name="rhs">The size to test against.</param>
351 /// <returns>True if the sizes are not equal.</returns>
352 /// <since_tizen> 3 </since_tizen>
353 public bool NotEqualTo(Size rhs)
355 bool ret = NDalicPINVOKE.Vector3_NotEqualTo(swigCPtr, Size.getCPtr(rhs));
356 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
361 /// The Width property for the width component of size
363 /// <since_tizen> 3 </since_tizen>
368 NDalicPINVOKE.Vector3_Width_set(swigCPtr, value);
369 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
373 float ret = NDalicPINVOKE.Vector3_Width_get(swigCPtr);
374 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
380 /// The Height property for the height component of size.
382 /// <since_tizen> 3 </since_tizen>
387 NDalicPINVOKE.Vector3_Height_set(swigCPtr, value);
388 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
392 float ret = NDalicPINVOKE.Vector3_Height_get(swigCPtr);
393 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
399 /// The Depth property for the depth component of size.
401 /// <since_tizen> 3 </since_tizen>
406 NDalicPINVOKE.Vector3_Depth_set(swigCPtr, value);
407 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
411 float ret = NDalicPINVOKE.Vector3_Depth_get(swigCPtr);
412 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
418 /// The type cast operator, Size to Vector3.
420 /// <param name="size">The object of size type.</param>
421 /// <since_tizen> 3 </since_tizen>
422 public static implicit operator Vector3(Size size)
424 return new Vector3(size.Width, size.Height, size.Depth);
428 /// The type cast operator, Vector3 to Size type.
430 /// <param name="vec">The object of Vector3 type.</param>
431 /// <since_tizen> 3 </since_tizen>
432 public static implicit operator Size(Vector3 vec)
434 return new Size(vec.Width, vec.Height, vec.Depth);