Support TranslatablePlaceholderTextFocused to TextField
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / KeyValue.cs
1 /*
2  * Copyright(c) 2019 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 using System;
19 using Tizen.NUI.Binding;
20
21 namespace Tizen.NUI
22 {
23     /// <summary>
24     /// KeyValue class.
25     /// </summary>
26     public class KeyValue
27     {
28         /// <summary>
29         /// Int key.
30         /// </summary>
31         public int? KeyInt = null;
32
33         /// <summary>
34         /// String key.
35         /// </summary>
36         public string KeyString = null;
37
38         /// <summary>
39         /// True value.
40         /// </summary>
41         public PropertyValue TrueValue = null;
42
43         private string _key = null;
44         private object _originalValue = null;
45         private object _originalKey = null;
46
47         /// <summary>
48         /// Default Constructor.
49         /// </summary>
50         public KeyValue()
51         { }
52
53         /// <summary>
54         /// Key property.
55         /// </summary>
56         public string Key
57         {
58             get
59             {
60                 return _key;
61             }
62             set
63             {
64                 _key = value;
65                 ParseKey(value);
66             }
67         }
68
69         /// <summary>
70         /// OriginalKey property.
71         /// </summary>
72         public object OriginalKey
73         {
74             get
75             {
76                 return _originalKey;
77             }
78             set
79             {
80                 _originalKey = value;
81                 if (value is int || value is Int32)
82                 {
83                     KeyInt = (int)value;
84                 }
85                 else if (value is string)
86                 {
87                     KeyString = value.ToString();
88                 }
89                 else if (value.GetType().Equals(typeof(int)) || value.GetType().Equals(typeof(Int32)))
90                 {
91                     KeyInt = (int)value;
92                 }
93                 else if (value.GetType().Equals(typeof(string)))
94                 {
95                     KeyString = value.ToString();
96                 }
97             }
98         }
99
100         /// <summary>
101         /// Value property.
102         /// </summary>
103         public object Value
104         {
105             get
106             {
107                 return _originalValue;
108             }
109             set
110             {
111                 _originalValue = value;
112                 TrueValue = PropertyValue.CreateFromObject(value);
113             }
114         }
115
116         /// <summary>
117         /// IntergerValue property.
118         /// </summary>
119         public int IntergerValue
120         {
121             set
122             {
123                 TrueValue = new PropertyValue(value);
124             }
125         }
126
127         /// <summary>
128         /// BooleanValue property.
129         /// </summary>
130         public bool BooleanValue
131         {
132             set
133             {
134                 TrueValue = new PropertyValue(value);
135             }
136         }
137
138         /// <summary>
139         /// SingleValue property.
140         /// </summary>
141         public float SingleValue
142         {
143             set
144             {
145                 TrueValue = new PropertyValue(value);
146             }
147         }
148
149         /// <summary>
150         /// StringValue property.
151         /// </summary>
152         public string StringValue
153         {
154             set
155             {
156                 TrueValue = new PropertyValue(value);
157             }
158         }
159
160         /// <summary>
161         /// Vector2Value property.
162         /// </summary>
163         public Vector2 Vector2Value
164         {
165             set
166             {
167                 TrueValue = new PropertyValue(value);
168             }
169         }
170
171         /// <summary>
172         /// Vector3Value property.
173         /// </summary>
174         public Vector3 Vector3Value
175         {
176             set
177             {
178                 TrueValue = new PropertyValue(value);
179             }
180         }
181
182         /// <summary>
183         /// Vector4Value property.
184         /// </summary>
185         public Vector4 Vector4Value
186         {
187             set
188             {
189                 TrueValue = new PropertyValue(value);
190             }
191         }
192
193         /// <summary>
194         /// PositionValue property.
195         /// </summary>
196         public Position PositionValue
197         {
198             set
199             {
200                 TrueValue = new PropertyValue(value);
201             }
202         }
203
204         /// <summary>
205         /// Position2DValue property.
206         /// </summary>
207         public Position2D Position2DValue
208         {
209             set
210             {
211                 TrueValue = new PropertyValue(value);
212             }
213         }
214
215         /// <summary>
216         /// SizeValue property.
217         /// </summary>
218         public Size SizeValue
219         {
220             set
221             {
222                 TrueValue = new PropertyValue(value);
223             }
224         }
225
226         /// <summary>
227         /// Size2DValue property.
228         /// </summary>
229         public Size2D Size2DValue
230         {
231             set
232             {
233                 TrueValue = new PropertyValue(value);
234             }
235         }
236
237         /// <summary>
238         /// ColorValue property.
239         /// </summary>
240         public Color ColorValue
241         {
242             set
243             {
244                 TrueValue = new PropertyValue(value);
245             }
246         }
247
248         /// <summary>
249         /// RectangleValue property.
250         /// </summary>
251         public Rectangle RectangleValue
252         {
253             set
254             {
255                 TrueValue = new PropertyValue(value);
256             }
257         }
258
259         /// <summary>
260         /// RotationValue property.
261         /// </summary>
262         public Rotation RotationValue
263         {
264             set
265             {
266                 TrueValue = new PropertyValue(value);
267             }
268         }
269
270         /// <summary>
271         /// RelativeVector2Value property.
272         /// </summary>
273         public RelativeVector2 RelativeVector2Value
274         {
275             set
276             {
277                 TrueValue = new PropertyValue(value);
278             }
279         }
280
281         /// <summary>
282         /// RelativeVector3Value property.
283         /// </summary>
284         public RelativeVector3 RelativeVector3Value
285         {
286             set
287             {
288                 TrueValue = new PropertyValue(value);
289             }
290         }
291
292         /// <summary>
293         /// RelativeVector4Value property.
294         /// </summary>
295         public RelativeVector4 RelativeVector4Value
296         {
297             set
298             {
299                 TrueValue = new PropertyValue(value);
300             }
301         }
302
303         /// <summary>
304         /// ExtentsValue property.
305         /// </summary>
306         public Extents ExtentsValue
307         {
308             set
309             {
310                 TrueValue = new PropertyValue(value);
311             }
312         }
313
314         /// <summary>
315         /// PropertyArrayValue property.
316         /// </summary>
317         public PropertyArray PropertyArrayValue
318         {
319             set
320             {
321                 TrueValue = new PropertyValue(value);
322             }
323         }
324
325         /// <summary>
326         /// PropertyMapValue property.
327         /// </summary>
328         public PropertyMap PropertyMapValue
329         {
330             set
331             {
332                 TrueValue = new PropertyValue(value);
333             }
334         }
335
336         private void ParseKey(string key)
337         {
338             int v = -1;
339             if (VisualExtension.KeyDictionary.ContainsKey(key))
340             {
341                 VisualExtension.KeyDictionary.TryGetValue(key, out v);
342                 KeyInt = v;
343             }
344             else
345             {
346                 KeyString = Key;
347             }
348         }
349     }
350 }