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