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