2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 using Tizen.NUI.UIComponents;
21 using Tizen.NUI.BaseComponents;
22 using Tizen.NUI.Constants;
24 namespace VisualsUsingCustomView
26 class VisualsExample : NUIApplication
28 public VisualsExample() : base()
32 public VisualsExample(string stylesheet) : base(stylesheet)
36 public VisualsExample(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
40 protected override void OnCreate()
46 private void Initialize()
48 Window window = Window.Instance;
49 window.BackgroundColor = Color.White;
51 TableView contentLayout = new TableView(14, 1);
52 contentLayout.Name = "ContentLayout";
53 //contentLayout.WidthResizePolicy = ResizePolicyType.FillToParent;
54 //contentLayout.HeightResizePolicy = ResizePolicyType.FillToParent;
55 contentLayout.PivotPoint = PivotPoint.TopLeft;
56 contentLayout.ParentOrigin = ParentOrigin.TopLeft;
57 contentLayout.Size2D = new Vector2(window.Size.Width, window.Size.Height);
58 contentLayout.SetCellPadding(new Size2D(5, 5));
59 contentLayout.BackgroundColor = new Color(0.949f, 0.949f, 0.949f, 1.0f);
61 window.Add(contentLayout);
63 TextLabel title = new TextLabel("Contacts List with Visuals");
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);
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)
76 contactView = new ContactView();
77 contactView.WidthResizePolicy = ResizePolicyType.FillToParent;
78 contactView.HeightResizePolicy = ResizePolicyType.FillToParent;
80 // Configure visuals of ContactView via properties
81 contactView.NameField = contact.Name;
82 contactView.MaskURL = contact.MaskURL;
83 contactView.ImageURL = contact.ImageURL;
84 contactView.Color = contact.Color;
85 contactView.Shape = contact.Shape;
86 contentLayout.Add(contactView);
91 /// The main entry point for the application.
94 static void _Main(string[] args)
96 VisualsExample visualsExample = new VisualsExample();
97 visualsExample.Run(args);