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.
22 namespace VisualsUsingCustomView
26 public VisualsExample(Application application)
28 application.Initialized += Initialize;
31 private void Initialize(object source, NUIApplicationInitEventArgs e)
33 Stage stage = Stage.Instance;
34 stage.BackgroundColor = Color.White;
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);
43 stage.GetDefaultLayer().Add(contentLayout);
45 TextLabel title = new TextLabel("Contacts List with Visuals");
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);
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)
58 contactView = new ContactView();
59 contactView.WidthResizePolicy = "FILL_TO_PARENT";
60 contactView.HeightResizePolicy = "FILL_TO_PARENT";
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);
72 /// The main entry point for the application.
75 static void Main(string[] args)
77 Application application = Application.NewApplication();
78 VisualsExample visualsExample = new VisualsExample(application);
79 application.MainLoop();