27ad9bba1c3aaa7feea1a92cda1327d36724ec4a
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.StyleGuide / Examples / DatePickerExample.cs
1 /*
2  * Copyright(c) 2022 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 using System;
18 using System.ComponentModel;
19 using Tizen.NUI;
20 using Tizen.NUI.BaseComponents;
21 using Tizen.NUI.Components;
22
23 namespace Tizen.NUI.StyleGuide
24 {
25     // IExample inehrited class will be automatically added in the main examples list.
26     internal class DatePickerExample : ContentPage, IExample
27     {
28         private View rootContent;
29         private DatePicker datePicker;
30         private TextLabel label;
31         private Button button;
32
33         public void Activate()
34         {
35         }
36         public void Deactivate()
37         {
38         }
39
40         /// Modify this method for adding other examples.
41         public DatePickerExample() : base()
42         {
43             WidthSpecification = LayoutParamPolicies.MatchParent;
44             HeightSpecification = LayoutParamPolicies.MatchParent;
45
46             // Navigator bar title is added here.
47             AppBar = new AppBar()
48             {
49                 Title = "DatePicker Default Style",
50             };
51
52             // Example root content view.
53             // you can decorate, add children on this view.
54             rootContent = new View()
55             {
56                 WidthSpecification = LayoutParamPolicies.MatchParent,
57                 HeightSpecification = LayoutParamPolicies.MatchParent,
58
59                 Layout = new LinearLayout()
60                 {
61                     LinearOrientation = LinearLayout.Orientation.Vertical,
62                     HorizontalAlignment = HorizontalAlignment.Center,
63                     VerticalAlignment = VerticalAlignment.Center,
64                     CellPadding = new Size2D(10, 20),
65                 },
66             };
67
68             // Picker style examples.
69             datePicker = new DatePicker()
70             {
71                 WidthSpecification = LayoutParamPolicies.MatchParent,
72                 Date = DateTime.Now
73             };
74             rootContent.Add(datePicker);
75
76
77             label = new TextLabel
78             {
79                 WidthSpecification = LayoutParamPolicies.MatchParent,
80                 Text = $"Date: {datePicker.Date.ToString()}"
81             };
82             rootContent.Add(label);
83
84             button = new Tizen.NUI.Components.Button
85             {
86                 WidthSpecification = LayoutParamPolicies.MatchParent,
87                 Text = "set date"
88             };
89             rootContent.Add(button);
90
91             button.Clicked += (s, e) =>
92             {
93                 label.Text = $"Date: {datePicker.Date.ToString()}";
94             };
95
96             Content = rootContent;
97         }
98     }
99 }