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