dali-1.2.31, nui 0.2.31 upgrade
[platform/core/csapi/nui.git] / NUISamples / NUISamples.TizenTV / examples / visuals-using-custom-view / visuals-using-custom-view.cs
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 using System;
19 using Tizen.NUI;
20 using Tizen.NUI.Constants;
21
22 namespace VisualsUsingCustomView
23 {
24     class VisualsExample : NUIApplication
25     {
26         public VisualsExample() : base()
27         {
28         }
29
30         public VisualsExample(string stylesheet) : base(stylesheet)
31         {
32         }
33
34         public VisualsExample(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
35         {
36         }
37
38         protected override void OnCreate()
39         {
40             base.OnCreate();
41             Initialize();
42         }
43
44         private void Initialize()
45         {
46             Stage stage = Stage.Instance;
47             stage.BackgroundColor = Color.White;
48
49             TableView contentLayout = new TableView(14, 1);
50             contentLayout.Name = "ContentLayout";
51             contentLayout.WidthResizePolicy = ResizePolicyType.FillToParent;
52             contentLayout.HeightResizePolicy = ResizePolicyType.FillToParent;
53             contentLayout.SetCellPadding(new Size2D(5, 5));
54             contentLayout.BackgroundColor = new Color(0.949f, 0.949f, 0.949f, 1.0f);
55
56             stage.GetDefaultLayer().Add(contentLayout);
57
58             TextLabel title = new TextLabel("Contacts List with Visuals");
59             title.Name = "Title";
60             title.StyleName = "Title";
61             title.WidthResizePolicy = ResizePolicyType.FillToParent;
62             title.HeightResizePolicy = ResizePolicyType.UseNaturalSize;
63             title.HorizontalAlignment = "CENTER";
64             contentLayout.Add(title);
65             contentLayout.SetFitHeight(0);
66
67             // Create ContactView(s) from ContactItem(s) in ContactsList and add them to TableView
68             ContactView contactView;
69             foreach (ContactItem contact in ContactsList.s_contactData)
70             {
71                 contactView = new ContactView();
72                 contactView.WidthResizePolicy = ResizePolicyType.FillToParent;
73                 contactView.HeightResizePolicy = ResizePolicyType.FillToParent;
74
75                 // Configure visuals of ContactView via properties
76                 contactView.Name = contact.Name;
77                 contactView.ImageURL = contact.ImageURL;
78                 contactView.Color = contact.Color;
79                 contactView.Shape = contact.Shape;
80                 contentLayout.Add(contactView);
81             }
82         }
83
84         /// <summary>
85         /// The main entry point for the application.
86         /// </summary>
87         [STAThread]
88         static void _Main(string[] args)
89         {
90             VisualsExample visualsExample = new VisualsExample("/home/owner/apps_rw/NUISamples.TizenTV/res/json/control-dashboard-theme.json");
91             visualsExample.Run(args);
92         }
93     }
94 }