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.
21 /*********************************************************************************/
\r
22 /*** will be removed/deprecated ***/
\r
23 /*********************************************************************************/
\r
24 public class Size : global::System.IDisposable
26 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
27 protected bool swigCMemOwn;
29 internal Size(global::System.IntPtr cPtr, bool cMemoryOwn)
31 swigCMemOwn = cMemoryOwn;
32 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
35 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Size obj)
37 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
40 //A Flag to check who called Dispose(). (By User or DisposeQueue)
41 private bool isDisposeQueued = false;
42 //A Flat to check if it is already disposed.
43 protected bool disposed = false;
52 isDisposeQueued = true;
53 DisposeQueue.Instance.Add(this);
59 //Throw excpetion if Dispose() is called in separate thread.
60 if (!Window.IsInstalled())
62 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
67 Dispose(DisposeTypes.Implicit);
71 Dispose(DisposeTypes.Explicit);
72 System.GC.SuppressFinalize(this);
76 protected virtual void Dispose(DisposeTypes type)
83 if (type == DisposeTypes.Explicit)
86 //Release your own managed resources here.
87 //You should release all of your own disposable objects here.
91 //Release your own unmanaged resources here.
92 //You should not access any managed member here except static instance.
93 //because the execution order of Finalizes is non-deterministic.
95 if (swigCPtr.Handle != global::System.IntPtr.Zero)
100 NDalicPINVOKE.delete_Vector3(swigCPtr);
102 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
109 /// Addition operator for A+B
111 /// <param name="arg1">Size, A</param>
112 /// <param name="arg2">Size to assign, B</param>
113 /// <returns>A Size containing the result of the addition</returns>
114 public static Size operator +(Size arg1, Size arg2)
116 return arg1.Add(arg2);
120 /// Subtraction operator for A-B
122 /// <param name="arg1">Size, A</param>
123 /// <param name="arg2">Size to subtract, B</param>
124 /// <returns>A Size containing the result of the subtraction</returns>
125 public static Size operator -(Size arg1, Size arg2)
127 return arg1.Subtract(arg2);
131 /// Unary negation operator.
133 /// <param name="arg1">Size for unary negation</param>
134 /// <returns>A Size containg the negation</returns>
135 public static Size operator -(Size arg1)
137 return arg1.Subtract();
141 /// Multiplication operator.
143 /// <param name="arg1">Size for multiplication</param>
144 /// <param name="arg2">The Size to multipl</param>
145 /// <returns>A Size containing the result of the multiplication</returns>
146 public static Size operator *(Size arg1, Size arg2)
148 return arg1.Multiply(arg2);
152 /// Multiplication operator.
154 /// <param name="arg1">Size for multiplication</param>
155 /// <param name="arg2">The float value to scale the Size</param>
156 /// <returns>A Size containing the result of the scaling</returns>
157 public static Size operator *(Size arg1, float arg2)
159 return arg1.Multiply(arg2);
163 /// Division operator.
165 /// <param name="arg1">Size for division</param>
166 /// <param name="arg2">The Size to divide</param>
167 /// <returns>A Size containing the result of the division></returns>
168 public static Size operator /(Size arg1, Size arg2)
170 return arg1.Divide(arg2);
174 /// Division operator.
176 /// <param name="arg1">Size for division</param>
177 /// <param name="arg2">The float value to scale the Size by</param>
178 /// <returns>A Size containing the result of the scaling</returns>
179 public static Size operator /(Size arg1, float arg2)
181 return arg1.Divide(arg2);
185 /// Array subscript operator.
187 /// <param name="index">Subscript index</param>
188 /// <returns>The float at the given index</returns>
189 public float this[uint index]
193 return ValueOfIndex(index);
197 internal static Size GetSizeFromPtr(global::System.IntPtr cPtr)
199 Size ret = new Size(cPtr, false);
200 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
207 public Size() : this(NDalicPINVOKE.new_Vector3__SWIG_0(), true)
209 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215 /// <param name="x">x (or width) component</param>
216 /// <param name="y">y (or height) component</param>
217 /// <param name="z">z (or depth) component</param>
218 public Size(float x, float y, float z) : this(NDalicPINVOKE.new_Vector3__SWIG_1(x, y, z), true)
220 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
226 /// <param name="size2d">Size2D with x (width) and y (height)</param>
227 public Size(Size2D size2d) : this(NDalicPINVOKE.new_Vector3__SWIG_3(Size2D.getCPtr(size2d)), true)
229 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
233 /// Zero constant, (0.0f, 0.0f, 0.0f).
235 public static Size Zero
239 global::System.IntPtr cPtr = NDalicPINVOKE.Vector3_ZERO_get();
240 Size ret = (cPtr == global::System.IntPtr.Zero) ? null : new Size(cPtr, false);
241 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
246 private Size Add(Size rhs)
248 Size ret = new Size(NDalicPINVOKE.Vector3_Add(swigCPtr, Size.getCPtr(rhs)), true);
249 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
253 private Size Subtract(Size rhs)
255 Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
256 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
260 private Size Multiply(Size rhs)
262 Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
263 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
267 private Size Multiply(float rhs)
269 Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
270 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
274 private Size Divide(Size rhs)
276 Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
277 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
281 private Size Divide(float rhs)
283 Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
284 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
288 private Size Subtract()
290 Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_1(swigCPtr), true);
291 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
295 private float ValueOfIndex(uint index)
297 float ret = NDalicPINVOKE.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
298 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
303 /// Check equality.<br>
304 /// Utilizes appropriate machine epsilon values.<br>
306 /// <param name="rhs">The Size to test against</param>
307 /// <returns>True if the Sizes are equal</returns>
308 public bool EqualTo(Size rhs)
310 bool ret = NDalicPINVOKE.Vector3_EqualTo(swigCPtr, Size.getCPtr(rhs));
311 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
316 /// Check inequality.<br>
317 /// Utilizes appropriate machine epsilon values.<br>
319 /// <param name="rhs">The Size to test against</param>
320 /// <returns>True if the Sizes are not equal</returns>
321 public bool NotEqualTo(Size rhs)
323 bool ret = NDalicPINVOKE.Vector3_NotEqualTo(swigCPtr, Size.getCPtr(rhs));
324 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
329 /// Width property for width component of Siz
335 NDalicPINVOKE.Vector3_Width_set(swigCPtr, value);
336 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
340 float ret = NDalicPINVOKE.Vector3_Width_get(swigCPtr);
341 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
347 /// Height property for height component of Size
353 NDalicPINVOKE.Vector3_Height_set(swigCPtr, value);
354 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
358 float ret = NDalicPINVOKE.Vector3_Height_get(swigCPtr);
359 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
365 /// Depth property for depth component of Size
371 NDalicPINVOKE.Vector3_Depth_set(swigCPtr, value);
372 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
376 float ret = NDalicPINVOKE.Vector3_Depth_get(swigCPtr);
377 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
383 /// Type cast operator, Size to Vector3.
385 /// <param name="size">Object of Size type</param>
386 public static implicit operator Vector3(Size size)
388 return new Vector3(size.Width, size.Height, size.Depth);
392 /// Type cast operator, Vector3 to Size type.
394 /// <param name="vec">Object of Vector3 type</param>
395 public static implicit operator Size(Vector3 vec)
397 return new Size(vec.Width, vec.Height, vec.Depth);