X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=plugins%2Fdali-swig%2Fexamples%2Fdali-test.cs;h=a4a3a1e3da72bbab925b9e1789c0315922b8e5f5;hp=ce7899b19d35dacff97febc627774043598e8d47;hb=071fcd1b53571defd28db3f3563645b5f32e6329;hpb=a3b69d118ee5f918a827b23ea76813a7aefad845 diff --git a/plugins/dali-swig/examples/dali-test.cs b/plugins/dali-swig/examples/dali-test.cs old mode 100644 new mode 100755 index ce7899b..a4a3a1e --- a/plugins/dali-swig/examples/dali-test.cs +++ b/plugins/dali-swig/examples/dali-test.cs @@ -21,6 +21,75 @@ using Dali; namespace MyCSharpExample { + class MyView : View + { + private string _myOwnName; + public int _myCurrentValue; + + public MyView() + { + _myCurrentValue = 0; + } + + public string MyOwnName + { + get + { + return _myOwnName; + } + set + { + _myOwnName = value; + } + } + } + + class MyButton : PushButton + { + private string _myOwnName; + public int _myCurrentValue; + + public MyButton() + { + _myCurrentValue = 0; + } + + public string MyOwnName + { + get + { + return _myOwnName; + } + set + { + _myOwnName = value; + } + } + } + + class MySpin : Spin + { + private string _myOwnName; + public int _myCurrentValue; + + public MySpin() + { + _myCurrentValue = 0; + } + + public string MyOwnName + { + get + { + return _myOwnName; + } + set + { + _myOwnName = value; + } + } + } + class Example { [UnmanagedFunctionPointer(CallingConvention.StdCall)] @@ -39,6 +108,8 @@ namespace MyCSharpExample public void Initialize(object source, NUIApplicationInitEventArgs e) { + NavigationPropertiesTests(); + OperatorTests(); CustomViewPropertyTest(); @@ -57,7 +128,7 @@ namespace MyCSharpExample Actor actor = new Actor(); actor.Size = new Position(200.0f, 200.0f, 0.0f); actor.Name = "MyActor"; - actor.Color = new Color(1.0f, 0.0f, 1.0f, 0.8f); + Console.WriteLine("Actor id: {0}", actor.GetId()); Console.WriteLine("Actor size: " + actor.Size.X + ", " + actor.Size.Y); Console.WriteLine("Actor name: " + actor.Name); @@ -116,6 +187,8 @@ namespace MyCSharpExample color.B += 10; color.A += 10; Console.WriteLine( " Color r = " + color.R + ", g = " + color.G + ", b = " + color.B + ", a = " + color.A ); + + ViewDownCastTest(); } public void RectanglePaddingClassTest() @@ -133,7 +206,7 @@ namespace MyCSharpExample Console.WriteLine( " *************************" ); - using (Rectangle r2 = new Rectangle(2, 5, 20, 30)) + using (Rectangle r2 = new Rectangle(2, 5, 20.0f, 30.0f)) { Console.WriteLine( " Created " + r2 ); r2.Set(1,1,40,40); @@ -194,6 +267,83 @@ namespace MyCSharpExample } } + public void NavigationPropertiesTests() + { + 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); + } + } + public void OperatorTests() { Actor actor = new Actor(); @@ -374,7 +524,7 @@ namespace MyCSharpExample // 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) ); + .Add( Dali.Constants.ColorVisualProperty.MixColor, new Property.Value(Color.Red) ); spin.Background = background; background = spin.Background; @@ -400,6 +550,17 @@ namespace MyCSharpExample 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") @@ -412,6 +573,133 @@ namespace MyCSharpExample } } + public void ViewDownCastTest() + { + View container = new View(); + container.Position = new Position(-800.0f, -800.0f, 0.0f); + Stage.GetCurrent().Add(container); + + // Test downcast for native control + TextLabel myLabel = new TextLabel(); + myLabel.Name = "MyLabelName"; + myLabel.Text = "MyText"; + + Console.WriteLine("myLabel.Name = " + myLabel.Name + ", Text = " + myLabel.Text); + + container.Add(myLabel); + + Actor myLabelActor = container.FindChildByName("MyLabelName"); + if(myLabelActor) + { + TextLabel newLabel = View.DownCast(myLabelActor); + if(newLabel) + { + Console.WriteLine("Downcast to TextLabel successful: newLabel Name = " + newLabel.Name + ", Text = " + newLabel.Text); + } + else + { + Console.WriteLine("Downcast to TextLabel failed!"); + } + } + + // Test downcast for class directly inherited from View + MyView myView = new MyView(); + myView.Name = "MyViewName"; + myView.MyOwnName = "MyOwnViewName"; + myView._myCurrentValue = 5; + + Console.WriteLine("myView.Name = " + myView.Name + ", MyOwnName = " + myView.MyOwnName + ", myCurrentValue = " + myView._myCurrentValue); + + container.Add(myView); + + Actor myViewActor = container.FindChildByName("MyViewName"); + if(myViewActor) + { + MyView newView = View.DownCast(myViewActor); + if(newView) + { + Console.WriteLine("Downcast to MyView successful: newView Name = " + newView.Name + ", MyOwnName = " + newView.MyOwnName + ", myCurrentValue = " + newView._myCurrentValue); + } + else + { + Console.WriteLine("Downcast to MyView failed!"); + } + } + + // Test downcast for class directly inherited from native control + MyButton myButton = new MyButton(); + myButton.Name = "MyButtonName"; + myButton.MyOwnName = "MyOwnViewName"; + myButton.LabelText = "MyLabelText"; + myButton._myCurrentValue = 5; + + Console.WriteLine("myButton.Name = " + myButton.Name + ", MyOwnName = " + myButton.MyOwnName + ", LabelText = " + myButton.LabelText + ", myCurrentValue = " + myButton._myCurrentValue); + + container.Add(myButton); + + Actor myButtonActor = container.FindChildByName("MyButtonName"); + if(myButtonActor) + { + MyButton newButton = View.DownCast(myButtonActor); + if(newButton) + { + Console.WriteLine("Downcast to MyButton successful: newButton Name = " + newButton.Name + ", MyOwnName = " + newButton.MyOwnName + ", LabelText = " + myButton.LabelText + ", myCurrentValue = " + newButton._myCurrentValue); + } + else + { + Console.WriteLine("Downcast to MyButton failed!"); + } + } + + // Test downcast for a CustomView + Spin spin = new Spin(); + spin.Name = "SpinName"; + spin.MaxValue = 8888; + + Console.WriteLine("spin.Name = " + spin.Name + ", MaxValue = " + spin.MaxValue); + + container.Add(spin); + + Actor spinActor = container.FindChildByName("SpinName"); + if(spinActor) + { + Spin newSpin = View.DownCast(spinActor); + if(newSpin) + { + Console.WriteLine("Downcast to Spin successful: newSpin Name = " + newSpin.Name + ", MaxValue = " + newSpin.MaxValue); + } + else + { + Console.WriteLine("Downcast to Spin failed!"); + } + } + + // Test downcast for class inherited from a CustomView + MySpin mySpin = new MySpin(); + mySpin.Name = "MySpinName"; + mySpin.MyOwnName = "MyOwnSpinName"; + mySpin.MaxValue = 8888; + mySpin._myCurrentValue = 5; + + Console.WriteLine("mySpin.Name = " + mySpin.Name + ", MyOwnName = " + mySpin.MyOwnName + ", MaxValue = " + mySpin.MaxValue + ", currentValue = " + mySpin._myCurrentValue); + + container.Add(mySpin); + + Actor mySpinActor = container.FindChildByName("MySpinName"); + if(mySpinActor) + { + MySpin newSpin = View.DownCast(mySpinActor); + if(newSpin) + { + Console.WriteLine("Downcast to MySpin successful: newSpin Name = " + newSpin.Name + ", MyOwnName = " + newSpin.MyOwnName + ", MaxValue = " + newSpin.MaxValue + ", currentValue = " + newSpin._myCurrentValue); + } + else + { + Console.WriteLine("Downcast to MySpin failed!"); + } + } + } + public void MainLoop() { _application.MainLoop ();