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.SetCellPadding(new Size2D(5, 5));
54 contentLayout.BackgroundColor = new Color(0.949f, 0.949f, 0.949f, 1.0f);
56 stage.GetDefaultLayer().Add(contentLayout);
58 TextLabel title = new TextLabel("Contacts List with Visuals");
60 title.StyleName = "Title";
61 title.WidthResizePolicy = ResizePolicyType.FillToParent;
62 title.HeightResizePolicy = ResizePolicyType.UseNaturalSize;
63 title.HorizontalAlignment = "CENTER";
64 contentLayout.Add(title);
65 contentLayout.SetFitHeight(0);
67 // Create ContactView(s) from ContactItem(s) in ContactsList and add them to TableView
68 ContactView contactView;
69 foreach (ContactItem contact in ContactsList.s_contactData)
71 contactView = new ContactView();
72 contactView.WidthResizePolicy = ResizePolicyType.FillToParent;
73 contactView.HeightResizePolicy = ResizePolicyType.FillToParent;
75 // Configure visuals of ContactView via properties
76 contactView.Name = contact.Name;
77 contactView.ImageURL = contact.ImageURL;
78 contactView.Color = contact.Color;
79 contactView.Shape = contact.Shape;
80 contentLayout.Add(contactView);
85 /// The main entry point for the application.
88 static void _Main(string[] args)
90 VisualsExample visualsExample = new VisualsExample("/home/owner/apps_rw/NUISamples.TizenTV/res/json/control-dashboard-theme.json");
91 visualsExample.Run(args);