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.Constants;
23 namespace VisualsUsingCustomView
25 class VisualsExample : NUIApplication
27 public VisualsExample() : base()
31 public VisualsExample(string stylesheet) : base(stylesheet)
35 public VisualsExample(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
39 protected override void OnCreate()
45 private void Initialize()
47 Stage stage = Stage.Instance;
48 stage.BackgroundColor = Color.White;
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);
60 stage.GetDefaultLayer().Add(contentLayout);
62 TextLabel title = new TextLabel("Contacts List with Visuals");
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);
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)
75 contactView = new ContactView();
76 contactView.WidthResizePolicy = ResizePolicyType.FillToParent;
77 contactView.HeightResizePolicy = ResizePolicyType.FillToParent;
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);
89 /// The main entry point for the application.
92 static void _Main(string[] args)
95 VisualsExample visualsExample = new VisualsExample();
96 visualsExample.Run(args);