04c9b29a9590b84300b08b858ffddee1a526520c
[platform/core/csapi/nui.git] / NUISamples / NUISamples / NUISamples.Tizen / examples / gc-test.cs
1
2 using System.Collections.Generic;
3 using System;
4 using Tizen.NUI.BaseComponents;
5 using Tizen.NUI.UIComponents;
6
7 namespace TizenVDUIApplication19
8 {
9     using Tizen.NUI;
10
11     internal class Program : NUIApplication
12     {
13         private Timer myTimer;
14         private List<View> myViewList;
15         private const int numberOfObjects = 500;
16         private Random myRandom;
17         private const string resources = "/home/owner/apps_rw/NUISamples.TizenTV/res";
18
19         protected override void OnCreate()
20         {
21             base.OnCreate();
22
23             Window.Instance.BackgroundColor = Color.White;
24
25             myViewList = new List<View>();
26
27             myRandom = new Random();
28
29             for (int i = 0; i < numberOfObjects; i++)
30             {
31                 View v = new View();
32
33                 float intensity = myRandom.Next(0, 255) / 255.0f;
34                 v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
35                 v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
36                 v.PivotPoint = PivotPoint.TopLeft;
37                 v.Size2D = new Size2D(100, 100);
38
39                 myViewList.Add(v);
40
41                 Window.Instance.GetDefaultLayer().Add(v);
42             }
43
44             myTimer = new Timer(1000);
45
46             myTimer.Tick += MyTimer_Tick;
47
48             myTimer.Start();
49         }
50
51         private bool MyTimer_Tick(object source, System.EventArgs e)
52         {
53             //Remove current Scene,
54             foreach (View v in myViewList)
55             {
56                 Window.Instance.GetDefaultLayer().Remove(v);
57             }
58
59             myViewList.Clear();
60
61             ////Add View
62
63             GC.Collect();
64             GC.WaitForPendingFinalizers();
65
66             for (int i = 0; i < 50; i++)
67             {
68                 TextLabel v = new TextLabel();
69
70                 float intensity = myRandom.Next(0, 255) / 255.0f;
71                 v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
72                 v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
73                 v.PivotPoint = PivotPoint.TopLeft;
74                 v.Size2D = new Size2D(100, 100);
75                 v.Text = "label " + i;
76
77                 myViewList.Add(v);
78
79                 Window.Instance.GetDefaultLayer().Add(v);
80             }
81
82             for (int i = 50; i < 100; i++)
83             {
84                 PushButton v = new PushButton();
85
86                 float intensity = myRandom.Next(0, 255) / 255.0f;
87                 v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
88                 v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
89                 v.PivotPoint = PivotPoint.TopLeft;
90                 v.Size2D = new Size2D(100, 100);
91                 v.LabelText = "button " + i;
92
93                 myViewList.Add(v);
94
95                 Window.Instance.GetDefaultLayer().Add(v);
96             }
97
98             for (int i = 100; i < 150; i++)
99             {
100                 ImageView v = new ImageView();
101
102                 float intensity = myRandom.Next(0, 255) / 255.0f;
103                 v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
104                 v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
105                 v.PivotPoint = PivotPoint.TopLeft;
106                 v.Size2D = new Size2D(100, 100);
107                 v.ResourceUrl = resources + "/images/gallery-3.jpg";
108
109                 myViewList.Add(v);
110
111                 Window.Instance.GetDefaultLayer().Add(v);
112             }
113
114             for (int i = 150; i < 200; i++)
115             {
116                 TextEditor v = new TextEditor();
117
118                 float intensity = myRandom.Next(0, 255) / 255.0f;
119                 v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
120                 v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
121                 v.PivotPoint = PivotPoint.TopLeft;
122                 v.Size2D = new Size2D(100, 100);
123                 v.Text = "editor" + i;
124
125                 myViewList.Add(v);
126
127                 Window.Instance.GetDefaultLayer().Add(v);
128             }
129
130             for (int i = 200; i < 250; i++)
131             {
132                 TextField v = new TextField();
133
134                 float intensity = myRandom.Next(0, 255) / 255.0f;
135                 v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
136                 v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
137                 v.PivotPoint = PivotPoint.TopLeft;
138                 v.Size2D = new Size2D(100, 100);
139                 v.Text = "field " + i;
140
141                 myViewList.Add(v);
142
143                 Window.Instance.GetDefaultLayer().Add(v);
144             }
145
146             for (int i = 250; i < 300; i++)
147             {
148                 CheckBoxButton v = new CheckBoxButton();
149
150                 float intensity = myRandom.Next(0, 255) / 255.0f;
151                 v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
152                 v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
153                 v.PivotPoint = PivotPoint.TopLeft;
154                 v.Size2D = new Size2D(100, 100);
155                 v.LabelText = "check " + i;
156
157                 myViewList.Add(v);
158
159                 Window.Instance.GetDefaultLayer().Add(v);
160             }
161
162             for (int i = 300; i < 350; i++)
163             {
164                 ScrollBar v = new ScrollBar();
165
166                 float intensity = myRandom.Next(0, 255) / 255.0f;
167                 v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
168                 v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
169                 v.PivotPoint = PivotPoint.TopLeft;
170                 v.Size2D = new Size2D(100, 100);
171
172                 myViewList.Add(v);
173
174                 Window.Instance.GetDefaultLayer().Add(v);
175             }
176
177             for (int i = 350; i < 400; i++)
178             {
179                 Slider v = new Slider();
180
181                 float intensity = myRandom.Next(0, 255) / 255.0f;
182                 v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
183                 v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
184                 v.PivotPoint = PivotPoint.TopLeft;
185                 v.Size2D = new Size2D(100, 100);
186
187                 myViewList.Add(v);
188
189                 Window.Instance.GetDefaultLayer().Add(v);
190             }
191
192             for (int i = 400; i < 450; i++)
193             {
194                 TableView v = new TableView(1, 1);
195
196                 float intensity = myRandom.Next(0, 255) / 255.0f;
197                 v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
198                 v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
199                 v.PivotPoint = PivotPoint.TopLeft;
200                 v.Size2D = new Size2D(100, 100);
201
202                 myViewList.Add(v);
203
204                 Window.Instance.GetDefaultLayer().Add(v);
205             }
206
207             for (int i = 450; i < numberOfObjects; i++)
208             {
209                 View v = new View();
210
211                 float intensity = myRandom.Next(0, 255) / 255.0f;
212                 v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
213                 v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
214                 v.PivotPoint = PivotPoint.TopLeft;
215                 v.Size2D = new Size2D(100, 100);
216
217                 myViewList.Add(v);
218
219                 Window.Instance.GetDefaultLayer().Add(v);
220             }
221
222             return true;
223         }
224
225         protected override void OnPause()
226         {
227             //This function is called when the window's visibility is changed from visible to invisible.
228             base.OnPause();
229         }
230
231         protected override void OnResume()
232         {
233             //This function is called when the window's visibility is changed from invisible to visible.
234             base.OnResume();
235         }
236
237         protected override void OnTerminate()
238         {
239             //This function is called when the app exit normally.
240             base.OnTerminate();
241         }
242         /*
243         protected override void OnLowMemory(LowMemoryEventArgs e)
244         {
245             //This function is called when the system is low on memory.
246             base.OnLowMemory(e);
247         }
248         protected override void OnLocaleChanged(LocaleChangedEventArgs e)
249         {
250             //This function is called when the language is changed.
251             base.OnLocaleChanged(e);
252         }
253         */
254         private static void _Main(string[] args)
255         {
256             //Create an Application
257             Program myProgram = new Program();
258             myProgram.Run(args);
259         }
260     }
261 }