Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / ElmSharp.Wearable / ElmSharp.Wearable / CircleProgressBar.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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 using System;
18
19 namespace ElmSharp.Wearable
20 {
21
22     /// <summary>
23     /// The Circle ProgressBar is a widget for visually representing the progress status of a given job/task with the circular design.
24     /// </summary>
25     public class CircleProgressBar : EvasObject
26     {
27         private IntPtr _circleHandle;
28
29         /// <summary>
30         /// Creates and initializes a new instance of the Circle Progressbar class.
31         /// </summary>
32         /// <param name="parent">The parent of new Circle Progressbar instance</param>
33         public CircleProgressBar(EvasObject parent) : base(parent)
34         {
35         }
36
37
38         /// <summary>
39         /// Sets or gets the value of ProgressBar.
40         /// </summary>
41         public double Value
42         {
43             get
44             {
45                 return Interop.Eext.eext_circle_object_value_get(_circleHandle);
46             }
47             set
48             {
49                 Interop.Eext.eext_circle_object_value_set(_circleHandle, value);
50             }
51         }
52
53         /// <summary>
54         /// Sets or gets the maximum value of ProgressBar.
55         /// </summary>
56         public double Maximum
57         {
58             get
59             {
60                 double max = 0;
61                 double min = 0;
62                 Interop.Eext.eext_circle_object_value_min_max_get(_circleHandle, out min, out max);
63                 return max;
64             }
65             set
66             {
67                 double min = Minimum;
68                 Interop.Eext.eext_circle_object_value_min_max_set(_circleHandle, min, value);
69             }
70         }
71
72         /// <summary>
73         /// Sets or gets the minimum value of ProgressBar.
74         /// </summary>
75         public double Minimum
76         {
77             get
78             {
79                 double max = 0;
80                 double min = 0;
81                 Interop.Eext.eext_circle_object_value_min_max_get(_circleHandle, out min, out max);
82                 return min;
83             }
84             set
85             {
86                 double max = Maximum;
87                 Interop.Eext.eext_circle_object_value_min_max_set(_circleHandle, value, max);
88             }
89         }
90
91         /// <summary>
92         /// Sets or gets the angle value of ProgressBar.
93         /// </summary>
94         public double BarAngle
95         {
96             get
97             {
98                 return Interop.Eext.eext_circle_object_angle_get(_circleHandle);
99             }
100             set
101             {
102                 Interop.Eext.eext_circle_object_angle_set(_circleHandle, value);
103             }
104         }
105
106         /// <summary>
107         /// Sets or gets the angle value of Background ProgressBar.
108         /// </summary>
109         public double BackgroundAngle
110         {
111             get
112             {
113                 return Interop.Eext.eext_circle_object_item_angle_get(_circleHandle, "bg");
114             }
115             set
116             {
117                 Interop.Eext.eext_circle_object_item_angle_set(_circleHandle, "bg", value);
118             }
119         }
120
121         /// <summary>
122         /// Sets or gets the angle offset value of ProgressBar.
123         /// </summary>
124         public double BarAngleOffset
125         {
126             get
127             {
128                 return Interop.Eext.eext_circle_object_angle_offset_get(_circleHandle);
129             }
130             set
131             {
132                 Interop.Eext.eext_circle_object_angle_offset_set(_circleHandle, value);
133             }
134         }
135
136         /// <summary>
137         /// Sets or gets the angle offset value of Background ProgressBar.
138         /// </summary>
139         public double BackgroundAngleOffset
140         {
141             get
142             {
143                 return Interop.Eext.eext_circle_object_item_angle_offset_get(_circleHandle, "bg");
144             }
145             set
146             {
147                 Interop.Eext.eext_circle_object_item_angle_offset_set(_circleHandle, "bg", value);
148             }
149         }
150
151         /// <summary>
152         /// Sets or gets the maximum angle value of ProgressBar.
153         /// </summary>
154         public double BarAngleMaximum
155         {
156             get
157             {
158                 double max = 0;
159                 double min = 0;
160                 Interop.Eext.eext_circle_object_angle_min_max_get(_circleHandle, out min, out max);
161                 return max;
162             }
163             set
164             {
165                 double min = BarAngleMinimum;
166                 Interop.Eext.eext_circle_object_angle_min_max_set(_circleHandle, min, value);
167             }
168         }
169
170         /// <summary>
171         /// Sets or gets the minimum angle value of ProgressBar.
172         /// </summary>
173         public double BarAngleMinimum
174         {
175             get
176             {
177                 double max = 0;
178                 double min = 0;
179                 Interop.Eext.eext_circle_object_angle_min_max_get(_circleHandle, out min, out max);
180                 return min;
181             }
182             set
183             {
184                 double max = BarAngleMaximum;
185                 Interop.Eext.eext_circle_object_angle_min_max_set(_circleHandle, value, max);
186             }
187         }
188
189         /// <summary>
190         /// Sets or gets disable status of Circle ProgressBar.
191         /// </summary>
192         public bool Disabled
193         {
194             get
195             {
196                 return Interop.Eext.eext_circle_object_disabled_get(_circleHandle);
197             }
198             set
199             {
200                 Interop.Eext.eext_circle_object_disabled_set(_circleHandle, value);
201             }
202         }
203
204         /// <summary>
205         /// Sets or gets color of ProgressBar.
206         /// </summary>
207         public Color BarColor
208         {
209             get
210             {
211                 int r = 0;
212                 int g = 0;
213                 int b = 0;
214                 int a = 0;
215                 Interop.Eext.eext_circle_object_color_get(_circleHandle, out r, out g, out b, out a);
216                 return Color.FromRgba(r, g, b, a);
217             }
218             set
219             {
220                 Interop.Eext.eext_circle_object_color_set(_circleHandle, value.R, value.G, value.B, value.A);
221             }
222         }
223
224         /// <summary>
225         /// Sets or gets color of Background ProgressBar.
226         /// </summary>
227         public Color BackgroundColor
228         {
229             get
230             {
231                 int r = 0;
232                 int g = 0;
233                 int b = 0;
234                 int a = 0;
235                 Interop.Eext.eext_circle_object_item_color_get(_circleHandle, "bg", out r, out g, out b, out a);
236                 return Color.FromRgba(r, g, b, a);
237             }
238             set
239             {
240                 Interop.Eext.eext_circle_object_item_color_set(_circleHandle, "bg", value.R, value.G, value.B, value.A);
241             }
242         }
243
244         /// <summary>
245         /// Sets or gets line width of ProgressBar.
246         /// </summary>
247         public int BarLineWidth
248         {
249             get
250             {
251                 return Interop.Eext.eext_circle_object_line_width_get(_circleHandle); ;
252             }
253             set
254             {
255                 Interop.Eext.eext_circle_object_line_width_set(_circleHandle, value);
256             }
257         }
258
259         /// <summary>
260         /// Sets or gets line width of Background ProgressBar.
261         /// </summary>
262         public int BackgroundLineWidth
263         {
264             get
265             {
266                 return Interop.Eext.eext_circle_object_item_line_width_get(_circleHandle, "bg");
267             }
268             set
269             {
270                 Interop.Eext.eext_circle_object_item_line_width_set(_circleHandle, "bg", value);
271             }
272         }
273
274         /// <summary>
275         /// Sets or gets radius of ProgressBar.
276         /// </summary>
277         public double BarRadius
278         {
279             get
280             {
281                 return Interop.Eext.eext_circle_object_radius_get(_circleHandle); ;
282             }
283             set
284             {
285                 Interop.Eext.eext_circle_object_radius_set(_circleHandle, value);
286             }
287         }
288
289         /// <summary>
290         /// Sets or gets radius of Background ProgressBar.
291         /// </summary>
292         public double BackgroundRadius
293         {
294             get
295             {
296                 return Interop.Eext.eext_circle_object_item_radius_get(_circleHandle, "bg"); ;
297             }
298             set
299             {
300                 Interop.Eext.eext_circle_object_item_radius_set(_circleHandle, "bg", value);
301             }
302         }
303
304         protected override IntPtr CreateHandle(EvasObject parent)
305         {
306             IntPtr surface = IntPtr.Zero;
307
308             if (parent is Conformant)
309             {
310                 surface = Interop.Eext.eext_circle_surface_conformant_add(parent.Handle);
311             }
312             else if (parent is Layout)
313             {
314                 surface = Interop.Eext.eext_circle_surface_layout_add(parent.Handle);
315             }
316             else if (parent is Naviframe)
317             {
318                 surface = Interop.Eext.eext_circle_surface_naviframe_add(parent.RealHandle);
319             }
320
321             _circleHandle = Interop.Eext.eext_circle_object_progressbar_add(parent.Handle, surface);
322             if (surface == IntPtr.Zero)
323             {
324                 EvasObject p = parent;
325                 while (!(p is Window))
326                 {
327                     p = p.Parent;
328                 }
329                 var w = (p as Window).ScreenSize.Width;
330                 var h = (p as Window).ScreenSize.Height;
331                 Interop.Evas.evas_object_resize(_circleHandle, w, h);
332             }
333
334             Interop.Eext.eext_rotary_object_event_activated_set(_circleHandle, true);
335             return parent.Handle;
336         }
337     }
338 }