2 * Copyright (c) 2016 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.
19 using System.Runtime.InteropServices;
22 namespace MyExampleApp
26 private Dali.Application _application;
27 private Builder _builder;
28 private string _jsonFileName;
30 public Example(Dali.Application application, string fileName)
32 _application = application;
33 _jsonFileName = fileName;
34 _application.Initialized += Initialize;
37 public void Initialize(object source, NUIApplicationInitEventArgs e)
39 if( _jsonFileName.Length == 0)
41 Console.WriteLine("Please specify JSON file to load");
45 _builder = new Builder ();
47 Property.Map constants = new Property.Map();
49 // In dali-demo we have some JSON files that can be loaded, but they need 3 different macros defining.
50 // The JSON folder is typically installed into dali-env/opt/share/com.samsung.dali-demo/res:
52 //string demoDirectory = ".../dali-env/opt/share/com.samsung.dali-demo/res";
53 //constants.Insert( "DEMO_IMAGE_DIR" , new Property.Value( demoDirectory+"/images") );
54 //constants.Insert( "DEMO_MODEL_DIR" , new Property.Value( demoDirectory+"/models") );
55 //constants.Insert( "DEMO_SCRIPT_DIR", new Property.Value( demoDirectory+"/scripts") );
56 constants.Insert( "CONFIG_SCRIPT_LOG_LEVEL", new Property.Value( "Verbose") );
58 _builder.AddConstants( constants );
61 Stage stage = Stage.GetCurrent();
62 stage.BackgroundColor = Color.White;
64 _builder.LoadFromFile( _jsonFileName );
66 _builder.AddActors( stage.GetRootLayer() );
71 public void MainLoop()
73 _application.MainLoop ();
77 /// The main entry point for the application.
80 static void Main(string[] args)
89 Console.WriteLine("arguments = " + args.Length);
90 Example example = new Example(Application.NewApplication(), fileName);