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 /// Position2D is a two dimensional vector.
23 public class Position2D : global::System.IDisposable {
24 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
25 protected bool swigCMemOwn;
27 internal Position2D(global::System.IntPtr cPtr, bool cMemoryOwn) {
28 swigCMemOwn = cMemoryOwn;
29 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
32 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Position2D obj) {
33 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
37 DisposeQueue.Instance.Add(this);
40 public virtual void Dispose() {
41 if (!Window.IsInstalled()) {
42 DisposeQueue.Instance.Add(this);
47 if (swigCPtr.Handle != global::System.IntPtr.Zero) {
50 NDalicPINVOKE.delete_Vector2(swigCPtr);
52 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
54 global::System.GC.SuppressFinalize(this);
59 /// Addition operator.
61 /// <param name="arg1">Vector to add</param>
62 /// <param name="arg2">Vector to add</param>
63 /// <returns>A vector containing the result of the addition</returns>
64 public static Position2D operator+(Position2D arg1, Position2D arg2) {
65 return arg1.Add(arg2);
69 /// Subtraction operator.
71 /// <param name="arg1">Vector to subtract</param>
72 /// <param name="arg2">Vector to subtract</param>
73 /// <returns>A vector containing the result of the subtraction</returns>
74 public static Position2D operator-(Position2D arg1, Position2D arg2) {
75 return arg1.Subtract(arg2);
79 /// Unary negation operator.
81 /// <param name="arg1">Vector to netate</param>
82 /// <returns>A vector containing the negation</returns>
83 public static Position2D operator-(Position2D arg1) {
84 return arg1.Subtract();
88 /// Multiplication operator.
90 /// <param name="arg1">Vector to multiply</param>
91 /// <param name="arg2">Vector to multiply</param>
92 /// <returns>A vector containing the result of the multiplication</returns>
93 public static Position2D operator*(Position2D arg1, Position2D arg2) {
94 return arg1.Multiply(arg2);
98 /// Multiplication operator.
100 /// <param name="arg1">Vector to multiply</param>
101 /// <param name="arg2">The int value to scale the vector</param>
102 /// <returns>A vector containing the result of the multiplication</returns>
103 public static Position2D operator*(Position2D arg1, int arg2) {
104 return arg1.Multiply(arg2);
108 /// Division operator.
110 /// <param name="arg1">Vector to divide</param>
111 /// <param name="arg2">Vector to divide</param>
112 /// <returns>A vector containing the result of the division</returns>
113 public static Position2D operator/(Position2D arg1, Position2D arg2) {
114 return arg1.Divide(arg2);
118 /// Division operator.
120 /// <param name="arg1">Vector to divide</param>
121 /// <param name="arg2">The int value to scale the vector by</param>
122 /// <returns>A vector containing the result of the division</returns>
123 public static Position2D operator/(Position2D arg1, int arg2) {
124 return arg1.Divide(arg2);
128 /// Const array subscript operator overload. Should be 0, or 1.
130 /// <param name="index">Subscript index</param>
131 /// <returns>The float at the given index</returns>
132 public float this[uint index]
136 return ValueOfIndex(index);
140 internal static Position2D GetPosition2DFromPtr(global::System.IntPtr cPtr) {
141 Position2D ret = new Position2D(cPtr, false);
142 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
149 public Position2D() : this(NDalicPINVOKE.new_Vector2__SWIG_0(), true) {
150 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
156 /// <param name="x">x component</param>
157 /// <param name="y">y component</param>
158 public Position2D(int x, int y) : this(NDalicPINVOKE.new_Vector2__SWIG_1((float)x, (float)y), true) {
159 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
165 /// <param name="position">Position to create this vector from</param>
166 public Position2D(Position position) : this(NDalicPINVOKE.new_Vector2__SWIG_3(Position.getCPtr(position)), true) {
167 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
170 private Position2D Add(Position2D rhs) {
171 Position2D ret = new Position2D(NDalicPINVOKE.Vector2_Add(swigCPtr, Position2D.getCPtr(rhs)), true);
172 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
176 private Position2D Subtract(Position2D rhs) {
177 Position2D ret = new Position2D(NDalicPINVOKE.Vector2_Subtract__SWIG_0(swigCPtr, Position2D.getCPtr(rhs)), true);
178 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
183 private Position2D Multiply(Position2D rhs) {
184 Position2D ret = new Position2D(NDalicPINVOKE.Vector2_Multiply__SWIG_0(swigCPtr, Position2D.getCPtr(rhs)), true);
185 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
189 private Position2D Multiply(int rhs) {
190 Position2D ret = new Position2D(NDalicPINVOKE.Vector2_Multiply__SWIG_1(swigCPtr, (float)rhs), true);
191 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
196 private Position2D Divide(Position2D rhs) {
197 Position2D ret = new Position2D(NDalicPINVOKE.Vector2_Divide__SWIG_0(swigCPtr, Position2D.getCPtr(rhs)), true);
198 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
202 private Position2D Divide(int rhs) {
203 Position2D ret = new Position2D(NDalicPINVOKE.Vector2_Divide__SWIG_1(swigCPtr, (float)rhs), true);
204 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
208 private Position2D Subtract() {
209 Position2D ret = new Position2D(NDalicPINVOKE.Vector2_Subtract__SWIG_1(swigCPtr), true);
210 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215 /// Compare if rhs is equal to.
217 /// <param name="rhs">The vector to compare</param>
218 /// <returns>Returns true if the two vectors are equal, otherwise false</returns>
219 public bool EqualTo(Position2D rhs) {
220 bool ret = NDalicPINVOKE.Vector2_EqualTo(swigCPtr, Position2D.getCPtr(rhs));
221 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
226 /// Compare if rhs is not equal to.
228 /// <param name="rhs">The vector to compare</param>
229 /// <returns>Returns true if the two vectors are not equal, otherwise false</returns>
230 public bool NotEqualTo(Position2D rhs) {
231 bool ret = NDalicPINVOKE.Vector2_NotEqualTo(swigCPtr, Position2D.getCPtr(rhs));
232 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
236 private int ValueOfIndex(uint index) {
237 int ret = (int)NDalicPINVOKE.Vector2_ValueOfIndex__SWIG_0(swigCPtr, index);
238 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
247 NDalicPINVOKE.Vector2_X_set(swigCPtr, (float)value);
248 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
251 float ret = NDalicPINVOKE.Vector2_X_get(swigCPtr);
252 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
262 NDalicPINVOKE.Vector2_Y_set(swigCPtr, (float)value);
263 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
266 float ret = NDalicPINVOKE.Vector2_Y_get(swigCPtr);
267 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
273 /// Convert a position2D instance to a vector2 instance.
275 public static implicit operator Vector2(Position2D position2d)
277 return new Vector2((float)position2d.X, (float)position2d.Y);
281 /// Convert a vector2 instance to a position2D instance.
283 public static implicit operator Position2D(Vector2 vec)
285 return new Position2D((int)vec.X, (int)vec.Y);