2 using Tizen.NUI.BaseComponents;
3 using Tizen.NUI.Components;
5 namespace Tizen.NUI.Samples
7 public class ToastSample : IExample
9 private TextLabel[] text = new TextLabel[3];
10 private Button[] button = new Button[2];
11 private Toast toast1_1, toast2_1; //1-null para 2-attributes; X_1-color; X_2 image track
13 private View[] parentView = new View[3];
15 public void Activate()
17 Window window = NUIApplication.GetDefaultWindow();
21 Size = new Size(1920, 1080),
22 BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f),
24 root.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical };
32 private void CreateTextView()
34 // Init parent of TextView
35 parentView[0] = new View();
36 parentView[0].Size = new Size(1920, 200);
37 parentView[0].Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.Center, CellPadding = new Size2D(300, 0) };
38 root.Add(parentView[0]);
40 for (int i = 0; i < 2; i++)
42 text[i] = new TextLabel();
43 text[i].Size = new Size(400, 70);
44 text[i].PointSize = 20.0f;
45 text[i].BackgroundColor = Color.Magenta;
46 text[i].HorizontalAlignment = HorizontalAlignment.Center;
47 text[i].VerticalAlignment = VerticalAlignment.Center;
48 text[i].Focusable = true;
49 text[i].FocusGained += Board_FocusGained;
50 text[i].FocusLost += Board_FocusLost;
51 parentView[0].Add(text[i]);
54 // Text of "Create Switch just by properties"
55 text[0].Text = "Null Style construction";
57 // Text of "Create Switch just by Style"
58 text[1].Text = "Style construction";
61 private void CreateToastView()
63 // Init parent of ToastView
64 parentView[1] = new View();
65 parentView[1].Size = new Size(1920, 500);
66 parentView[1].Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.Center, CellPadding = new Size2D(300, 0) };
67 root.Add(parentView[1]);
70 toast1_1 = Toast.FromText("Null parameter construction", 1000);
71 toast1_1.Size = new Size(700, 132);
72 toast1_1.Post(NUIApplication.GetDefaultWindow());
74 ToastStyle attr = new ToastStyle
76 Size = new Size(712, 132),
77 BackgroundImage = CommonResource.GetFHResourcePath() + "12. Toast Popup/toast_background.png",
78 BackgroundImageBorder = new Rectangle(64, 64, 4, 4),
82 toast2_1 = new Toast(attr);
83 toast2_1.Message = "Style parameter construction";
84 toast2_1.Post(NUIApplication.GetDefaultWindow());
87 CreateBoardAndButtons();
90 private void CreateLogPadView()
92 // Init parent of LogPadView
93 parentView[2] = new View();
94 parentView[2].Size = new Size(1920, 380);
95 parentView[2].Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.Center};
96 root.Add(parentView[2]);
99 text[2] = new TextLabel();
100 text[2].Size = new Size(1000, 100);
101 text[2].PointSize = 30.0f;
102 text[2].HorizontalAlignment = HorizontalAlignment.Center;
103 text[2].VerticalAlignment = VerticalAlignment.Center;
104 text[2].BackgroundColor = Color.Magenta;
105 text[2].Text = "log pad";
106 text[2].Focusable = true;
107 text[2].FocusGained += Board_FocusGained;
108 text[2].FocusLost += Board_FocusLost;
109 text[2].UpFocusableView = button[0];
110 parentView[2].Add(text[2]);
113 void CreateBoardAndButtons()
115 for (int i = 0; i < 2; i++)
117 button[i] = new Button();
118 button[i].BackgroundColor = Color.Green;
119 button[i].Size = new Size(200, 50);
120 button[i].Focusable = true;
121 parentView[1].Add(button[i]);
123 button[0].Text = "toast1_1 Show";
124 button[0].ClickEvent += toast1_1Show;
125 button[1].Text = "toast2_1 Show";
126 button[1].ClickEvent += toast2_1Show;
129 FocusManager.Instance.SetCurrentFocusView(button[0]);
132 private void Board_FocusLost(object sender, global::System.EventArgs e)
134 text[2].BackgroundColor = Color.Magenta;
137 private void Board_FocusGained(object sender, global::System.EventArgs e)
139 text[2].BackgroundColor = Color.Cyan;
142 private void toast1_1Show(object sender, global::System.EventArgs e)
144 text[2].Text = "toast1_1 show: ";
148 private void toast2_1Show(object sender, global::System.EventArgs e)
150 text[2].Text = "toast2_1 show: ";
154 public void Deactivate()
158 NUIApplication.GetDefaultWindow().Remove(root);
160 if (toast1_1 != null)
162 NUIApplication.GetDefaultWindow().Remove(toast1_1);
167 if (toast2_1 != null)
169 NUIApplication.GetDefaultWindow().Remove(toast2_1);
181 for (i = 0; i < 3; i++)
185 parentView[i].Dispose();
186 parentView[i] = null;