1e650720e737566416d9dcd779c7c5f84516ca22
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / ProgressBar.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
20 {
21     public class ProgressBar : Layout
22     {
23         SmartEvent _changed;
24
25         public ProgressBar(EvasObject parent) : base(parent)
26         {
27             _changed = new SmartEvent(this, this.RealHandle, "changed");
28             _changed.On += (s, e) =>
29             {
30                 ValueChanged?.Invoke(this, EventArgs.Empty);
31             };
32         }
33
34         public event EventHandler ValueChanged;
35
36         public bool IsPulseMode
37         {
38             get
39             {
40                 return Interop.Elementary.elm_progressbar_pulse_get(RealHandle);
41             }
42             set
43             {
44                 Interop.Elementary.elm_progressbar_pulse_set(RealHandle, value);
45             }
46         }
47
48         public double Value
49         {
50             get
51             {
52                 return Interop.Elementary.elm_progressbar_value_get(RealHandle);
53             }
54             set
55             {
56                 Interop.Elementary.elm_progressbar_value_set(RealHandle, value);
57             }
58         }
59
60         public int SpanSize
61         {
62             get
63             {
64                 return Interop.Elementary.elm_progressbar_span_size_get(RealHandle);
65             }
66             set
67             {
68                 Interop.Elementary.elm_progressbar_span_size_set(RealHandle, value);
69             }
70         }
71
72         public bool IsHorizontal
73         {
74             get
75             {
76                 return Interop.Elementary.elm_progressbar_horizontal_get(RealHandle);
77             }
78             set
79             {
80                 Interop.Elementary.elm_progressbar_horizontal_set(RealHandle, value);
81             }
82         }
83
84         public bool IsInverted
85         {
86             get
87             {
88                 return Interop.Elementary.elm_progressbar_inverted_get(RealHandle);
89             }
90             set
91             {
92                 Interop.Elementary.elm_progressbar_inverted_set(RealHandle, value);
93             }
94         }
95
96         public string UnitFormat
97         {
98             get
99             {
100                 return Interop.Elementary.elm_progressbar_unit_format_get(RealHandle);
101             }
102             set
103             {
104                 Interop.Elementary.elm_progressbar_unit_format_set(RealHandle, value);
105             }
106         }
107
108         public void PlayPulse()
109         {
110             Interop.Elementary.elm_progressbar_pulse(RealHandle, true);
111         }
112
113         [Obsolete("use StopPulse instead")]
114         public void StopPluse()
115         {
116             Interop.Elementary.elm_progressbar_pulse(RealHandle, false);
117         }
118
119         public void StopPulse()
120         {
121             Interop.Elementary.elm_progressbar_pulse(RealHandle, false);
122         }
123
124         protected override IntPtr CreateHandle(EvasObject parent)
125         {
126             IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
127             Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
128
129             RealHandle = Interop.Elementary.elm_progressbar_add(handle);
130             Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
131
132             return handle;
133         }
134     }
135 }