2 using Tizen.NUI.BaseComponents;
3 using Tizen.NUI.Components;
5 namespace Tizen.NUI.Samples
7 public class LoadingSample : IExample
9 private TextLabel[] textLabel = new TextLabel[3];
10 private Button[] button = new Button[3];
11 private Loading[] loading = new Loading[2];
13 private View gridLayout;
14 private View[] layout = new View[4];
15 private string[] imageArray;
17 public void Activate()
19 Window window = NUIApplication.GetDefaultWindow();
23 Size = new Size(1920, 1080),
24 BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f)
28 gridLayout = new View()
30 Position = new Position(400, 200),
31 Size = new Size(1920, 1080)
33 gridLayout.Layout = new GridLayout()
36 GridOrientation = GridLayout.Orientation.Horizontal,
39 //parent.Layout.Measure(new MeasureSpecification(new LayoutLength(1000), MeasureSpecification.ModeType.Exactly), new MeasureSpecification(new LayoutLength(780), MeasureSpecification.ModeType.Exactly));
42 imageArray = new string[36];
43 for (int i = 0; i < 36; i++)
47 imageArray[i] = CommonResource.GetFHResourcePath() + "9. Controller/Loading Sequence_Native/loading_0" + i + ".png";
51 imageArray[i] = CommonResource.GetFHResourcePath() + "9. Controller/Loading Sequence_Native/loading_" + i + ".png";
59 void CreatePropLayout()
61 textLabel[0] = new TextLabel();
62 textLabel[0].WidthSpecification = 500;
63 textLabel[0].HeightSpecification = 100;
64 //To set spacing between grid cells.
65 textLabel[0].Margin = new Extents(0, 20, 0, 100);
66 textLabel[0].PointSize = 20;
67 textLabel[0].HorizontalAlignment = HorizontalAlignment.Center;
68 textLabel[0].VerticalAlignment = VerticalAlignment.Center;
69 textLabel[0].BackgroundColor = Color.Magenta;
70 textLabel[0].Text = "Property construction";
71 gridLayout.Add(textLabel[0]);
73 // layout for loading which is created by properties.
74 // It'll update the visual when framerate is changed, so put loading into a layout.
75 layout[1] = new View();
76 layout[1].Layout = new LinearLayout()
78 LinearOrientation = LinearLayout.Orientation.Horizontal,
79 LinearAlignment = LinearLayout.Alignment.Center
81 loading[0] = new Loading();
82 loading[0].Size = new Size(100, 100);
83 loading[0].ImageArray = imageArray;
84 layout[1].Add(loading[0]);
85 gridLayout.Add(layout[1]);
87 CreatePropBtnLayout();
89 textLabel[1] = new TextLabel();
90 textLabel[1].PointSize = 20;
91 textLabel[1].HorizontalAlignment = HorizontalAlignment.Center;
92 textLabel[1].VerticalAlignment = VerticalAlignment.Center;
93 textLabel[1].BackgroundColor = Color.Magenta;
94 textLabel[1].Text = "log pad";
95 textLabel[1].PointSize = 15;
96 gridLayout.Add(textLabel[1]);
99 void CreatePropBtnLayout()
101 // layout for button.
102 // To avoid button size same as the grid cell.
103 layout[0] = new View() {};
104 layout[0].Layout = new LinearLayout()
106 LinearOrientation = LinearLayout.Orientation.Horizontal,
107 LinearAlignment = LinearLayout.Alignment.Center,
108 CellPadding = new Size(10, 50)
111 button[0] = new Button();
112 button[0].Size = new Size(200, 50);
113 button[0].Text = "FPS++";
114 button[0].PointSize = 15;
115 button[0].BackgroundColor = Color.Green;
116 layout[0].Add(button[0]);
117 button[0].Focusable = true;
118 button[0].ClickEvent += propFpsAdd;
119 FocusManager.Instance.SetCurrentFocusView(button[0]);
121 button[1] = new Button();
122 button[1].Size = new Size(200, 50);
123 button[1].Text = "FPS--";
124 button[1].PointSize = 15;
125 button[1].BackgroundColor = Color.Green;
126 layout[0].Add(button[1]);
127 button[1].Focusable = true;
128 button[1].ClickEvent += propFpsMinus;
129 FocusManager.Instance.SetCurrentFocusView(button[1]);
131 gridLayout.Add(layout[0]);
133 button[0].RightFocusableView = button[1];
134 button[1].LeftFocusableView = button[0];
137 private void CreateAttrLayout()
139 textLabel[2] = new TextLabel();
140 textLabel[2].PointSize = 20;
141 textLabel[2].HorizontalAlignment = HorizontalAlignment.Center;
142 textLabel[2].VerticalAlignment = VerticalAlignment.Center;
143 textLabel[2].BackgroundColor = Color.Magenta;
144 textLabel[2].Text = "Attribute construction";
145 gridLayout.Add(textLabel[2]);
147 // layout for loading which is created by attributes.
148 // It'll update the visual when framerate is changed, so put loading into a layout.
149 layout[2] = new View();
150 layout[2].Layout = new LinearLayout()
152 LinearOrientation = LinearLayout.Orientation.Horizontal,
153 LinearAlignment = LinearLayout.Alignment.Center
155 LoadingStyle style = new LoadingStyle
159 loading[1] = new Loading(style);
160 loading[1].Size = new Size(100, 100);
161 layout[2].Add(loading[1]);
162 gridLayout.Add(layout[2]);
164 // layout for button.
165 // To avoid button size same as the grid cell.
166 layout[3] = new View() { };
167 layout[3].Layout = new LinearLayout()
169 LinearOrientation = LinearLayout.Orientation.Horizontal,
170 LinearAlignment = LinearLayout.Alignment.Center
172 button[2] = new Button();
173 button[2].Size = new Size(400, 50);
174 button[2].Text = "Normal Loading";
175 button[2].PointSize = 15;
176 button[2].BackgroundColor = Color.Green;
177 layout[3].Add(button[2]);
178 gridLayout.Add(layout[3]);
179 button[2].Focusable = true;
180 FocusManager.Instance.SetCurrentFocusView(button[2]);
183 private void propFpsAdd(object sender, global::System.EventArgs e)
185 loading[0].FrameRate += 1;
186 textLabel[1].Text = "loading1_1 FPS: " + loading[0].FrameRate.ToString();
189 private void propFpsMinus(object sender, global::System.EventArgs e)
191 loading[0].FrameRate -= 1;
192 textLabel[1].Text = "loading1_1 FPS: " + loading[0].FrameRate.ToString();
195 private void FocusLost(object sender, global::System.EventArgs e)
197 View view = sender as View;
198 view.Scale = new Vector3(1.2f, 1.2f, 1.0f);
201 private void FocusGained(object sender, global::System.EventArgs e)
203 View view = sender as View;
204 view.Scale = new Vector3(1.0f, 1.0f, 1.0f);
207 public void Deactivate()
211 layout[0].Remove(button[0]);
215 layout[0].Remove(button[1]);
219 gridLayout.Remove(layout[0]);
223 gridLayout.Remove(textLabel[0]);
224 textLabel[0].Dispose();
227 layout[1].Remove(loading[0]);
228 loading[0].Dispose();
231 gridLayout.Remove(layout[1]);
235 gridLayout.Remove(textLabel[1]);
236 textLabel[1].Dispose();
239 gridLayout.Remove(textLabel[2]);
240 textLabel[2].Dispose();
243 layout[2].Remove(loading[1]);
244 loading[1].Dispose();
247 gridLayout.Remove(layout[2]);
251 layout[3].Remove(button[2]);
255 gridLayout.Remove(layout[3]);
259 root.Remove(gridLayout);
260 gridLayout.Dispose();
263 NUIApplication.GetDefaultWindow().Remove(root);