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;
21 using Tizen.NUI.BaseComponents;
23 namespace VisualsExampleTest
25 class Example : NUIApplication
27 private TextLabel _title;
28 private const string resources = "/home/owner/apps_rw/NUISamples.TizenTV/res";
30 public Example() : base()
34 public Example(string stylesheet) : base(stylesheet)
38 public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
42 protected override void OnCreate()
48 public void Initialize()
50 Window window = Window.Instance;
51 window.BackgroundColor = Color.White;
53 TableView contentLayout = new TableView(4, 1);
54 contentLayout.Name = ("ContentLayout");
55 contentLayout.WidthResizePolicy = ResizePolicyType.FillToParent;
56 contentLayout.HeightResizePolicy = ResizePolicyType.FillToParent;
58 contentLayout.SetCellPadding(new Size2D(0, 5));
59 contentLayout.BackgroundColor = Color.Red;//new Color(0.949f, 0.949f, 0.949f, 1.0f);
61 window.Add(contentLayout);
63 _title = new TextLabel("Visuals Example");
64 _title.Name = "Title";
65 _title.StyleName = "Title";
66 _title.WidthResizePolicy = ResizePolicyType.FillToParent;
67 _title.HeightResizePolicy = ResizePolicyType.UseNaturalSize;
68 _title.HorizontalAlignment = HorizontalAlignment.Center;
69 _title.BackgroundColor = Color.Yellow;
70 contentLayout.Add(_title);
71 contentLayout.SetFitHeight(0);
73 // Color Visual example
74 ImageView colorView = new ImageView();
75 //colorView.WidthResizePolicy = ResizePolicyType.SizeRelativeToParent;
76 //colorView.HeightResizePolicy = ResizePolicyType.SizeRelativeToParent;
77 // PropertyMap colorVisual = new PropertyMap();
78 // colorVisual.Add( Visual.Property.Type, new PropertyValue( (int)Visual.Type.Color ))
79 // .Add( ColorVisualProperty.MixColor, new PropertyValue( Color.Green ));
80 //colorView.Background = colorVisual;
81 colorView.Size2D = new Size2D(500, 200);
82 colorView.ResourceUrl = resources+"/images/00_popup_bg.9.png";
83 colorView.Border = new Rectangle(100, 100, 100, 100);
85 // PropertyMap _map = new PropertyMap();
86 // _map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
87 // _map.Add(NpatchImageVisualProperty.URL, new PropertyValue(resources+"/images/00_popup_bg.9.png"));
88 // _map.Add(NpatchImageVisualProperty.Border, new PropertyValue(new Rectangle(100, 100, 100, 100)));
89 //_map.Add(NpatchImageVisualProperty.BorderOnly, new PropertyValue(true));
90 //colorView.Background = _map;
91 contentLayout.Add(colorView);
93 // Image Visual example
94 View imageView = new View();
95 imageView.WidthResizePolicy = ResizePolicyType.UseNaturalSize;
96 imageView.HeightResizePolicy = ResizePolicyType.UseNaturalSize;
97 PropertyMap imageVisual = new PropertyMap();
98 imageVisual.Add( Visual.Property.Type, new PropertyValue( (int)Visual.Type.Image ));
99 imageVisual.Add(ImageVisualProperty.URL, new PropertyValue( resources + "/images/gallery-0.jpg" ));
100 imageView.Background = imageVisual;
101 contentLayout.SetCellAlignment(new TableView.CellPosition(2, 0), HorizontalAlignmentType.Center, VerticalAlignmentType.Center);
102 contentLayout.Add(imageView);
103 for(int i =1; i<=5; i++)
105 PropertyMap imageVisual1 = new PropertyMap();
106 imageVisual1.Add( Visual.Property.Type, new PropertyValue( (int)Visual.Type.Image ));
107 imageVisual1.Add(ImageVisualProperty.URL, new PropertyValue( resources + "/images/gallery-"+i+".jpg" ));
108 imageView.Background = imageVisual1;
111 // Primitive Visual example
112 View primitiveView = new View();
113 primitiveView.WidthResizePolicy = ResizePolicyType.SizeRelativeToParent;
114 primitiveView.HeightResizePolicy = ResizePolicyType.SizeRelativeToParent;
115 PropertyMap primitiveVisual = new PropertyMap();
116 primitiveVisual.Add( Visual.Property.Type, new PropertyValue( (int)Visual.Type.Primitive ))
117 .Add( PrimitiveVisualProperty.Shape, new PropertyValue((int)PrimitiveVisualShapeType.BevelledCube))
118 .Add( PrimitiveVisualProperty.BevelPercentage, new PropertyValue(0.3f))
119 .Add( PrimitiveVisualProperty.BevelSmoothness, new PropertyValue(0.0f))
120 .Add( PrimitiveVisualProperty.ScaleDimensions, new PropertyValue(new Vector3(1.0f,1.0f,0.3f)))
121 .Add( PrimitiveVisualProperty.MixColor, new PropertyValue(new Vector4(0.7f, 0.5f, 0.05f, 1.0f)));
122 primitiveView.Background = primitiveVisual;
123 Radian rad = new Radian(new Degree(45.0f));
124 primitiveView.Orientation = new Rotation(rad, Vector3.YAxis);
125 contentLayout.Add(primitiveView);
127 // Text Visual example
128 View textView = new View();
129 textView.WidthResizePolicy = ResizePolicyType.SizeRelativeToParent;
130 textView.HeightResizePolicy = ResizePolicyType.SizeRelativeToParent;
131 PropertyMap textVisual = new PropertyMap();
132 textVisual.Add( Visual.Property.Type, new PropertyValue( (int)Visual.Type.Text ))
133 .Add( TextVisualProperty.Text, new PropertyValue("I am text visual"))
134 .Add( TextVisualProperty.TextColor, new PropertyValue(Color.Blue))
135 .Add( TextVisualProperty.PointSize, new PropertyValue(20));
136 textView.Background = textVisual;
137 contentLayout.Add(textView);
141 /// The main entry point for the application.
144 static void _Main(string[] args)
146 Example example = new Example( resources + "/json/style-example-theme-one.json");