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