1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
20 internal class TouchPointContainer : global::System.IDisposable, global::System.Collections.IEnumerable
21 , global::System.Collections.Generic.IEnumerable<TouchPoint>
23 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
24 protected bool swigCMemOwn;
26 internal TouchPointContainer(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(TouchPointContainer obj)
34 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
37 //A Flag to check who called Dispose(). (By User or DisposeQueue)
38 private bool isDisposeQueued = false;
39 //A Flat to check if it is already disposed.
40 protected bool disposed = false;
43 ~TouchPointContainer()
47 isDisposeQueued = true;
48 DisposeQueue.Instance.Add(this);
54 //Throw excpetion if Dispose() is called in separate thread.
55 if (!Window.IsInstalled())
57 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
62 Dispose(DisposeTypes.Implicit);
66 Dispose(DisposeTypes.Explicit);
67 System.GC.SuppressFinalize(this);
71 protected virtual void Dispose(DisposeTypes type)
78 if (type == DisposeTypes.Explicit)
81 //Release your own managed resources here.
82 //You should release all of your own disposable objects here.
86 //Release your own unmanaged resources here.
87 //You should not access any managed member here except static instance.
88 //because the execution order of Finalizes is non-deterministic.
90 if (swigCPtr.Handle != global::System.IntPtr.Zero)
95 NDalicPINVOKE.delete_TouchPointContainer(swigCPtr);
97 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
103 public TouchPointContainer(global::System.Collections.ICollection c) : this()
106 throw new global::System.ArgumentNullException("c");
107 foreach (TouchPoint element in c)
113 public bool IsFixedSize
121 public bool IsReadOnly
129 public TouchPoint this[int index]
133 return getitem(index);
137 setitem(index, value);
145 return (int)capacity();
150 throw new global::System.ArgumentOutOfRangeException("Capacity");
151 reserve((uint)value);
163 public bool IsSynchronized
171 public void CopyTo(TouchPoint[] array)
173 CopyTo(0, array, 0, this.Count);
176 public void CopyTo(TouchPoint[] array, int arrayIndex)
178 CopyTo(0, array, arrayIndex, this.Count);
181 public void CopyTo(int index, TouchPoint[] array, int arrayIndex, int count)
184 throw new global::System.ArgumentNullException("array");
186 throw new global::System.ArgumentOutOfRangeException("index", "Value is less than zero");
188 throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero");
190 throw new global::System.ArgumentOutOfRangeException("count", "Value is less than zero");
192 throw new global::System.ArgumentException("Multi dimensional array.", "array");
193 if (index + count > this.Count || arrayIndex + count > array.Length)
194 throw new global::System.ArgumentException("Number of elements to copy is too large.");
195 for (int i = 0; i < count; i++)
196 array.SetValue(getitemcopy(index + i), arrayIndex + i);
199 global::System.Collections.Generic.IEnumerator<TouchPoint> global::System.Collections.Generic.IEnumerable<TouchPoint>.GetEnumerator()
201 return new TouchPointContainerEnumerator(this);
204 global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
206 return new TouchPointContainerEnumerator(this);
209 public TouchPointContainerEnumerator GetEnumerator()
211 return new TouchPointContainerEnumerator(this);
214 // Type-safe enumerator
215 /// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown
216 /// whenever the collection is modified. This has been done for changes in the size of the
217 /// collection but not when one of the elements of the collection is modified as it is a bit
218 /// tricky to detect unmanaged code that modifies the collection under our feet.
219 public sealed class TouchPointContainerEnumerator : global::System.Collections.IEnumerator
220 , global::System.Collections.Generic.IEnumerator<TouchPoint>
222 private TouchPointContainer collectionRef;
223 private int currentIndex;
224 private object currentObject;
225 private int currentSize;
227 public TouchPointContainerEnumerator(TouchPointContainer collection)
229 collectionRef = collection;
231 currentObject = null;
232 currentSize = collectionRef.Count;
235 // Type-safe iterator Current
236 public TouchPoint Current
240 if (currentIndex == -1)
241 throw new global::System.InvalidOperationException("Enumeration not started.");
242 if (currentIndex > currentSize - 1)
243 throw new global::System.InvalidOperationException("Enumeration finished.");
244 if (currentObject == null)
245 throw new global::System.InvalidOperationException("Collection modified.");
246 return (TouchPoint)currentObject;
250 // Type-unsafe IEnumerator.Current
251 object global::System.Collections.IEnumerator.Current
259 public bool MoveNext()
261 int size = collectionRef.Count;
262 bool moveOkay = (currentIndex + 1 < size) && (size == currentSize);
266 currentObject = collectionRef[currentIndex];
270 currentObject = null;
278 currentObject = null;
279 if (collectionRef.Count != currentSize)
281 throw new global::System.InvalidOperationException("Collection modified.");
285 public void Dispose()
288 currentObject = null;
294 NDalicPINVOKE.TouchPointContainer_Clear(swigCPtr);
295 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
298 public void Add(TouchPoint x)
300 NDalicPINVOKE.TouchPointContainer_Add(swigCPtr, TouchPoint.getCPtr(x));
301 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
306 uint ret = NDalicPINVOKE.TouchPointContainer_size(swigCPtr);
307 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
311 private uint capacity()
313 uint ret = NDalicPINVOKE.TouchPointContainer_capacity(swigCPtr);
314 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
318 private void reserve(uint n)
320 NDalicPINVOKE.TouchPointContainer_reserve(swigCPtr, n);
321 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
324 public TouchPointContainer() : this(NDalicPINVOKE.new_TouchPointContainer__SWIG_0(), true)
326 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
329 public TouchPointContainer(TouchPointContainer other) : this(NDalicPINVOKE.new_TouchPointContainer__SWIG_1(TouchPointContainer.getCPtr(other)), true)
331 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
334 public TouchPointContainer(int capacity) : this(NDalicPINVOKE.new_TouchPointContainer__SWIG_2(capacity), true)
336 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
339 private TouchPoint getitemcopy(int index)
341 TouchPoint ret = new TouchPoint(NDalicPINVOKE.TouchPointContainer_getitemcopy(swigCPtr, index), true);
342 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
346 private TouchPoint getitem(int index)
348 TouchPoint ret = new TouchPoint(NDalicPINVOKE.TouchPointContainer_getitem(swigCPtr, index), false);
349 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
353 private void setitem(int index, TouchPoint val)
355 NDalicPINVOKE.TouchPointContainer_setitem(swigCPtr, index, TouchPoint.getCPtr(val));
356 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
359 public void AddRange(TouchPointContainer values)
361 NDalicPINVOKE.TouchPointContainer_AddRange(swigCPtr, TouchPointContainer.getCPtr(values));
362 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
365 public TouchPointContainer GetRange(int index, int count)
367 global::System.IntPtr cPtr = NDalicPINVOKE.TouchPointContainer_GetRange(swigCPtr, index, count);
368 TouchPointContainer ret = (cPtr == global::System.IntPtr.Zero) ? null : new TouchPointContainer(cPtr, true);
369 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
373 public void Insert(int index, TouchPoint x)
375 NDalicPINVOKE.TouchPointContainer_Insert(swigCPtr, index, TouchPoint.getCPtr(x));
376 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
379 public void InsertRange(int index, TouchPointContainer values)
381 NDalicPINVOKE.TouchPointContainer_InsertRange(swigCPtr, index, TouchPointContainer.getCPtr(values));
382 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
385 public void RemoveAt(int index)
387 NDalicPINVOKE.TouchPointContainer_RemoveAt(swigCPtr, index);
388 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
391 public void RemoveRange(int index, int count)
393 NDalicPINVOKE.TouchPointContainer_RemoveRange(swigCPtr, index, count);
394 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
397 public static TouchPointContainer Repeat(TouchPoint value, int count)
399 global::System.IntPtr cPtr = NDalicPINVOKE.TouchPointContainer_Repeat(TouchPoint.getCPtr(value), count);
400 TouchPointContainer ret = (cPtr == global::System.IntPtr.Zero) ? null : new TouchPointContainer(cPtr, true);
401 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
405 public void Reverse()
407 NDalicPINVOKE.TouchPointContainer_Reverse__SWIG_0(swigCPtr);
408 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
411 public void Reverse(int index, int count)
413 NDalicPINVOKE.TouchPointContainer_Reverse__SWIG_1(swigCPtr, index, count);
414 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
417 public void SetRange(int index, TouchPointContainer values)
419 NDalicPINVOKE.TouchPointContainer_SetRange(swigCPtr, index, TouchPointContainer.getCPtr(values));
420 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();