[NUI] Reduce code duplication - refactor dispose codes (#1010)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / PropertyCondition.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     /// A condition that can be evaluated on a Property Value
22     /// </summary>
23     /// <since_tizen> 4 </since_tizen>
24     public class PropertyCondition : BaseHandle
25     {
26         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
27
28         /// <summary>
29         /// Create a property condition instance.
30         /// </summary>
31         /// <since_tizen> 4 </since_tizen>
32         public PropertyCondition() : this(Interop.PropertyCondition.new_PropertyCondition__SWIG_0(), true)
33         {
34             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
35         }
36
37         internal PropertyCondition(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.PropertyCondition.PropertyCondition_SWIGUpcast(cPtr), cMemoryOwn)
38         {
39             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
40         }
41
42         /// <summary>
43         /// Retrieves the arguments that this condition uses.
44         /// </summary>
45         /// <returns>The arguments used for this condition.</returns>
46         /// <since_tizen> 4 </since_tizen>
47         public uint GetArgumentCount()
48         {
49             uint ret = Interop.PropertyCondition.PropertyCondition_GetArgumentCount(swigCPtr);
50             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
51             return ret;
52         }
53
54         /// <summary>
55         /// Retrieves the arguments that this condition uses
56         /// </summary>
57         /// <param name="index">The condition index to get the argument.</param>
58         /// <returns>The arguments used for this condition.</returns>
59         /// <since_tizen> 4 </since_tizen>
60         public float GetArgument(uint index)
61         {
62             float ret = Interop.PropertyCondition.PropertyCondition_GetArgument(swigCPtr, index);
63             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
64             return ret;
65         }
66
67         /// <summary>
68         /// LessThan condition compares whether property is less than arg.
69         /// </summary>
70         /// <param name="arg">The argument for the condition.</param>
71         /// <returns>A property condition function object.</returns>
72         /// <since_tizen> 4 </since_tizen>
73         public static PropertyCondition LessThan(float arg)
74         {
75             PropertyCondition ret = new PropertyCondition(Interop.PropertyCondition.LessThanCondition(arg), true);
76             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
77             return ret;
78         }
79
80         /// <summary>
81         /// GreaterThan condition compares whether property is greater than arg.
82         /// </summary>
83         /// <param name="arg">The argument for the condition.</param>
84         /// <returns>A property condition function object.</returns>
85         /// <since_tizen> 4 </since_tizen>
86         public static PropertyCondition GreaterThan(float arg)
87         {
88             PropertyCondition ret = new PropertyCondition(Interop.PropertyCondition.GreaterThanCondition(arg), true);
89             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
90             return ret;
91         }
92
93         /// <summary>
94         /// Inside condition compares whether property is greater than arg0 and less than arg1.
95         /// </summary>
96         /// <param name="arg0">The first argument for the condition.</param>
97         /// <param name="arg1">The second argument for the condition.</param>
98         /// <returns>A property condition function object.</returns>
99         /// <since_tizen> 4 </since_tizen>
100         public static PropertyCondition Inside(float arg0, float arg1)
101         {
102             PropertyCondition ret = new PropertyCondition(Interop.PropertyCondition.InsideCondition(arg0, arg1), true);
103             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
104             return ret;
105         }
106
107         /// <summary>
108         /// Outside condition compares whether property is less than arg0 or greater than arg1
109         /// </summary>
110         /// <param name="arg0">The first argument for the condition.</param>
111         /// <param name="arg1">The second argument for the condition.</param>
112         /// <returns>A property condition function object.</returns>
113         /// <since_tizen> 4 </since_tizen>
114         public static PropertyCondition Outside(float arg0, float arg1)
115         {
116             PropertyCondition ret = new PropertyCondition(Interop.PropertyCondition.OutsideCondition(arg0, arg1), true);
117             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
118             return ret;
119         }
120
121         /// <summary>
122         /// Detects when a property changes by stepAmount from initialValue, in both positive and negative directions. This will continue checking for multiples of stepAmount.
123         /// </summary>
124         /// <param name="stepAmount">The step size required to trigger condition.</param>
125         /// <param name="initialValue">The initial value to step from.</param>
126         /// <returns>A property condition function object.</returns>
127         /// <since_tizen> 4 </since_tizen>
128         public static PropertyCondition Step(float stepAmount, float initialValue)
129         {
130             PropertyCondition ret = new PropertyCondition(Interop.PropertyCondition.StepCondition__SWIG_0(stepAmount, initialValue), true);
131             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
132             return ret;
133         }
134
135         /// <summary>
136         /// Receives notifications as a property goes above/below the inputted values. Values must be ordered and can be either ascending or descending.
137         /// </summary>
138         /// <param name="stepAmount">List of values to receive notifications for as a property crosses them.</param>
139         /// <returns>A property condition function object.</returns>
140         /// <since_tizen> 4 </since_tizen>
141         public static PropertyCondition Step(float stepAmount)
142         {
143             PropertyCondition ret = new PropertyCondition(Interop.PropertyCondition.StepCondition__SWIG_1(stepAmount), true);
144             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
145             return ret;
146         }
147
148         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyCondition obj)
149         {
150             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
151         }
152
153         /// <summary>
154         /// Dispose.
155         /// </summary>
156         /// <since_tizen> 4 </since_tizen>
157         protected override void Dispose(DisposeTypes type)
158         {
159             if (disposed)
160             {
161                 return;
162             }
163
164             //Release your own unmanaged resources here.
165             //You should not access any managed member here except static instance.
166             //because the execution order of Finalizes is non-deterministic.
167
168             if (swigCPtr.Handle != global::System.IntPtr.Zero)
169             {
170                 if (swigCMemOwn)
171                 {
172                     swigCMemOwn = false;
173                     Interop.PropertyCondition.delete_PropertyCondition(swigCPtr);
174                 }
175                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
176             }
177
178             base.Dispose(type);
179         }
180     }
181 }