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 [Obsolete("Please do not use! This will be deprecated! Please use Size2D instead!")]
29 [EditorBrowsable(EditorBrowsableState.Never)]
30 public class Size : global::System.IDisposable
32 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
33 /// <summary>swigCMemOwn.</summary>
34 /// <since_tizen> 3 </since_tizen>
35 protected bool swigCMemOwn;
37 internal Size(global::System.IntPtr cPtr, bool cMemoryOwn)
39 swigCMemOwn = cMemoryOwn;
40 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
43 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Size obj)
45 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
48 //A Flag to check who called Dispose(). (By User or DisposeQueue)
49 private bool isDisposeQueued = false;
51 /// A Flat to check if it is already disposed.
53 /// <since_tizen> 3 </since_tizen>
54 protected bool disposed = false;
63 isDisposeQueued = true;
64 DisposeQueue.Instance.Add(this);
71 /// <since_tizen> 3 </since_tizen>
74 //Throw excpetion if Dispose() is called in separate thread.
75 if (!Window.IsInstalled())
77 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
82 Dispose(DisposeTypes.Implicit);
86 Dispose(DisposeTypes.Explicit);
87 System.GC.SuppressFinalize(this);
94 /// <since_tizen> 3 </since_tizen>
95 protected virtual void Dispose(DisposeTypes type)
102 if (type == DisposeTypes.Explicit)
105 //Release your own managed resources here.
106 //You should release all of your own disposable objects here.
110 //Release your own unmanaged resources here.
111 //You should not access any managed member here except static instance.
112 //because the execution order of Finalizes is non-deterministic.
114 if (swigCPtr.Handle != global::System.IntPtr.Zero)
119 NDalicPINVOKE.delete_Vector3(swigCPtr);
121 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
128 /// The addition operator for A+B.
130 /// <param name="arg1">Size to assign A.</param>
131 /// <param name="arg2">Size to assign B.</param>
132 /// <returns>A size containing the result of the addition.</returns>
133 /// <since_tizen> 3 </since_tizen>
134 public static Size operator +(Size arg1, Size arg2)
136 return arg1.Add(arg2);
140 /// The subtraction operator for A-B.
142 /// <param name="arg1">Size to subtract A.</param>
143 /// <param name="arg2">Size to subtract B.</param>
144 /// <returns>The size containing the result of the subtraction.</returns>
145 /// <since_tizen> 3 </since_tizen>
146 public static Size operator -(Size arg1, Size arg2)
148 return arg1.Subtract(arg2);
152 /// The unary negation operator.
154 /// <param name="arg1">Size for unary negation.</param>
155 /// <returns>A size containing the negation.</returns>
156 /// <since_tizen> 3 </since_tizen>
157 public static Size operator -(Size arg1)
159 return arg1.Subtract();
163 /// The multiplication operator.
165 /// <param name="arg1">Size for multiplication.</param>
166 /// <param name="arg2">The size to multiply.</param>
167 /// <returns>A size containing the result of the multiplication.</returns>
168 /// <since_tizen> 3 </since_tizen>
169 public static Size operator *(Size arg1, Size arg2)
171 return arg1.Multiply(arg2);
175 /// The multiplication operator.
177 /// <param name="arg1">Size for multiplication.</param>
178 /// <param name="arg2">The float value to scale the size.</param>
179 /// <returns>A size containing the result of the scaling.</returns>
180 /// <since_tizen> 3 </since_tizen>
181 public static Size operator *(Size arg1, float arg2)
183 return arg1.Multiply(arg2);
187 /// The division operator.
189 /// <param name="arg1">Size for division.</param>
190 /// <param name="arg2">The size to divide.</param>
191 /// <returns>A size containing the result of the division.</returns>
192 /// <since_tizen> 3 </since_tizen>
193 public static Size operator /(Size arg1, Size arg2)
195 return arg1.Divide(arg2);
199 /// The division operator.
201 /// <param name="arg1">Size for division.</param>
202 /// <param name="arg2">The float value to scale the size by.</param>
203 /// <returns>A Size containing the result of the scaling.</returns>
204 /// <since_tizen> 3 </since_tizen>
205 public static Size operator /(Size arg1, float arg2)
207 return arg1.Divide(arg2);
211 /// The array subscript operator.
213 /// <param name="index">Subscript index.</param>
214 /// <returns>The float at the given index.</returns>
215 /// <since_tizen> 3 </since_tizen>
216 public float this[uint index]
220 return ValueOfIndex(index);
224 internal static Size GetSizeFromPtr(global::System.IntPtr cPtr)
226 Size ret = new Size(cPtr, false);
227 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
234 /// <since_tizen> 3 </since_tizen>
235 public Size() : this(NDalicPINVOKE.new_Vector3__SWIG_0(), true)
237 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
243 /// <param name="x">The x (or width) component.</param>
244 /// <param name="y">The y (or height) component.</param>
245 /// <param name="z">The z (or depth) component.</param>
246 /// <since_tizen> 3 </since_tizen>
247 public Size(float x, float y, float z) : this(NDalicPINVOKE.new_Vector3__SWIG_1(x, y, z), true)
249 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
255 /// <param name="size2d">Size2D with x (width) and y (height).</param>
256 /// <since_tizen> 3 </since_tizen>
257 public Size(Size2D size2d) : this(NDalicPINVOKE.new_Vector3__SWIG_3(Size2D.getCPtr(size2d)), true)
259 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
263 /// The Zero constant, (0.0f, 0.0f, 0.0f).
265 /// <since_tizen> 3 </since_tizen>
266 public static Size Zero
270 global::System.IntPtr cPtr = NDalicPINVOKE.Vector3_ZERO_get();
271 Size ret = (cPtr == global::System.IntPtr.Zero) ? null : new Size(cPtr, false);
272 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
277 private Size Add(Size rhs)
279 Size ret = new Size(NDalicPINVOKE.Vector3_Add(swigCPtr, Size.getCPtr(rhs)), true);
280 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
284 private Size Subtract(Size rhs)
286 Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
287 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
291 private Size Multiply(Size rhs)
293 Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
294 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
298 private Size Multiply(float rhs)
300 Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
301 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
305 private Size Divide(Size rhs)
307 Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
308 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
312 private Size Divide(float rhs)
314 Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
315 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
319 private Size Subtract()
321 Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_1(swigCPtr), true);
322 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
326 private float ValueOfIndex(uint index)
328 float ret = NDalicPINVOKE.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
329 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
334 /// Checks equality.<br />
335 /// Utilizes appropriate machine epsilon values.<br />
337 /// <param name="rhs">The size to test against.</param>
338 /// <returns>True if the sizes are equal.</returns>
339 /// <since_tizen> 3 </since_tizen>
340 public bool EqualTo(Size rhs)
342 bool ret = NDalicPINVOKE.Vector3_EqualTo(swigCPtr, Size.getCPtr(rhs));
343 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
348 /// Checks inequality.<br />
349 /// Utilizes appropriate machine epsilon values.<br />
351 /// <param name="rhs">The size to test against.</param>
352 /// <returns>True if the sizes are not equal.</returns>
353 /// <since_tizen> 3 </since_tizen>
354 public bool NotEqualTo(Size rhs)
356 bool ret = NDalicPINVOKE.Vector3_NotEqualTo(swigCPtr, Size.getCPtr(rhs));
357 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
362 /// The Width property for the width component of size
364 /// <since_tizen> 3 </since_tizen>
369 NDalicPINVOKE.Vector3_Width_set(swigCPtr, value);
370 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
374 float ret = NDalicPINVOKE.Vector3_Width_get(swigCPtr);
375 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
381 /// The Height property for the height component of size.
383 /// <since_tizen> 3 </since_tizen>
388 NDalicPINVOKE.Vector3_Height_set(swigCPtr, value);
389 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
393 float ret = NDalicPINVOKE.Vector3_Height_get(swigCPtr);
394 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
400 /// The Depth property for the depth component of size.
402 /// <since_tizen> 3 </since_tizen>
407 NDalicPINVOKE.Vector3_Depth_set(swigCPtr, value);
408 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
412 float ret = NDalicPINVOKE.Vector3_Depth_get(swigCPtr);
413 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
419 /// The type cast operator, Size to Vector3.
421 /// <param name="size">The object of size type.</param>
422 /// <since_tizen> 3 </since_tizen>
423 public static implicit operator Vector3(Size size)
425 return new Vector3(size.Width, size.Height, size.Depth);
429 /// The type cast operator, Vector3 to Size type.
431 /// <param name="vec">The object of Vector3 type.</param>
432 /// <since_tizen> 3 </since_tizen>
433 public static implicit operator Size(Vector3 vec)
435 return new Size(vec.Width, vec.Height, vec.Depth);