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
13 private TextLabel[] createText = new TextLabel[2];
15 private Popup popup = null;
16 private Popup popup2 = null;
17 private TextLabel contentText = null;
18 private TextLabel contentText2 = null;
19 private int index = 0;
20 private int index2 = 0;
21 private Button button = null;
23 private static string[] buttonStyles = new string[]
30 private static Color[] color = new Color[]
32 new Color(0.05f, 0.63f, 0.9f, 1),//#ff0ea1e6
33 new Color(0.14f, 0.77f, 0.28f, 1),//#ff24c447
34 new Color(0.75f, 0.46f, 0.06f, 1),//#ffec7510
35 new Color(0.59f, 0.38f, 0.85f, 1),//#ff9762d9
37 public void Activate()
39 Window window = NUIApplication.GetDefaultWindow();
43 Size = new Size(1920, 1080),
44 BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f),
50 Size = new Size(1920, 1080),
52 parent1.Layout = new LinearLayout()
54 LinearOrientation = LinearLayout.Orientation.Horizontal,
55 LinearAlignment = LinearLayout.Alignment.Center,
56 CellPadding = new Size(50, 50)
61 Size = new Size(1032, 980),
63 parent2.Layout = new LinearLayout()
65 LinearOrientation = LinearLayout.Orientation.Vertical,
66 LinearAlignment = LinearLayout.Alignment.CenterHorizontal,
67 CellPadding = new Size(400, 400)
70 ///////////////////////////////////////////////Create by Property//////////////////////////////////////////////////////////
71 createText[0] = new TextLabel();
72 createText[0].Text = "Create Popup just by properties";
73 createText[0].WidthSpecification = 500;
74 createText[0].HeightSpecification = 100;
75 parent2.Add(createText[0]);
78 popup.MinimumSize = new Size(1032, 184);
79 popup.Size = new Size(1032, 400);
80 popup.Position = new Position(150, 100);
83 popup.Title.PointSize = 25;
84 popup.Title.Size = new Size(0, 68);
85 popup.Title.PositionUsesPivotPoint = true;
86 popup.Title.ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft;
87 popup.Title.PivotPoint = Tizen.NUI.PivotPoint.TopLeft;
88 popup.Title.HorizontalAlignment = HorizontalAlignment.Begin;
89 popup.Title.VerticalAlignment = VerticalAlignment.Bottom;
90 popup.Title.Position = new Position(64, 52);
91 popup.Title.Text = "Popup Title";
92 popup.Title.Padding = 0;
95 popup.ImageShadow = new ImageShadow
97 Url = CommonResource.GetFHResourcePath() + "11. Popup/popup_background_shadow.png",
98 Border = new Rectangle(24, 24, 24, 24),
99 Extents = new Vector2(48, 48)
103 popup.BackgroundImage = CommonResource.GetFHResourcePath() + "11. Popup/popup_background.png";
104 popup.BackgroundImageBorder = new Rectangle(0, 0, 81, 81);
107 popup.AddButton("Yes");
108 popup.AddButton("Exit");
109 popup.ButtonBackground = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_normal.png";
110 popup.ButtonBackgroundBorder = new Rectangle(5, 5, 5, 5);
111 popup.ButtonOverLayBackgroundColorSelector = new Selector<Color>
113 Normal = new Color(1.0f, 1.0f, 1.0f, 0.5f),
114 Pressed = new Color(0.0f, 0.0f, 0.0f, 0.5f)
116 popup.ButtonImageShadow = new ImageShadow
118 Url = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_shadow.png",
119 Border = new Rectangle(5, 5, 5, 5)
121 popup.ButtonTextColor = color[0];
122 popup.ButtonHeight = 132;
123 popup.PopupButtonClickEvent += PopupButtonClickedEvent;
124 popup.LayoutDirectionChanged += PopupLayoutDirectionChanged;
127 contentText = new TextLabel();
128 contentText.Size = new Size(1032, 100);
129 contentText.PointSize = 20;
130 contentText.HorizontalAlignment = HorizontalAlignment.Begin;
131 contentText.VerticalAlignment = VerticalAlignment.Center;
132 contentText.Text = "Popup ButtonStyle is " + buttonStyles[index];
133 contentText.TextColor = new Color(0,0,222,1);
134 popup.AddContentText(contentText);
136 ///////////////////////////////////////////////Create by Attributes//////////////////////////////////////////////////////////
137 createText[1] = new TextLabel();
138 createText[1].Text = "Create Popup just by Attributes";
139 createText[1].WidthSpecification = 500;
140 createText[1].HeightSpecification = 100;
141 parent2.Add(createText[1]);
143 PopupStyle attrs = new PopupStyle
145 MinimumSize = new Size(1032, 184),
146 BackgroundImage = new Selector<string> { All = CommonResource.GetFHResourcePath() + "11. Popup/popup_background.png" },
147 BackgroundImageBorder = new Selector<Rectangle> { All = new Rectangle(0, 0, 81, 81) },
148 ImageShadow = new ImageShadow
150 Url = CommonResource.GetFHResourcePath() + "11. Popup/popup_background_shadow.png",
151 Border = new Rectangle(24, 24, 24, 24),
152 Extents = new Vector2(48, 48),
154 Title = new TextLabelStyle
156 PointSize = new Selector<float?> { All = 25 },
157 TextColor = new Selector<Color> { All = Color.Black },
158 Size = new Size(0, 68),
159 PositionUsesPivotPoint = true,
160 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
161 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
162 HorizontalAlignment = HorizontalAlignment.Begin,
163 VerticalAlignment = VerticalAlignment.Bottom,
164 Position = new Position(64, 52),
165 Text = new Selector<string> { All = "Popup Title" },
167 Buttons = new ButtonStyle
169 PositionUsesPivotPoint = true,
170 ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft,
171 PivotPoint = Tizen.NUI.PivotPoint.BottomLeft,
172 BackgroundImage = new Selector<string> { All = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_normal.png" },
173 BackgroundImageBorder = new Selector<Rectangle> { All = new Rectangle(5, 5, 5, 5) },
174 ImageShadow = new ImageShadow
176 Url = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_shadow.png",
177 Border = new Rectangle(5, 5, 5, 5),
179 Overlay = new ImageViewStyle
181 PositionUsesPivotPoint = true,
182 ParentOrigin = Tizen.NUI.ParentOrigin.Center,
183 PivotPoint = Tizen.NUI.PivotPoint.Center,
184 WidthResizePolicy = ResizePolicyType.FillToParent,
185 HeightResizePolicy = ResizePolicyType.FillToParent,
186 BackgroundColor = new Selector<Color>
188 Normal = new Color(1.0f, 1.0f, 1.0f, 0.5f),
189 Pressed = new Color(0.0f, 0.0f, 0.0f, 0.5f),
192 Text = new TextLabelStyle
194 PositionUsesPivotPoint = true,
195 ParentOrigin = Tizen.NUI.ParentOrigin.Center,
196 PivotPoint = Tizen.NUI.PivotPoint.Center,
197 HorizontalAlignment = HorizontalAlignment.Center,
198 VerticalAlignment = VerticalAlignment.Center,
199 TextColor = new Selector<Color> { All = color[index2] }
204 popup2 = new Popup(attrs);
205 popup2.Size = new Size(1032, 400);
206 popup2.Position = new Position(150, 600);
207 popup2.AddButton("Yes");
208 popup2.AddButton("Exit");
209 popup2.ButtonHeight = 132;
210 popup2.PopupButtonClickEvent += PopupButtonClickedEvent;
211 popup2.LayoutDirectionChanged += Popup2LayoutDirectionChanged;
214 contentText2 = new TextLabel();
215 contentText2.Size = new Size(1032, 100);
216 contentText2.PointSize = 20;
217 contentText2.HorizontalAlignment = HorizontalAlignment.Begin;
218 contentText2.VerticalAlignment = VerticalAlignment.Center;
219 contentText2.Text = "Popup2 ButtonStyle is " + buttonStyles[index];
220 popup2.ContentView.Add(contentText2);
222 button = new Button();
223 button.BackgroundImage = CommonResource.GetTVResourcePath() + "component/c_buttonbasic/c_basic_button_white_bg_normal_9patch.png";
224 button.BackgroundImageBorder = new Rectangle(4, 4, 5, 5);
225 button.WidthSpecification = 580;
226 button.HeightSpecification = 80;
227 button.TextLabel.Text = "LayoutDirection is left to right";
228 button.ClickEvent += ButtonClickEvent;
230 parent1.Add(parent2);
235 private void Popup2LayoutDirectionChanged(object sender, View.LayoutDirectionChangedEventArgs e)
237 if (contentText2.HorizontalAlignment == HorizontalAlignment.Begin)
239 contentText2.HorizontalAlignment = HorizontalAlignment.End;
241 else if (contentText2.HorizontalAlignment == HorizontalAlignment.End)
243 contentText2.HorizontalAlignment = HorizontalAlignment.Begin;
247 private void PopupLayoutDirectionChanged(object sender, View.LayoutDirectionChangedEventArgs e)
249 if (contentText.HorizontalAlignment == HorizontalAlignment.Begin)
251 contentText.HorizontalAlignment = HorizontalAlignment.End;
253 else if (contentText.HorizontalAlignment == HorizontalAlignment.End)
255 contentText.HorizontalAlignment = HorizontalAlignment.Begin;
259 private void PopupButtonClickedEvent(object sender, Popup.ButtonClickEventArgs e)
261 Popup obj = sender as Popup;
262 if (obj != null && e.ButtonIndex == 0)
267 index = index % buttonStyles.Length;
268 obj.ButtonTextColor = color[index];
269 contentText.Text = "Popup ButtonStyle is " + buttonStyles[index];
274 index2 = index2 % buttonStyles.Length;
275 obj.ButtonTextColor = color[index2];
276 contentText2.Text = "Popup2 ButtonStyle is " + buttonStyles[index2];
281 private void ButtonClickEvent(object sender, Button.ClickEventArgs e)
283 if (popup.LayoutDirection == ViewLayoutDirectionType.LTR)
285 popup.LayoutDirection = ViewLayoutDirectionType.RTL;
286 popup2.LayoutDirection = ViewLayoutDirectionType.RTL;
287 button.TextLabel.Text = "LayoutDirection is right to left";
291 popup.LayoutDirection = ViewLayoutDirectionType.LTR;
292 popup2.LayoutDirection = ViewLayoutDirectionType.LTR;
293 button.TextLabel.Text = "LayoutDirection is left to right";
297 public void Deactivate()
303 if (contentText != null)
305 popup.ContentView.Remove(contentText);
306 contentText.Dispose();
318 if (contentText2 != null)
320 popup2.ContentView.Remove(contentText2);
321 contentText2.Dispose();
331 if (createText[0] != null)
333 root.Remove(createText[0]);
334 createText[0].Dispose();
335 createText[0] = null;
338 if (createText[1] != null)
340 root.Remove(createText[1]);
341 createText[1].Dispose();
342 createText[1] = null;
352 NUIApplication.GetDefaultWindow().Remove(root);