Merge remote-tracking branch 'origin/master' into tizen
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Samples / Tizen.NUI.Samples / Samples / WearablePopupTest.cs
1 
2 using global::System;
3 using Tizen.NUI.BaseComponents;
4 using Tizen.NUI.Components;
5
6 namespace Tizen.NUI.Samples
7 {
8     using L = Tizen.Log;
9     using W = Tizen.NUI.Wearable;
10
11     public class WearablePopupTest : IExample
12     {
13         private W.Popup myPopup1;
14         private Window myWindow;
15         const string tag = "NUITEST";
16         private string resourcePath;
17         private const int BUTTON_WIDTH = 73;
18         private const int BUTTON_HEIGHT = 121;
19         private Color BUTTON_COLOR = new Color(11.0f / 255.0f, 6.0f / 255.0f, 92.0f / 255.0f, 1);
20         private const int BUTTON_ICON_WIDTH = 50;
21         private const int BUTTON_ICON_HEIGHT = 50;
22
23         private TextLabel myContent1;
24         private TextLabel t1;
25         public void Activate()
26         {
27             resourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
28             myWindow = NUIApplication.GetDefaultWindow();
29
30             //two buttons popup, type1
31             ButtonStyle buttonStyle = new ButtonStyle()
32             {
33                 Icon = new ImageViewStyle()
34                 {
35                     ResourceUrl = new Selector<string>()
36                     {
37                         All = resourcePath + "images/PopupTest/tw_ic_popup_btn_bg.png",
38                     },
39                     Size = new Size(BUTTON_WIDTH, BUTTON_HEIGHT),
40                     Color = new Selector<Color>()
41                     {
42                         All = BUTTON_COLOR,
43                     },
44                 },
45                 Overlay = new ImageViewStyle()
46                 {
47                     ResourceUrl = new Selector<string>()
48                     {
49                         All = resourcePath + "images/PopupTest/tw_ic_popup_btn_check.png",
50                     },
51                     Size = new Size(BUTTON_ICON_WIDTH, BUTTON_ICON_HEIGHT),
52                     Color = new Selector<Color>()
53                     {
54                         All = Color.Cyan,
55                     },
56                 },
57             };
58             Button leftButton = new Button(buttonStyle)
59             {
60                 Name = "LeftButton",
61                 Size = new Size(BUTTON_WIDTH, BUTTON_HEIGHT),
62             };
63
64             myPopup1 = new W.Popup();
65             myPopup1.AppendButton("LeftButton", leftButton);
66
67             buttonStyle.Overlay.ResourceUrl = new Selector<string>()
68             {
69                 All = resourcePath + "images/PopupTest/tw_ic_popup_btn_delete.png",
70             };
71             Button rightButton = new Button(buttonStyle)
72             {
73                 Name = "RightButton",
74                 Size = new Size(BUTTON_WIDTH, BUTTON_HEIGHT),
75             };
76             myPopup1.AppendButton("RightButton", rightButton);
77
78             TextLabel t = myPopup1.GetTitle();
79             t.Text = "User consent";
80
81             myContent1 = new TextLabel();
82             myContent1.Text = "Agree? \n GPS location \n and use of your \n location data \n are controlled \n by the applications you \n \n \n this is additional text!";
83             myContent1.MultiLine = true;
84             myContent1.Size = new Size(200, 800);
85             myContent1.PointSize = 6;
86             myContent1.HorizontalAlignment = HorizontalAlignment.Center;
87             myContent1.VerticalAlignment = VerticalAlignment.Top;
88             myContent1.TextColor = Color.White;
89             myContent1.PositionUsesPivotPoint = true;
90             myContent1.ParentOrigin = ParentOrigin.Center;
91             myContent1.PivotPoint = PivotPoint.Center;
92             myPopup1.AppendContent("ContentText", myContent1);
93             leftButton.Clicked += LeftButton_Clicked;
94             rightButton.Clicked += RightButton_Clicked;
95             myPopup1.OutsideClicked += Mp_OutsideClicked;
96
97             myPopup1.ContentContainer.WidthResizePolicy = ResizePolicyType.FitToChildren;
98             myPopup1.ContentContainer.HeightResizePolicy = ResizePolicyType.FitToChildren;
99
100             myPopup1.Post(myWindow);
101             myPopup1.AfterDissmising += MyPopup1_AfterDissmising;
102         }
103
104         private void MyPopup1_AfterDissmising(object sender, EventArgs e)
105         {
106             t1 = new TextLabel("please go back to main menu!")
107             {
108                 PositionUsesPivotPoint = true,
109                 ParentOrigin = ParentOrigin.Center,
110                 PivotPoint = PivotPoint.Center,
111                 PointSize = 8,
112                 MultiLine = true,
113             };
114             NUIApplication.GetDefaultWindow().Add(t1);
115         }
116
117         private void RightButton_Clicked(object sender, ClickedEventArgs e)
118         {
119             myPopup1.Dismiss();
120         }
121
122         private void LeftButton_Clicked(object sender, ClickedEventArgs e)
123         {
124             myContent1.TextColor = Color.Yellow;
125         }
126
127         private void Mp_OutsideClicked(object sender, EventArgs e)
128         {
129             var popup = sender as W.Popup;
130             if (popup != null)
131             {
132                 myPopup1.Dismiss();
133             }
134         }
135
136         public void Deactivate()
137         {
138             t1.Unparent();
139             t1.Dispose();
140         }
141     }
142 }