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.Constants;
22 namespace VisualsUsingCustomView
24 class VisualsExample : NUIApplication
26 public VisualsExample() : base()
30 public VisualsExample(string stylesheet) : base(stylesheet)
34 public VisualsExample(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
38 protected override void OnCreate()
44 private void Initialize()
46 Stage stage = Stage.Instance;
47 stage.BackgroundColor = Color.White;
49 TableView contentLayout = new TableView(14, 1);
50 contentLayout.Name = "ContentLayout";
51 //contentLayout.WidthResizePolicy = ResizePolicyType.FillToParent;
52 //contentLayout.HeightResizePolicy = ResizePolicyType.FillToParent;
53 contentLayout.AnchorPoint = AnchorPoint.Center;
54 contentLayout.ParentOrigin = ParentOrigin.Center;
55 contentLayout.Size = new Vector3(stage.Size.Width, stage.Size.Height, 0.0f);
56 contentLayout.SetCellPadding(new Size2D(5, 5));
57 contentLayout.BackgroundColor = new Color(0.949f, 0.949f, 0.949f, 1.0f);
59 stage.GetDefaultLayer().Add(contentLayout);
61 TextLabel title = new TextLabel("Contacts List with Visuals");
63 title.StyleName = "Title";
64 title.WidthResizePolicy = ResizePolicyType.FillToParent;
65 title.HeightResizePolicy = ResizePolicyType.UseNaturalSize;
66 title.HorizontalAlignment = "CENTER";
67 contentLayout.Add(title);
68 contentLayout.SetFitHeight(0);
70 // Create ContactView(s) from ContactItem(s) in ContactsList and add them to TableView
71 ContactView contactView;
72 foreach (ContactItem contact in ContactsList.s_contactData)
74 contactView = new ContactView();
75 contactView.WidthResizePolicy = ResizePolicyType.FillToParent;
76 contactView.HeightResizePolicy = ResizePolicyType.FillToParent;
78 // Configure visuals of ContactView via properties
79 contactView.Name = contact.Name;
80 contactView.ImageURL = contact.ImageURL;
81 contactView.Color = contact.Color;
82 contactView.Shape = contact.Shape;
83 contentLayout.Add(contactView);
88 /// The main entry point for the application.
91 static void Main(string[] args)
93 VisualsExample visualsExample = new VisualsExample();
94 visualsExample.Run(args);