Manual merge for nui v0.2.35.
[platform/core/csapi/nui.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.UIComponents;
21 using Tizen.NUI.Constants;
22
23 namespace VisualsUsingCustomView
24 {
25     class VisualsExample : NUIApplication
26     {
27         public VisualsExample() : base()
28         {
29         }
30
31         public VisualsExample(string stylesheet) : base(stylesheet)
32         {
33         }
34
35         public VisualsExample(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
36         {
37         }
38
39         protected override void OnCreate()
40         {
41             base.OnCreate();
42             Initialize();
43         }
44
45         private void Initialize()
46         {
47             Stage stage = Stage.Instance;
48             stage.BackgroundColor = Color.White;
49
50             TableView contentLayout = new TableView(14, 1);
51             contentLayout.Name = "ContentLayout";
52             //contentLayout.WidthResizePolicy = ResizePolicyType.FillToParent;
53             //contentLayout.HeightResizePolicy = ResizePolicyType.FillToParent;
54             contentLayout.AnchorPoint = AnchorPoint.Center;
55             contentLayout.ParentOrigin = ParentOrigin.Center;
56             contentLayout.Size = new Vector3(stage.Size.Width, stage.Size.Height, 0.0f);
57             contentLayout.SetCellPadding(new Size2D(5, 5));
58             contentLayout.BackgroundColor = new Color(0.949f, 0.949f, 0.949f, 1.0f);
59
60             stage.GetDefaultLayer().Add(contentLayout);
61
62             TextLabel title = new TextLabel("Contacts List with Visuals");
63             title.Name = "Title";
64             title.StyleName = "Title";
65             title.WidthResizePolicy = ResizePolicyType.FillToParent;
66             title.HeightResizePolicy = ResizePolicyType.UseNaturalSize;
67             title.HorizontalAlignment = HorizontalAlignment.HorizontalAlignCenter;
68             contentLayout.Add(title);
69             contentLayout.SetFitHeight(0);
70
71             // Create ContactView(s) from ContactItem(s) in ContactsList and add them to TableView
72             ContactView contactView;
73             foreach (ContactItem contact in ContactsList.s_contactData)
74             {
75                 contactView = new ContactView();
76                 contactView.WidthResizePolicy = ResizePolicyType.FillToParent;
77                 contactView.HeightResizePolicy = ResizePolicyType.FillToParent;
78
79                 // Configure visuals of ContactView via properties
80                 contactView.Name = contact.Name;
81                 contactView.ImageURL = contact.ImageURL;
82                 contactView.Color = contact.Color;
83                 contactView.Shape = contact.Shape;
84                 contentLayout.Add(contactView);
85             }
86             }
87
88         /// <summary>
89         /// The main entry point for the application.
90         /// </summary>
91         [STAThread]
92         static void _Main(string[] args)
93         {
94             
95             VisualsExample visualsExample = new VisualsExample();
96             visualsExample.Run(args);
97         }
98     }
99 }