[dali_1.2.40] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / 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 Dali;
20 using Dali.Constants;
21
22 namespace VisualsUsingCustomView
23 {
24     class VisualsExample
25     {
26         public VisualsExample(Application application)
27         {
28             application.Initialized += Initialize;
29         }
30
31         private void Initialize(object source, NUIApplicationInitEventArgs e)
32         {
33             Stage stage = Stage.Instance;
34             stage.BackgroundColor = Color.White;
35
36             TableView contentLayout = new TableView(14, 1);
37             contentLayout.Name = "ContentLayout";
38             contentLayout.WidthResizePolicy = "FILL_TO_PARENT";
39             contentLayout.HeightResizePolicy = "FILL_TO_PARENT";
40             contentLayout.SetCellPadding(new Size2D(5, 5));
41             contentLayout.BackgroundColor = new Color(0.949f, 0.949f, 0.949f, 1.0f);
42
43             stage.GetDefaultLayer().Add(contentLayout);
44
45             TextLabel title = new TextLabel("Contacts List with Visuals");
46             title.Name = "Title";
47             title.StyleName = "Title";
48             title.WidthResizePolicy = "FILL_TO_PARENT";
49             title.HeightResizePolicy = "USE_NATURAL_SIZE";
50             title.HorizontalAlignment = "CENTER";
51             contentLayout.Add(title);
52             contentLayout.SetFitHeight(0);
53
54             // Create ContactView(s) from ContactItem(s) in ContactsList and add them to TableView
55             ContactView contactView;
56             foreach (ContactItem contact in ContactsList.s_contactData)
57             {
58                 contactView = new ContactView();
59                 contactView.WidthResizePolicy = "FILL_TO_PARENT";
60                 contactView.HeightResizePolicy = "FILL_TO_PARENT";
61
62                 // Configure visuals of ContactView via properties
63                 contactView.Name = contact.Name;
64                 contactView.ImageURL = contact.ImageURL;
65                 contactView.Color = contact.Color;
66                 contactView.Shape = contact.Shape;
67                 contentLayout.Add(contactView);
68             }
69         }
70
71         /// <summary>
72         /// The main entry point for the application.
73         /// </summary>
74         [STAThread]
75         static void Main(string[] args)
76         {
77             Application application = Application.NewApplication();
78             VisualsExample visualsExample = new VisualsExample(application);
79             application.MainLoop();
80         }
81     }
82 }