+ private Dali.Application _application;
+
+ public Example(Dali.Application application)
+ {
+ _application = application;
+ Console.WriteLine("1) InitSignal connection count = " + _application.InitSignal().GetConnectionCount());
+
+ _application.Initialized += Initialize;
+ Console.WriteLine("2) InitSignal connection count = " + _application.InitSignal().GetConnectionCount());
+ }
+
+ public void Initialize(object source, NUIApplicationInitEventArgs e)
+ {
+
+ //1)
+ NavigationPropertiesTests();
+
+ //2)
+ OperatorTests();
+
+ //3)
+ CustomViewPropertyTest();
+
+ //4)
+ ActorHandleTest();
+
+ //5)
+ RectanglePaddingClassTest();
+
+ //6)
+ SizePositionTest();
+
+ //7)
+ ViewDownCastTest();
+
+ }
+
+
+ public void NavigationPropertiesTests()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("### [1] NavigationPropertiesTests START");
+
+ View view = new View();
+ View leftView, rightView, upView, downView, tmpView;
+
+ leftView = new View();
+ leftView.Name = "leftView";
+ rightView = new View();
+ rightView.Name = "rightView";
+ upView = new View();
+ upView.Name = "upView";
+ downView = new View();
+ downView.Name = "downView";
+
+ Stage.Instance.Add(leftView);
+ Stage.Instance.Add(rightView);
+ Stage.Instance.Add(upView);
+ Stage.Instance.Add(downView);
+
+ view.LeftFocusableView = leftView;
+ tmpView = view.LeftFocusableView;
+ if (string.Compare(tmpView.Name, "leftView") == 0)
+ {
+ Console.WriteLine("Passed: LeftFocusedView = " + tmpView.Name);
+ }
+ else
+ {
+ Console.WriteLine("Failed: LeftFocusedView = " + tmpView.Name);
+ }
+
+ view.RightFocusableView = rightView;
+ tmpView = view.RightFocusableView;
+ if (string.Compare(tmpView.Name, "rightView") == 0)
+ {
+ Console.WriteLine("Passed: RightFocusedView = " + tmpView.Name);
+ }
+ else
+ {
+ Console.WriteLine("Failed: RightFocusedView = " + tmpView.Name);
+ }
+
+ Stage.Instance.Add(view);
+
+ view.UpFocusableView = upView;
+ tmpView = view.UpFocusableView;
+ if (string.Compare(tmpView.Name, "upView") == 0)
+ {
+ Console.WriteLine("Passed: UpFocusedView = " + tmpView.Name);
+ }
+ else
+ {
+ Console.WriteLine("Failed: UpFocusedView = " + tmpView.Name);
+ }
+
+ view.DownFocusableView = downView;
+ tmpView = view.DownFocusableView;
+ if (string.Compare(tmpView.Name, "downView") == 0)
+ {
+ Console.WriteLine("Passed: DownFocusedView = " + tmpView.Name);
+ }
+ else
+ {
+ Console.WriteLine("Failed: DownFocusedView = " + tmpView.Name);
+ }
+
+ Stage.Instance.Remove(leftView);
+ tmpView = view.LeftFocusableView;
+ if (!tmpView)
+ {
+ Console.WriteLine("Passed: NULL LeftFocusedView");
+ }
+ else
+ {
+ Console.WriteLine("Failed: LeftFocusedView = " + tmpView.Name);
+ }
+
+ Console.WriteLine("### [1] NavigationPropertiesTests END");
+ }
+
+ public void OperatorTests()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("### [2] OperatorTests START");
+ Actor actor = new Actor();
+ Actor differentActor = new Actor();
+ Actor actorSame = actor;
+ Actor nullActor = null;
+
+ // test the true operator
+ if (actor)
+ {
+ Console.WriteLine("BaseHandle Operator true (actor) : test passed ");
+ }
+ else
+ {
+ Console.WriteLine("BaseHandle Operator true (actor): test failed ");
+ }
+
+ Actor parent = actor.GetParent();
+
+ if (parent)
+ {
+ Console.WriteLine("Handle with Empty body :failed ");
+ }
+ else
+ {
+ Console.WriteLine("Valid with Empty body :passed ");
+ }
+
+ actor.Add(differentActor);
+
+ // here we test two different C# objects, which on the native side have the same body/ ref-object
+ if (actor == differentActor.GetParent())
+ {
+ Console.WriteLine("actor == differentActor.GetParent() :passed ");
+ }
+ else
+ {
+ Console.WriteLine("actor == differentActor.GetParent() :failed ");
+ }
+
+ if (differentActor == differentActor.GetParent())
+ {
+ Console.WriteLine("differentActor == differentActor.GetParent() :failed ");
+ }
+ else
+ {
+ Console.WriteLine("differentActor == differentActor.GetParent() :passed ");
+ }
+
+ if (nullActor)
+ {
+ Console.WriteLine("BaseHandle Operator true (nullActor) : test failed ");
+ }
+ else
+ {
+ Console.WriteLine("BaseHandle Operator true (nullActor): test passed ");
+ }
+
+ // ! operator
+ if (!actor)
+ {
+ Console.WriteLine("BaseHandle Operator !(actor) : test failed ");
+ }
+ else
+ {
+ Console.WriteLine("BaseHandle Operator !(actor): test passed ");
+ }
+
+ if (!nullActor)
+ {
+ Console.WriteLine("BaseHandle Operator !(nullActor) : test passed ");
+ }
+ else
+ {
+ Console.WriteLine("BaseHandle Operator !(nullActor): test failed ");
+ }
+
+ // Note: operator false only used inside & operator
+ // test equality operator ==
+ if (actor == actorSame)
+ {
+ Console.WriteLine("BaseHandle Operator (actor == actorSame) : test passed");
+ }
+ else
+ {
+ Console.WriteLine("BaseHandle Operator (actor == actorSame) : test failed");
+ }
+
+ if (actor == differentActor)
+ {
+ Console.WriteLine("BaseHandle Operator (actor == differentActor) : test failed");
+ }
+ else
+ {
+ Console.WriteLine("BaseHandle Operator (actor == differentActor) : test passed");
+ }
+
+ if (actor == nullActor)
+ {
+ Console.WriteLine("BaseHandle Operator (actor == nullActor) : test failed");
+ }
+ else
+ {
+ Console.WriteLine("BaseHandle Operator (actor == nullActor) : test passed");
+ }
+
+ if (nullActor == nullActor)
+ {
+ Console.WriteLine("BaseHandle Operator (nullActor == nullActor) : test passed");
+ }
+ else
+ {
+ Console.WriteLine("BaseHandle Operator (nullActor == nullActor) : test failed");
+ }
+
+ // test || operator
+ if (actor || actorSame)
+ {
+ Console.WriteLine("BaseHandle Operator (actor || actorSame) : test passed");
+ }
+ else
+ {
+ Console.WriteLine("BaseHandle Operator (actor || actorSame) : test failed");
+ }
+
+ if (actor || nullActor)
+ {
+ Console.WriteLine("BaseHandle Operator (actor || nullActor) : test passed");
+ }
+ else
+ {
+ Console.WriteLine("BaseHandle Operator (actor || nullActor) : test failed");
+ }
+
+ if (nullActor || nullActor)
+ {
+ Console.WriteLine("BaseHandle Operator (nullActor || nullActor) : test failed");
+ }
+ else
+ {
+ Console.WriteLine("BaseHandle Operator (nullActor || nullActor) : test passed");
+ }
+
+ // test && operator
+ if (actor && actorSame)
+ {
+ Console.WriteLine("BaseHandle Operator (actor && actorSame) : test passed");
+ }
+ else
+ {
+ Console.WriteLine("BaseHandle Operator (actor && actorSame) : test failed");
+ }
+
+ if (actor && nullActor)
+ {
+ Console.WriteLine("BaseHandle Operator (actor && nullActor) : test failed");
+ }
+ else
+ {
+ Console.WriteLine("BaseHandle Operator (actor && nullActor) : test passed");
+ }
+
+ if (nullActor && nullActor)
+ {
+ Console.WriteLine("BaseHandle Operator (nullActor && nullActor) : test failed");
+ }
+ else
+ {
+ Console.WriteLine("BaseHandle Operator (nullActor && nullActor) : test passed");
+ }
+
+ Console.WriteLine("### [2] OperatorTests END");
+
+ }
+
+ public void CustomViewPropertyTest()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("### [3] CustomViewPropertyTest START");
+
+ // Create a Spin control
+ Spin spin = new Spin();
+
+ // Background property
+ Property.Map background = new Property.Map();
+ background.Add(Dali.Constants.Visual.Property.Type, new Property.Value((int)Dali.Constants.Visual.Type.Color))
+ .Add(Dali.Constants.ColorVisualProperty.MixColor, new Property.Value(Color.Red));
+ spin.Background = background;
+
+ background = spin.Background;
+ Color backgroundColor = new Color();
+ background.Find(Dali.Constants.ColorVisualProperty.MixColor).Get(backgroundColor);
+
+ if (backgroundColor == Color.Red)
+ {
+ Console.WriteLine("Custom View Background property : test passed");
+ }
+ else
+ {
+ Console.WriteLine("Custom View Background property : test failed");
+ }
+
+ // BackgroundColor property
+ spin.BackgroundColor = Color.Yellow;
+
+ if (spin.BackgroundColor.EqualTo(Color.Yellow))
+ {
+ Console.WriteLine("Custom View BackgroundColor property : test passed");
+ }
+ else
+ {
+ Console.WriteLine("Custom View BackgroundColor property : test failed");
+ }
+
+ // BackgroundImage property
+ spin.BackgroundImage = "background-image.jpg";
+ if (spin.BackgroundImage == "background-image.jpg")
+ {
+ Console.WriteLine("Custom View BackgroundImage property : test passed");
+ }
+ else
+ {
+ Console.WriteLine("Custom View BackgroundImage property : test failed");
+ }
+
+ // StyleName property
+ spin.StyleName = "MyCustomStyle";
+ if (spin.StyleName == "MyCustomStyle")
+ {
+ Console.WriteLine("Custom View StyleName property : test passed");
+ }
+ else
+ {
+ Console.WriteLine("Custom View StyleName property : test failed");
+ }
+
+ Console.WriteLine("### [3] CustomViewPropertyTest END");
+ }
+
+
+
+ public void ActorHandleTest()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("### [4] ActorHandleTest START");
+
+ Handle handle = new Handle();
+ int myPropertyIndex = handle.RegisterProperty("myProperty", new Property.Value(10.0f), Property.AccessMode.READ_WRITE);
+ float myProperty = 0.0f;
+ handle.GetProperty(myPropertyIndex).Get(ref myProperty);
+ Console.WriteLine("myProperty value: " + myProperty);
+
+ int myPropertyIndex2 = handle.RegisterProperty("myProperty2", new Property.Value(new Size(5.0f, 5.0f, 5.0f)), Property.AccessMode.READ_WRITE);
+ Size myProperty2 = new Size(0.0f, 0.0f, 0.0f);
+ handle.GetProperty(myPropertyIndex2).Get(myProperty2);
+ Console.WriteLine("myProperty2 value: " + myProperty2.Width + ", " + myProperty2.Height);
+
+ Actor actor = new Actor();
+ actor.Size = new Position(200.0f, 200.0f, 0.0f);
+ actor.Name = "MyActor";
+ Console.WriteLine("Actor id: {0}", actor.GetId());
+ Console.WriteLine("Actor size: " + actor.Size.X + ", " + actor.Size.Y);
+ Console.WriteLine("Actor name: " + actor.Name);
+
+ Stage stage = Stage.GetCurrent();
+ stage.BackgroundColor = Color.White;
+ Size2D stageSize = stage.Size;
+ Console.WriteLine("Stage size: " + stageSize.Width + ", " + stageSize.Height);
+ stage.Add(actor);