nui 0.2.32 manual merge, mapping to dali 1.2.32
[platform/core/csapi/tizenfx.git] / NUISamples / 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.AnchorPoint = AnchorPoint.Center;
54             contentLayout.ParentOrigin = ParentOrigin.Center;
55             contentLayout.Size = new Vector3(stage.Size.Width, stage.Size.Height, 0.0f);
56             contentLayout.SetCellPadding(new Size2D(5, 5));
57             contentLayout.BackgroundColor = new Color(0.949f, 0.949f, 0.949f, 1.0f);
58
59             stage.GetDefaultLayer().Add(contentLayout);
60
61             TextLabel title = new TextLabel("Contacts List with Visuals");
62             title.Name = "Title";
63             title.StyleName = "Title";
64             title.WidthResizePolicy = ResizePolicyType.FillToParent;
65             title.HeightResizePolicy = ResizePolicyType.UseNaturalSize;
66             title.HorizontalAlignment = "CENTER";
67             contentLayout.Add(title);
68             contentLayout.SetFitHeight(0);
69
70             // Create ContactView(s) from ContactItem(s) in ContactsList and add them to TableView
71             ContactView contactView;
72             foreach (ContactItem contact in ContactsList.s_contactData)
73             {
74                 contactView = new ContactView();
75                 contactView.WidthResizePolicy = ResizePolicyType.FillToParent;
76                 contactView.HeightResizePolicy = ResizePolicyType.FillToParent;
77
78                 // Configure visuals of ContactView via properties
79                 contactView.Name = contact.Name;
80                 contactView.ImageURL = contact.ImageURL;
81                 contactView.Color = contact.Color;
82                 contactView.Shape = contact.Shape;
83                 contentLayout.Add(contactView);
84             }
85             }
86
87         /// <summary>
88         /// The main entry point for the application.
89         /// </summary>
90         [STAThread]
91         static void Main(string[] args)
92         {
93             VisualsExample visualsExample = new VisualsExample();
94             visualsExample.Run(args);
95         }
96     }
97 }