1 using System.Collections.Generic;
2 using Tizen.NUI.BaseComponents;
3 using Tizen.NUI.Components;
5 namespace Tizen.NUI.Samples
7 public class PopupSample : IExample
11 private TextLabel[] createText = new TextLabel[2];
13 private Popup popup = null;
14 private Popup popup2 = null;
15 private TextLabel contentText = null;
16 private TextLabel contentText2 = null;
17 private int index = 0;
18 private int index2 = 0;
19 private Button button = null;
21 private static string[] buttonStyles = new string[]
28 private static Color[] color = new Color[]
30 new Color(0.05f, 0.63f, 0.9f, 1),//#ff0ea1e6
31 new Color(0.14f, 0.77f, 0.28f, 1),//#ff24c447
32 new Color(0.75f, 0.46f, 0.06f, 1),//#ffec7510
33 new Color(0.59f, 0.38f, 0.85f, 1),//#ff9762d9
35 public void Activate()
37 Window window = NUIApplication.GetDefaultWindow();
41 Size2D = new Size2D(1920, 1080),
42 BackgroundColor = Color.White,
46 ///////////////////////////////////////////////Create by Property//////////////////////////////////////////////////////////
47 createText[0] = new TextLabel();
48 createText[0].Text = "Create Popup just by properties";
49 createText[0].Size2D = new Size2D(500, 100);
50 createText[0].Position2D = new Position2D(500, 50);
51 root.Add(createText[0]);
54 popup.MinimumSize = new Size2D(1032, 184);
55 popup.Size = new Size(1032, 400);
56 popup.Position = new Position(200, 100);
59 popup.Style.Title.PointSize = 25;
60 popup.Style.Title.SizeHeight = 68;
61 popup.Style.Title.HorizontalAlignment = HorizontalAlignment.Begin;
62 popup.Style.Title.Position = new Position(64, 52);
63 popup.Style.Title.Text = "Popup Title";
66 popup.Style.ImageShadow = new ImageShadow
68 Url = CommonResource.GetFHResourcePath() + "11. Popup/popup_background_shadow.png",
69 Border = new Rectangle(24, 24, 24, 24),
70 Offset = new Vector2(-24, -24),
71 Extents = new Vector2(48, 48),
75 popup.BackgroundImage = CommonResource.GetFHResourcePath() + "11. Popup/popup_background.png";
76 popup.BackgroundImageBorder = new Rectangle(0, 0, 81, 81);
79 popup.AddButton("Yes");
80 popup.AddButton("Exit");
81 popup.ButtonBackground = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_normal.png";
82 popup.ButtonBackgroundBorder = new Rectangle(5, 5, 5, 5);
83 popup.ButtonOverLayBackgroundColorSelector = new Selector<Color>
85 Normal = new Color(1.0f, 1.0f, 1.0f, 1.0f),
86 Pressed = new Color(0.0f, 0.0f, 0.0f, 0.1f),
87 Selected = new Color(1.0f, 1.0f, 1.0f, 1.0f),
89 popup.ButtonImageShadow = new ImageShadow
91 Url = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_shadow.png",
92 Border = new Rectangle(5, 5, 5, 5)
94 popup.ButtonTextColor = color[0];
95 popup.ButtonHeight = 132;
96 popup.PopupButtonClickEvent += PopupButtonClickedEvent;
97 popup.LayoutDirectionChanged += PopupLayoutDirectionChanged;
100 contentText = new TextLabel();
101 contentText.Size2D = new Size2D(904, 100);
102 contentText.PointSize = 20;
103 contentText.HorizontalAlignment = HorizontalAlignment.Begin;
104 contentText.VerticalAlignment = VerticalAlignment.Center;
105 contentText.Text = "Popup ButtonStyle is " + buttonStyles[index];
106 contentText.TextColor = new Color(0,0,222,1);
107 popup.AddContentText(contentText);
109 ///////////////////////////////////////////////Create by Attributes//////////////////////////////////////////////////////////
110 createText[1] = new TextLabel();
111 createText[1].Text = "Create Popup just by Attributes";
112 createText[1].Size2D = new Size2D(500, 100);
113 createText[1].Position2D = new Position2D(500, 550);
114 root.Add(createText[1]);
116 PopupStyle attrs = new PopupStyle
118 MinimumSize = new Size2D(1032, 184),
119 BackgroundImage = new Selector<string> { All = CommonResource.GetFHResourcePath() + "11. Popup/popup_background.png" },
120 BackgroundImageBorder = new Selector<Rectangle> { All = new Rectangle(0, 0, 81, 81) },
121 ImageShadow = new ImageShadow
123 Url = CommonResource.GetFHResourcePath() + "11. Popup/popup_background_shadow.png",
124 Border = new Rectangle(24, 24, 24, 24),
125 Offset = new Vector2(-24, -24),
126 Extents = new Vector2(48, 48),
128 Title = new TextLabelStyle
130 PointSize = new Selector<float?> { All = 25 },
131 TextColor = new Selector<Color> { All = Color.Black },
132 Size = new Size(0, 68),
133 PositionUsesPivotPoint = true,
134 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
135 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
136 HorizontalAlignment = HorizontalAlignment.Begin,
137 VerticalAlignment = VerticalAlignment.Bottom,
138 Position = new Position(64, 52),
139 Text = new Selector<string> { All = "Popup Title" },
141 Buttons = new ButtonStyle
143 PositionUsesPivotPoint = true,
144 ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft,
145 PivotPoint = Tizen.NUI.PivotPoint.BottomLeft,
146 BackgroundImage = new Selector<string> { All = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_normal.png" },
147 BackgroundImageBorder = new Selector<Rectangle> { All = new Rectangle(5, 5, 5, 5) },
148 ImageShadow = new ImageShadow
150 Url = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_shadow.png",
151 Border = new Rectangle(5, 5, 5, 5),
153 Overlay = new ImageViewStyle
155 PositionUsesPivotPoint = true,
156 ParentOrigin = Tizen.NUI.ParentOrigin.Center,
157 PivotPoint = Tizen.NUI.PivotPoint.Center,
158 WidthResizePolicy = ResizePolicyType.FillToParent,
159 HeightResizePolicy = ResizePolicyType.FillToParent,
160 BackgroundColor = new Selector<Color>
162 Normal = new Color(1.0f, 1.0f, 1.0f, 1.0f),
163 Pressed = new Color(0.0f, 0.0f, 0.0f, 0.1f),
164 Selected = new Color(1.0f, 1.0f, 1.0f, 1.0f),
167 Text = new TextLabelStyle
169 PositionUsesPivotPoint = true,
170 ParentOrigin = Tizen.NUI.ParentOrigin.Center,
171 PivotPoint = Tizen.NUI.PivotPoint.Center,
172 HorizontalAlignment = HorizontalAlignment.Center,
173 VerticalAlignment = VerticalAlignment.Center,
174 TextColor = new Selector<Color> { All = color[index2] },
179 popup2 = new Popup(attrs);
180 popup2.Size = new Size(1032, 400);
181 popup2.Position = new Position(200, 600);
182 popup2.AddButton("Yes");
183 popup2.AddButton("Exit");
184 popup2.ButtonHeight = 132;
185 popup2.PopupButtonClickEvent += PopupButtonClickedEvent;
186 popup2.LayoutDirectionChanged += Popup2LayoutDirectionChanged;
189 contentText2 = new TextLabel();
190 contentText2.Size2D = new Size2D(904, 100);
191 contentText2.PointSize = 20;
192 contentText2.HorizontalAlignment = HorizontalAlignment.Begin;
193 contentText2.VerticalAlignment = VerticalAlignment.Center;
194 contentText2.Text = "Popup2 ButtonStyle is " + buttonStyles[index];
195 popup2.ContentView.Add(contentText2);
197 button = new Button();
198 button.Style.BackgroundImage = CommonResource.GetTVResourcePath() + "component/c_buttonbasic/c_basic_button_white_bg_normal_9patch.png";
199 button.Style.BackgroundImageBorder = new Rectangle(4, 4, 5, 5);
200 button.Size2D = new Size2D(580, 80);
201 button.Position2D = new Position2D(1300, 500);
202 button.Style.Text.Text = "LayoutDirection is left to right";
203 button.ClickEvent += ButtonClickEvent;
207 private void Popup2LayoutDirectionChanged(object sender, View.LayoutDirectionChangedEventArgs e)
209 if (contentText2.HorizontalAlignment == HorizontalAlignment.Begin)
211 contentText2.HorizontalAlignment = HorizontalAlignment.End;
213 else if (contentText2.HorizontalAlignment == HorizontalAlignment.End)
215 contentText2.HorizontalAlignment = HorizontalAlignment.Begin;
219 private void PopupLayoutDirectionChanged(object sender, View.LayoutDirectionChangedEventArgs e)
221 if (contentText.HorizontalAlignment == HorizontalAlignment.Begin)
223 contentText.HorizontalAlignment = HorizontalAlignment.End;
225 else if (contentText.HorizontalAlignment == HorizontalAlignment.End)
227 contentText.HorizontalAlignment = HorizontalAlignment.Begin;
231 private void PopupButtonClickedEvent(object sender, Popup.ButtonClickEventArgs e)
233 Popup obj = sender as Popup;
234 if (obj != null && e.ButtonIndex == 0)
239 index = index % buttonStyles.Length;
240 obj.ButtonTextColor = color[index];
241 contentText.Text = "Popup ButtonStyle is " + buttonStyles[index];
246 index2 = index2 % buttonStyles.Length;
247 obj.ButtonTextColor = color[index2];
248 contentText2.Text = "Popup2 ButtonStyle is " + buttonStyles[index2];
253 private void ButtonClickEvent(object sender, Button.ClickEventArgs e)
255 if (popup.LayoutDirection == ViewLayoutDirectionType.LTR)
257 popup.LayoutDirection = ViewLayoutDirectionType.RTL;
258 popup2.LayoutDirection = ViewLayoutDirectionType.RTL;
259 button.Style.Text.Text = "LayoutDirection is right to left";
263 popup.LayoutDirection = ViewLayoutDirectionType.LTR;
264 popup2.LayoutDirection = ViewLayoutDirectionType.LTR;
265 button.Style.Text.Text = "LayoutDirection is left to right";
269 public void Deactivate()
275 if (contentText != null)
277 popup.ContentView.Remove(contentText);
278 contentText.Dispose();
289 if (contentText2 != null)
291 popup2.ContentView.Remove(contentText2);
292 contentText2.Dispose();
301 if (createText[0] != null)
303 root.Remove(createText[0]);
304 createText[0].Dispose();
305 createText[0] = null;
308 if (createText[1] != null)
310 root.Remove(createText[1]);
311 createText[1].Dispose();
312 createText[1] = null;
322 NUIApplication.GetDefaultWindow().Remove(root);