Fix downcast issue for C# CustomView
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / examples / date-picker-using-json.cs
index dbc388c..ade1b72 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -53,7 +53,7 @@ namespace MyCSharpExample
             constants.Insert( "CONFIG_SCRIPT_LOG_LEVEL",  new Property.Value( "Verbose") );
             _builder.AddConstants( constants );
 
-            _builder.LoadFromFile( "./json/date-picker.json" );
+            _builder.LoadFromFile( "./json/date-picker-template.json" );
 
             // create the date-picker from the template in the json file
             BaseHandle handle =  _builder.Create( "date-picker");
@@ -66,21 +66,19 @@ namespace MyCSharpExample
             Actor month  =  actorTree.FindChildByName("Month" );
             Actor day  = actorTree.FindChildByName("Day");
 
-            // need to get the actual C# View associated with the actor,
-            _spinYear = (Spin ) ViewRegistry.GetCustomViewFromActor( year );
-            _spinMonth = (Spin ) ViewRegistry.GetCustomViewFromActor( month );
-            _spinDay = (Spin ) ViewRegistry.GetCustomViewFromActor( day );
+            // need to get the actual C# Spin object associated with the actor,
+            _spinYear = View.DownCast<Spin>( year );
+            _spinMonth = View.DownCast<Spin>( month );
+            _spinDay = View.DownCast<Spin>( day );
 
             _spinYear.Value = 2099;
             _spinMonth.Value = 5;
             _spinDay.Value = 23;
 
-
             _spinYear.SetKeyboardFocusable(true);
             _spinMonth.SetKeyboardFocusable(true);
             _spinDay.SetKeyboardFocusable(true);
 
-
             FocusManager keyboardFocusManager = FocusManager.Instance;
             keyboardFocusManager.PreFocusChange += OnKeyboardPreFocusChange;
             keyboardFocusManager.FocusedActorEnterKeyPressed += OnFocusedActorEnterKeyPressed;