1 using System.Net.Mime;
3 using System.ComponentModel;
5 * Copyright(c) 2022 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
23 using System.Collections.Generic;
25 using Tizen.NUI.Components;
26 using Tizen.NUI.BaseComponents;
27 using Tizen.NUI.Binding;
28 using System.Reflection;
30 namespace PerformanceTest
32 class Program : NUIApplication
34 private Window window;
35 private Navigator navigator;
36 private ContentPage page;
39 public void OnKeyEvent(object sender, Window.KeyEventArgs e)
41 // FIXME:: Navigator should provide Back/Escape event processing.
42 if (e.Key.State == Key.StateType.Up)
44 if (e.Key.KeyPressedName == "Escape" || e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "BackSpace")
51 protected override void OnCreate()
57 //enable FocusManger default algorithm
58 //FocusManager.Instance.EnableDefaultAlgorithm(true);
60 private void Initialize()
62 window = GetDefaultWindow();
63 window.Title = "세탁코스";
64 window.KeyEvent += OnKeyEvent;
65 path = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
68 private View GetAILaundryCard()
71 var aiLaundry = new View()
73 BackgroundColor = new Tizen.NUI.Color(0.4f, 0.4f, 0.4f, 0.5f),
75 WidthSpecification = 500,
76 HeightSpecification = LayoutParamPolicies.MatchParent,
77 Padding = new Extents(50, 50, 10, 10),
78 Layout = new LinearLayout()
80 LinearOrientation = LinearLayout.Orientation.Vertical,
81 HorizontalAlignment = HorizontalAlignment.Center,
82 VerticalAlignment = VerticalAlignment.Top,
83 CellPadding = new Size2D(0, 30),
87 var laundryTitle = new TextLabel()
92 aiLaundry.Add(laundryTitle);
94 var laundryDuration = new TextLabel()
99 aiLaundry.Add(laundryDuration);
101 var aiLaundryIconView = new View()
103 WidthSpecification = LayoutParamPolicies.MatchParent,
104 HeightSpecification = LayoutParamPolicies.MatchParent,
105 Layout = new LinearLayout()
107 LinearOrientation = LinearLayout.Orientation.Horizontal,
108 HorizontalAlignment = HorizontalAlignment.Center,
109 VerticalAlignment = VerticalAlignment.Center,
110 CellPadding = new Size2D(10, 0),
115 var tempIcon = new ImageView()
117 ResourceUrl = path + "temp.png",
118 WidthSpecification = 50,
119 HeightSpecification = 50,
121 aiLaundryIconView.Add(tempIcon);
123 var cleaningIcon = new ImageView()
125 ResourceUrl = path + "cleaning.png",
126 WidthSpecification = 50,
127 HeightSpecification = 50,
129 aiLaundryIconView.Add(cleaningIcon);
131 var dryIcon = new ImageView()
133 ResourceUrl = path + "dry.png",
134 WidthSpecification = 50,
135 HeightSpecification = 50,
137 aiLaundryIconView.Add(dryIcon);
138 aiLaundry.Add(aiLaundryIconView);
143 private View GetStdLaundryCard()
146 var stdLaundry = new View()
148 BackgroundColor = new Tizen.NUI.Color(0.4f, 0.4f, 0.4f, 0.5f),
150 WidthSpecification = 250,
151 HeightSpecification = LayoutParamPolicies.MatchParent,
152 Padding = new Extents(50, 50, 10, 10),
153 Layout = new LinearLayout()
155 LinearOrientation = LinearLayout.Orientation.Vertical,
156 HorizontalAlignment = HorizontalAlignment.Center,
157 VerticalAlignment = VerticalAlignment.Top,
158 CellPadding = new Size2D(0, 30),
162 var laundryTitle = new TextLabel()
167 stdLaundry.Add(laundryTitle);
169 var laundryDuration = new TextLabel()
174 stdLaundry.Add(laundryDuration);
179 private View GetPetCareLaundryCard()
182 var petCareLaundry = new View()
184 BackgroundColor = new Tizen.NUI.Color(0.4f, 0.4f, 0.4f, 0.5f),
186 WidthSpecification = 250,
187 HeightSpecification = LayoutParamPolicies.MatchParent,
188 Padding = new Extents(50, 50, 10, 10),
189 Layout = new LinearLayout()
191 LinearOrientation = LinearLayout.Orientation.Vertical,
192 HorizontalAlignment = HorizontalAlignment.Center,
193 VerticalAlignment = VerticalAlignment.Top,
194 CellPadding = new Size2D(0, 30),
198 var laundryTitle = new TextLabel()
203 petCareLaundry.Add(laundryTitle);
205 var laundryDuration = new TextLabel()
210 petCareLaundry.Add(laundryDuration);
212 return petCareLaundry;
215 private View GetLaundryView()
217 var aiCard = GetAILaundryCard();
218 var stdCard = GetStdLaundryCard();
219 var petCareCard = GetPetCareLaundryCard();
222 var laundryContent = new View()
224 WidthSpecification = 1070,
225 HeightSpecification = LayoutParamPolicies.MatchParent,
226 Padding = new Extents(10, 10, 10, 10),
227 Layout = new LinearLayout()
229 LinearOrientation = LinearLayout.Orientation.Horizontal,
230 HorizontalAlignment = HorizontalAlignment.Center,
231 VerticalAlignment = VerticalAlignment.Center,
232 CellPadding = new Size2D(20, 0),
235 laundryContent.Add(aiCard);
236 laundryContent.Add(stdCard);
237 laundryContent.Add(petCareCard);
239 return laundryContent;
242 private View GetDryerCard(string title, string duration, bool start, float progress = 0f)
244 var dryCard = new View()
246 BackgroundColor = new Tizen.NUI.Color(0.4f, 0.4f, 0.4f, 0.5f),
248 WidthSpecification = LayoutParamPolicies.MatchParent,
249 HeightSpecification = LayoutParamPolicies.MatchParent,
250 Padding = new Extents(10, 10, 10, 10),
251 Layout = new LinearLayout()
253 LinearOrientation = LinearLayout.Orientation.Vertical,
254 HorizontalAlignment = HorizontalAlignment.Center,
255 VerticalAlignment = VerticalAlignment.Center,
256 CellPadding = new Size2D(0, 10),
260 var laundryTitle = new TextLabel()
265 dryCard.Add(laundryTitle);
267 var dryDurationPlay = new View()
269 WidthSpecification = LayoutParamPolicies.MatchParent,
270 HeightSpecification = LayoutParamPolicies.WrapContent,
271 Padding = new Extents(0, 0, 10, 10),
272 Layout = new LinearLayout()
274 LinearOrientation = LinearLayout.Orientation.Horizontal,
275 HorizontalAlignment = HorizontalAlignment.Center,
276 VerticalAlignment = VerticalAlignment.Center,
277 CellPadding = new Size2D(0, 10),
281 var laundryDuration = new TextLabel()
283 WidthSpecification = LayoutParamPolicies.MatchParent,
287 dryDurationPlay.Add(laundryDuration);
289 var laundryPauseIcon = new ImageView()
291 ResourceUrl = path + (start? "pause.png" :"play.png"),
292 WidthSpecification = 50,
293 HeightSpecification = 50,
295 dryDurationPlay.Add(laundryPauseIcon);
296 dryCard.Add(dryDurationPlay);
298 var dryProgress = new Progress()
300 WidthSpecification = LayoutParamPolicies.MatchParent,
303 CurrentValue = progress,
305 dryCard.Add(dryProgress);
310 private View GetDryerView()
312 var stdDryerdard = GetDryerCard("표준 건조", "1시간 20분", true, 0.35f);
313 var aiDryerdard = GetDryerCard("AI 건조", "2시간 00분", false);
315 var dryerContent = new View()
317 WidthSpecification = 1070,
318 HeightSpecification = LayoutParamPolicies.MatchParent,
319 Padding = new Extents(10, 10, 10, 10),
320 Layout = new LinearLayout()
322 LinearOrientation = LinearLayout.Orientation.Vertical,
323 HorizontalAlignment = HorizontalAlignment.Center,
324 VerticalAlignment = VerticalAlignment.Center,
325 CellPadding = new Size2D(0, 20),
328 dryerContent.Add(stdDryerdard);
329 dryerContent.Add(aiDryerdard);
334 private void SetMainPage()
336 var rootView = new View()
338 BackgroundColor = Tizen.NUI.Color.Black,
339 WidthSpecification = LayoutParamPolicies.MatchParent,
340 HeightSpecification = LayoutParamPolicies.MatchParent,
341 Padding = new Extents(5, 5, 5, 5),
342 Layout = new LinearLayout()
344 LinearOrientation = LinearLayout.Orientation.Vertical,
345 HorizontalAlignment = HorizontalAlignment.Center,
346 VerticalAlignment = VerticalAlignment.Top,
347 CellPadding = new Size2D(0, 0),
351 var luandryContent = GetLaundryView();
352 var dryerContent = GetDryerView();
354 var contentView = new ScrollableBase()
356 BackgroundColor = new Tizen.NUI.Color(0.2f,0.2f,0.2f,0.5f),
357 WidthSpecification = LayoutParamPolicies.MatchParent,
358 HeightSpecification = LayoutParamPolicies.MatchParent,
359 Padding = new Extents(5, 5, 5, 5),
360 ScrollingDirection = ScrollableBase.Direction.Horizontal,
362 Layout = new LinearLayout()
364 LinearOrientation = LinearLayout.Orientation.Horizontal,
365 HorizontalAlignment = HorizontalAlignment.Begin,
366 VerticalAlignment = VerticalAlignment.Center,
367 CellPadding = new Size2D(10, 0),
370 contentView.Add(luandryContent);
371 contentView.Add(dryerContent);
373 var laundryBtn = new Button()
379 laundryBtn.Clicked += (object sender, ClickedEventArgs e) =>
381 contentView.ScrollToIndex(0);
384 var dryerBtn = new Button()
390 dryerBtn.Clicked += (object sender, ClickedEventArgs e) =>
392 contentView.ScrollToIndex(1);
395 var buttonView = new View()
397 WidthSpecification = LayoutParamPolicies.MatchParent,
398 HeightSpecification = 80,
399 Layout = new LinearLayout()
401 LinearOrientation = LinearLayout.Orientation.Horizontal,
402 HorizontalAlignment = HorizontalAlignment.Begin,
403 VerticalAlignment = VerticalAlignment.Center,
404 CellPadding = new Size2D(10, 0),
408 buttonView.Add(laundryBtn);
409 buttonView.Add(dryerBtn);
411 rootView.Add(buttonView);
412 rootView.Add(contentView);
414 window.Add(rootView);
418 private void FullGC()
420 global::System.GC.Collect();
421 global::System.GC.WaitForPendingFinalizers();
422 global::System.GC.Collect();
425 static void Main(string[] args)
427 var app = new Program();