2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 /// Enumeration of datetime field types for DateTimeSelector.
24 public enum DateTimeFieldType
35 /// It inherits <see cref="Layout"/>
36 /// DateTimeSelector is a widget to display and input date & time values.
37 /// This widget displays date and time as per the system's locale settings
38 /// (Date includes Day, Month & Year along with the defined separators and Time includes Hour, Minute & AM/PM fields. Separator for AM/PM field is ignored.
40 public class DateTimeSelector : Layout
43 DateTime _cacheDateTime;
46 /// Creates and initializes a new instance of the DateTimeSelector class.
48 /// <param name="parent">The parent is a given container which will be attached by DateTimeSelector
49 ///as a child.It's <see cref="EvasObject"/> type.</param>
50 public DateTimeSelector(EvasObject parent) : base(parent)
52 _changed = new SmartEvent(this, this.RealHandle, "changed");
53 _changed.On += (s, e) =>
55 DateTime newDateTime = DateTime;
56 DateTimeChanged?.Invoke(this, new DateChangedEventArgs(_cacheDateTime, newDateTime));
57 DateTime = newDateTime;
62 /// ItemSelected is raised when Datetime field value changed.
64 public event EventHandler<DateChangedEventArgs> DateTimeChanged;
67 /// Gets or sets the datetime format.
70 /// format is a combination of allowed LIBC date format specifiers like: "%b %d, %Y %I : %M %p".
76 return Interop.Elementary.elm_datetime_format_get(RealHandle);
80 Interop.Elementary.elm_datetime_format_set(RealHandle, value);
85 /// Gets or sets the upper boundary of DateTime field.
87 public DateTime MaximumDateTime
91 var tm = new Interop.Libc.SystemTime();
92 Interop.Elementary.elm_datetime_value_max_get(RealHandle, ref tm);
97 Interop.Libc.SystemTime tm = value;
98 Interop.Elementary.elm_datetime_value_max_set(RealHandle, ref tm);
103 /// Gets or sets the lower boundary of DateTime field.
105 public DateTime MinimumDateTime
109 var tm = new Interop.Libc.SystemTime();
110 Interop.Elementary.elm_datetime_value_min_get(RealHandle, ref tm);
115 Interop.Libc.SystemTime tm = value;
116 Interop.Elementary.elm_datetime_value_min_set(RealHandle, ref tm);
121 /// Gets or sets the current value of DateTime field.
123 public DateTime DateTime
127 var tm = new Interop.Libc.SystemTime();
128 Interop.Elementary.elm_datetime_value_get(RealHandle, ref tm);
133 Interop.Libc.SystemTime tm = value;
134 Interop.Elementary.elm_datetime_value_set(RealHandle, ref tm);
135 _cacheDateTime = value;
140 /// Gets whether a field can be visible.
142 /// <param name="type">Enumeration <see cref="DateTimeFieldType"/></param>
144 /// The field is visible or not.
145 /// Type is bool.If visible, return true.
147 public bool IsFieldVisible(DateTimeFieldType type)
149 return Interop.Elementary.elm_datetime_field_visible_get(RealHandle, (int)type);
153 /// Sets the field limits of a field.
155 /// <param name="type">Enumeration <see cref="DateTimeFieldType"/></param>
156 /// <param name="minimum">minimum limit</param>
157 /// <param name="maximum">maximum limit</param>
158 public void SetFieldLimit(DateTimeFieldType type, int minimum, int maximum)
160 Interop.Elementary.elm_datetime_field_limit_set(RealHandle, (int)type, minimum, maximum);
164 /// Gets whether a field can be visible.
166 /// <param name="type">Enumeration <see cref="DateTimeFieldType"/></param>
167 /// <param name="visible">When set as true, the field type visible.</param>
168 public void SetFieldVisible(DateTimeFieldType type, bool visible)
170 Interop.Elementary.elm_datetime_field_visible_set(RealHandle, (int)type, visible);
173 protected override IntPtr CreateHandle(EvasObject parent)
175 IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
176 Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
178 RealHandle = Interop.Elementary.elm_datetime_add(handle);
179 Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);