[NUI] Sync with dalihub & API5 branch (#631)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Radian.cs
1 /*
2  * Copyright(c) 2017 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 namespace Tizen.NUI
19 {
20     /// <summary>
21     /// An angle in radians.
22     /// </summary>
23     /// <since_tizen> 3 </since_tizen>
24     public class Radian : global::System.IDisposable
25     {
26         /// <summary>
27         /// swigCMemOwn
28         /// </summary>
29         /// <since_tizen> 3 </since_tizen>
30         protected bool swigCMemOwn;
31
32         /// <summary>
33         /// A Flat to check if it is already disposed.
34         /// </summary>
35         /// <since_tizen> 3 </since_tizen>
36         protected bool disposed = false;
37
38         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
39
40         //A Flag to check who called Dispose(). (By User or DisposeQueue)
41         private bool isDisposeQueued = false;
42
43         /// <summary>
44         /// The default constructor, initializes to 0.
45         /// </summary>
46         /// <since_tizen> 3 </since_tizen>
47         public Radian() : this(NDalicPINVOKE.new_Radian__SWIG_0(), true)
48         {
49             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
50         }
51
52         /// <summary>
53         /// Creates an angle in radians.
54         /// </summary>
55         /// <param name="value">The initial value in radians.</param>
56         /// <since_tizen> 3 </since_tizen>
57         public Radian(float value) : this(NDalicPINVOKE.new_Radian__SWIG_1(value), true)
58         {
59             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
60         }
61
62         /// <summary>
63         /// Creates an angle in radians from an angle in degrees.
64         /// </summary>
65         /// <param name="degree">The initial value in degrees.</param>
66         /// <since_tizen> 3 </since_tizen>
67         public Radian(Degree degree) : this(NDalicPINVOKE.new_Radian__SWIG_2(Degree.getCPtr(degree)), true)
68         {
69             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
70         }
71
72         internal Radian(global::System.IntPtr cPtr, bool cMemoryOwn)
73         {
74             swigCMemOwn = cMemoryOwn;
75             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
76         }
77
78         /// <summary>
79         /// Dispose.
80         /// </summary>
81         /// <since_tizen> 3 </since_tizen>
82         ~Radian()
83         {
84             if (!isDisposeQueued)
85             {
86                 isDisposeQueued = true;
87                 DisposeQueue.Instance.Add(this);
88             }
89         }
90
91         /// <summary>
92         /// The value in radians.
93         /// </summary>
94         /// <since_tizen> 3 </since_tizen>
95         public float Value
96         {
97             set
98             {
99                 NDalicPINVOKE.Radian_radian_set(swigCPtr, value);
100                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
101             }
102             get
103             {
104                 float ret = NDalicPINVOKE.Radian_radian_get(swigCPtr);
105                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
106                 return ret;
107             }
108         }
109
110         /// <summary>
111         /// Dispose.
112         /// </summary>
113         /// <since_tizen> 3 </since_tizen>
114         public void Dispose()
115         {
116             //Throw excpetion if Dispose() is called in separate thread.
117             if (!Window.IsInstalled())
118             {
119                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
120             }
121
122             if (isDisposeQueued)
123             {
124                 Dispose(DisposeTypes.Implicit);
125             }
126             else
127             {
128                 Dispose(DisposeTypes.Explicit);
129                 System.GC.SuppressFinalize(this);
130             }
131         }
132
133         /// <summary>
134         /// Conversion to float.
135         /// </summary>
136         /// <returns>The float value of this radian.</returns>
137         /// <since_tizen> 3 </since_tizen>
138         public float ConvertToFloat()
139         {
140             float ret = NDalicPINVOKE.Radian_ConvertToFloat(swigCPtr);
141             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
142             return ret;
143         }
144
145         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Radian obj)
146         {
147             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
148         }
149
150         /// <summary>
151         /// Dispose.
152         /// </summary>
153         /// <since_tizen> 3 </since_tizen>
154         protected virtual void Dispose(DisposeTypes type)
155         {
156             if (disposed)
157             {
158                 return;
159             }
160
161             if(type == DisposeTypes.Explicit)
162             {
163                 //Called by User
164                 //Release your own managed resources here.
165                 //You should release all of your own disposable objects here.
166             }
167
168             //Release your own unmanaged resources here.
169             //You should not access any managed member here except static instance.
170             //because the execution order of Finalizes is non-deterministic.
171
172             if (swigCPtr.Handle != global::System.IntPtr.Zero)
173             {
174                 if (swigCMemOwn)
175                 {
176                     swigCMemOwn = false;
177                     NDalicPINVOKE.delete_Radian(swigCPtr);
178                 }
179                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
180             }
181             disposed = true;
182         }
183     }
184 }