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.
22 /// A two dimensional size
24 public class Size2D : global::System.IDisposable
26 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
27 protected bool swigCMemOwn;
29 internal Size2D(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(Size2D obj)
37 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
42 DisposeQueue.Instance.Add(this);
48 public virtual void Dispose()
50 if (!Window.IsInstalled())
52 DisposeQueue.Instance.Add(this);
58 if (swigCPtr.Handle != global::System.IntPtr.Zero)
63 NDalicPINVOKE.delete_Vector2(swigCPtr);
65 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
67 global::System.GC.SuppressFinalize(this);
72 /// Addition operator for A+B
74 /// <param name="arg1">Size, A</param>
75 /// <param name="arg2">Size to assign, B</param>
76 /// <returns>A Size containing the result of the addition</returns>
77 public static Size2D operator +(Size2D arg1, Size2D arg2)
79 return arg1.Add(arg2);
83 /// Subtraction operator for A-B
85 /// <param name="arg1">Size, A</param>
86 /// <param name="arg2">Size to subtract, B</param>
87 /// <returns>A Size containing the result of the subtraction</returns>
88 public static Size2D operator -(Size2D arg1, Size2D arg2)
90 return arg1.Subtract(arg2);
94 /// Unary negation operator.
96 /// <param name="arg1">Size for unary negation</param>
97 /// <returns>A Size containg the negation</returns>
98 public static Size2D operator -(Size2D arg1)
100 return arg1.Subtract();
104 /// Multiplication operator.
106 /// <param name="arg1">Size for multiplication</param>
107 /// <param name="arg2">The Size to multipl</param>
108 /// <returns>A Size containing the result of the multiplication</returns>
109 public static Size2D operator *(Size2D arg1, Size2D arg2)
111 return arg1.Multiply(arg2);
115 /// Multiplication operator.
117 /// <param name="arg1">Size for multiplication</param>
118 /// <param name="arg2">The int value to scale the Size</param>
119 /// <returns>A Size containing the result of the scaling</returns>
121 public static Size2D operator *(Size2D arg1, int arg2)
123 return arg1.Multiply(arg2);
127 /// Division operator.
129 /// <param name="arg1">Size for division</param>
130 /// <param name="arg2">The Size to divide</param>
131 /// <returns>A Size containing the result of the division></returns>
132 public static Size2D operator /(Size2D arg1, Size2D arg2)
134 return arg1.Divide(arg2);
138 /// Division operator.
140 /// <param name="arg1">Size for division</param>
141 /// <param name="arg2">The int value to scale the Size by</param>
142 /// <returns>A Size containing the result of the scaling</returns>
143 public static Size2D operator /(Size2D arg1, int arg2)
145 return arg1.Divide(arg2);
149 /// Array subscript operator.
151 /// <param name="index">Subscript index</param>
152 /// <returns>The float at the given index</returns>
153 public float this[uint index]
157 return ValueOfIndex(index);
162 /// Get Size from pointer.
164 /// <param name="cPtr">Pointer of the Size</param>
165 /// <returns>Size</returns>
166 internal static Size2D GetSize2DFromPtr(global::System.IntPtr cPtr)
168 Size2D ret = new Size2D(cPtr, false);
169 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
176 public Size2D() : this(NDalicPINVOKE.new_Vector2__SWIG_0(), true)
178 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
184 /// <param name="x">x (or width) component</param>
185 /// <param name="y">y (or height) component</param>
186 public Size2D(int x, int y) : this(NDalicPINVOKE.new_Vector2__SWIG_1((float)x, (float)y), true)
188 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
194 /// <param name="size">Size with x (width), y (height), and z (depth)</param>
195 public Size2D(Size size) : this(NDalicPINVOKE.new_Vector2__SWIG_3(Size.getCPtr(size)), true)
197 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
200 private Size2D Add(Size2D rhs)
202 Size2D ret = new Size2D(NDalicPINVOKE.Vector2_Add(swigCPtr, Size2D.getCPtr(rhs)), true);
203 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
207 private Size2D Subtract(Size2D rhs)
209 Size2D ret = new Size2D(NDalicPINVOKE.Vector2_Subtract__SWIG_0(swigCPtr, Size2D.getCPtr(rhs)), true);
210 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215 private Size2D Multiply(Size2D rhs)
217 Size2D ret = new Size2D(NDalicPINVOKE.Vector2_Multiply__SWIG_0(swigCPtr, Size2D.getCPtr(rhs)), true);
218 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
222 private Size2D Multiply(int rhs)
224 Size2D ret = new Size2D(NDalicPINVOKE.Vector2_Multiply__SWIG_1(swigCPtr, (float)rhs), true);
225 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
230 private Size2D Divide(Size2D rhs)
232 Size2D ret = new Size2D(NDalicPINVOKE.Vector2_Divide__SWIG_0(swigCPtr, Size2D.getCPtr(rhs)), true);
233 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
237 private Size2D Divide(int rhs)
239 Size2D ret = new Size2D(NDalicPINVOKE.Vector2_Divide__SWIG_1(swigCPtr, (float)rhs), true);
240 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
244 private Size2D Subtract()
246 Size2D ret = new Size2D(NDalicPINVOKE.Vector2_Subtract__SWIG_1(swigCPtr), true);
247 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
252 /// Check equality.<br>
253 /// Utilizes appropriate machine epsilon values.<br>
255 /// <param name="rhs">The Size to test against</param>
256 /// <returns>True if the Sizes are equal</returns>
257 public bool EqualTo(Size2D rhs)
259 bool ret = NDalicPINVOKE.Vector2_EqualTo(swigCPtr, Size2D.getCPtr(rhs));
260 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
265 /// Check inequality.<br>
266 /// Utilizes appropriate machine epsilon values.<br>
268 /// <param name="rhs">The Size to test against</param>
269 /// <returns>True if the Sizes are not equal</returns>
270 public bool NotEqualTo(Size2D rhs)
272 bool ret = NDalicPINVOKE.Vector2_NotEqualTo(swigCPtr, Size2D.getCPtr(rhs));
273 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
277 private int ValueOfIndex(uint index)
279 int ret = (int)NDalicPINVOKE.Vector2_ValueOfIndex__SWIG_0(swigCPtr, index);
280 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
285 /// Property for width component of Size
291 NDalicPINVOKE.Vector2_Width_set(swigCPtr, (float)value);
292 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
296 float ret = NDalicPINVOKE.Vector2_Width_get(swigCPtr);
297 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
303 /// Property for height component of Size
309 NDalicPINVOKE.Vector2_Height_set(swigCPtr, (float)value);
310 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
314 float ret = NDalicPINVOKE.Vector2_Height_get(swigCPtr);
315 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
321 /// Type cast operator, Size2D to Vector2.
323 /// <param name="size">Object of Size2D type</param>
324 public static implicit operator Vector2(Size2D size)
326 return new Vector2((float)size.Width, (float)size.Height);
330 /// Type cast operator, Vector2 to Size2D type.
332 /// <param name="vec">Object of Vector2 type</param>
333 public static implicit operator Size2D(Vector2 vec)
335 return new Size2D((int)vec.X, (int)vec.Y);