X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=plugins%2Fdali-swig%2Fexamples%2Fdali-test.cs;h=f85a78ae735111512802479fe7ddd83d7fbf16bc;hb=refs%2Fchanges%2F09%2F120909%2F7;hp=6e106aeb665fcc2309735281a6d9326b564bd932;hpb=b00827fcac356e25c32ce504a202efa54aeee4a6;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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 6e106ae..f85a78a --- a/plugins/dali-swig/examples/dali-test.cs +++ b/plugins/dali-swig/examples/dali-test.cs @@ -39,7 +39,7 @@ namespace MyCSharpExample } set { - _myOwnName = value; + _myOwnName = value; } } } @@ -62,7 +62,7 @@ namespace MyCSharpExample } set { - _myOwnName = value; + _myOwnName = value; } } } @@ -85,190 +85,54 @@ namespace MyCSharpExample } set { - _myOwnName = value; + _myOwnName = value; } } } class Example { - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - delegate void CallbackDelegate(IntPtr appPtr); // void, void delgate - private Dali.Application _application; public Example(Dali.Application application) { _application = application; - Console.WriteLine( "InitSignal connection count = " + _application.InitSignal().GetConnectionCount() ); + Console.WriteLine("1) InitSignal connection count = " + _application.InitSignal().GetConnectionCount()); _application.Initialized += Initialize; - Console.WriteLine( "InitSignal connection count = " + _application.InitSignal().GetConnectionCount() ); + Console.WriteLine("2) InitSignal connection count = " + _application.InitSignal().GetConnectionCount()); } public void Initialize(object source, NUIApplicationInitEventArgs e) { + //1) NavigationPropertiesTests(); + //2) OperatorTests(); + //3) CustomViewPropertyTest(); - 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)), Property.AccessMode.READ_WRITE); - Size myProperty2 = new Size(0.0f, 0.0f); - handle.GetProperty(myPropertyIndex2).Get(myProperty2); - Console.WriteLine( "myProperty2 value: " + myProperty2.W + ", " + myProperty2.H ); - - 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); - - Stage stage = Stage.GetCurrent(); - stage.BackgroundColor = Color.White; - Size stageSize = stage.Size; - Console.WriteLine("Stage size: " + stageSize.W + ", " + stageSize.H); - stage.Add(actor); - - TextLabel text = new TextLabel("Hello Mono World"); - text.ParentOrigin = NDalic.ParentOriginCenter; - text.AnchorPoint = NDalic.AnchorPointCenter; - text.HorizontalAlignment = "CENTER"; - stage.Add(text); - - Console.WriteLine( "Text label text: " + text.Text ); - - Console.WriteLine( "Text label point size: " + text.PointSize ); - text.PointSize = 32.0f; - Console.WriteLine( "Text label new point size: " + text.PointSize ); + //4) + ActorHandleTest(); + //5) RectanglePaddingClassTest(); - Console.WriteLine( " *************************" ); - Size Size = new Size(100, 50); - Console.WriteLine( " Created " + Size ); - Console.WriteLine( " Size x = " + Size.W + ", y = " + Size.H ); - Size += new Size(20, 20); - Console.WriteLine( " Size x = " + Size.W + ", y = " + Size.H ); - Size.W += 10; - Size.H += 10; - Console.WriteLine( " Size width = " + Size.W + ", height = " + Size.H ); - - Console.WriteLine( " *************************" ); - Position Position = new Position(20, 100, 50); - Console.WriteLine( " Created " + Position ); - Console.WriteLine( " Position x = " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z ); - Position += new Position(20, 20, 20); - Console.WriteLine( " Position x = " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z ); - Position.X += 10; - Position.Y += 10; - Position.Z += 10; - Console.WriteLine( " Position width = " + Position.X + ", height = " + Position.Y + ", depth = " + Position.Z ); - Position parentOrigin = new Dali.Position(NDalic.ParentOriginBottomRight); - Console.WriteLine( " parentOrigin x = " + parentOrigin.X + ", y = " + parentOrigin.Y + ", z = " + parentOrigin.Z ); - - Console.WriteLine( " *************************" ); - Color color = new Color(20, 100, 50, 200); - Console.WriteLine( " Created " + color ); - Console.WriteLine( " Color R = " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A ); - color += new Color(20, 20, 20, 20); - Console.WriteLine( " Color R = " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A ); - color.R += 10; - color.G += 10; - color.B += 10; - color.A += 10; - Console.WriteLine( " Color r = " + color.R + ", g = " + color.G + ", b = " + color.B + ", a = " + color.A ); + //6) + SizePositionTest(); + //7) ViewDownCastTest(); } - public void RectanglePaddingClassTest() - { - using (Rectangle r1 = new Rectangle(2, 5, 20, 30)) - { - Console.WriteLine( " Created " + r1 ); - Console.WriteLine( " IsEmpty() = " + r1.IsEmpty() ); - Console.WriteLine( " Left = " + r1.Left() ); - Console.WriteLine( " Right = " + r1.Right() ); - Console.WriteLine( " Top = " + r1.Top() ); - Console.WriteLine( " Bottom = " + r1.Bottom() ); - Console.WriteLine( " Area = " + r1.Area() ); - } - - Console.WriteLine( " *************************" ); - - using (Rectangle r2 = new Rectangle(2, 5, 20, 30)) - { - Console.WriteLine( " Created " + r2 ); - r2.Set(1,1,40,40); - Console.WriteLine( " IsEmpty() = " + r2.IsEmpty() ); - Console.WriteLine( " Left = " + r2.Left() ); - Console.WriteLine( " Right = " + r2.Right() ); - Console.WriteLine( " Top = " + r2.Top() ); - Console.WriteLine( " Bottom = " + r2.Bottom() ); - Console.WriteLine( " Area = " + r2.Area() ); - } - - Console.WriteLine( " *************************" ); - - Rectangle r3 = new Rectangle(10, 10, 20, 20); - Rectangle r4 = new Rectangle(10, 10, 20, 20); - - if (r3 == r4) - { - Console.WriteLine("r3 == r4"); - } - else - { - Console.WriteLine("r3 != r4"); - } - - r4 = new Rectangle(12, 10, 20, 20); - - if (r3 == r4) - { - Console.WriteLine("r3 == r4"); - } - else - { - Console.WriteLine("r3 != r4"); - } - - PaddingType p1 = new PaddingType(10.5f, 10.7f, 20.8f, 20.8f); - PaddingType p2 = new PaddingType(10.5f, 10.7f, 20.8f, 20.8f); - - if (p1 == p2) - { - Console.WriteLine("p1 == p2"); - } - else - { - Console.WriteLine("p1 != p2"); - } - - p2 = new PaddingType(12.0f, 10.7f, 20.2f, 20.0f); - - if (p1 == p2) - { - Console.WriteLine("p1 == p2"); - } - else - { - Console.WriteLine("p1 != p2"); - } - } public void NavigationPropertiesTests() { + Console.WriteLine(""); + Console.WriteLine("### [1] NavigationPropertiesTests START"); + View view = new View(); View leftView, rightView, upView, downView, tmpView; @@ -342,367 +206,558 @@ namespace MyCSharpExample { 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 ) + if (actor) { - Console.WriteLine ("BaseHandle Operator true (actor) : test passed "); + Console.WriteLine("BaseHandle Operator true (actor) : test passed "); } else { - Console.WriteLine ("BaseHandle Operator true (actor): test failed "); + Console.WriteLine("BaseHandle Operator true (actor): test failed "); } - Actor parent = actor.GetParent (); + Actor parent = actor.GetParent(); - if ( parent ) + if (parent) { - Console.WriteLine ("Handle with Empty body :failed "); + Console.WriteLine("Handle with Empty body :failed "); } else { - Console.WriteLine ("Valid with Empty body :passed "); + Console.WriteLine("Valid with Empty body :passed "); } - actor.Add( differentActor ); + 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() ) + if (actor == differentActor.GetParent()) { - Console.WriteLine ("actor == differentActor.GetParent() :passed "); + Console.WriteLine("actor == differentActor.GetParent() :passed "); } else { - Console.WriteLine ("actor == differentActor.GetParent() :failed "); + Console.WriteLine("actor == differentActor.GetParent() :failed "); } - if ( differentActor == differentActor.GetParent() ) + if (differentActor == differentActor.GetParent()) { - Console.WriteLine ("differentActor == differentActor.GetParent() :failed "); + Console.WriteLine("differentActor == differentActor.GetParent() :failed "); } else { - Console.WriteLine ("differentActor == differentActor.GetParent() :passed "); + Console.WriteLine("differentActor == differentActor.GetParent() :passed "); } - if ( nullActor ) + if (nullActor) { - Console.WriteLine ("BaseHandle Operator true (nullActor) : test failed "); + Console.WriteLine("BaseHandle Operator true (nullActor) : test failed "); } else { - Console.WriteLine ("BaseHandle Operator true (nullActor): test passed "); + Console.WriteLine("BaseHandle Operator true (nullActor): test passed "); } // ! operator - if ( !actor ) + if (!actor) { - Console.WriteLine ("BaseHandle Operator !(actor) : test failed "); + Console.WriteLine("BaseHandle Operator !(actor) : test failed "); } else { - Console.WriteLine ("BaseHandle Operator !(actor): test passed "); + Console.WriteLine("BaseHandle Operator !(actor): test passed "); } - if ( !nullActor ) + if (!nullActor) { - Console.WriteLine ("BaseHandle Operator !(nullActor) : test passed "); + Console.WriteLine("BaseHandle Operator !(nullActor) : test passed "); } else { - Console.WriteLine ("BaseHandle Operator !(nullActor): test failed "); + Console.WriteLine("BaseHandle Operator !(nullActor): test failed "); } // Note: operator false only used inside & operator // test equality operator == - if ( actor == actorSame ) + if (actor == actorSame) { - Console.WriteLine ("BaseHandle Operator (actor == actorSame) : test passed"); + Console.WriteLine("BaseHandle Operator (actor == actorSame) : test passed"); } else { - Console.WriteLine ("BaseHandle Operator (actor == actorSame) : test failed"); + Console.WriteLine("BaseHandle Operator (actor == actorSame) : test failed"); } - if ( actor == differentActor ) + if (actor == differentActor) { - Console.WriteLine ("BaseHandle Operator (actor == differentActor) : test failed"); + Console.WriteLine("BaseHandle Operator (actor == differentActor) : test failed"); } else { - Console.WriteLine ("BaseHandle Operator (actor == differentActor) : test passed"); + Console.WriteLine("BaseHandle Operator (actor == differentActor) : test passed"); } - if ( actor == nullActor ) + if (actor == nullActor) { - Console.WriteLine ("BaseHandle Operator (actor == nullActor) : test failed"); + Console.WriteLine("BaseHandle Operator (actor == nullActor) : test failed"); } else { - Console.WriteLine ("BaseHandle Operator (actor == nullActor) : test passed"); + Console.WriteLine("BaseHandle Operator (actor == nullActor) : test passed"); } - if ( nullActor == nullActor ) + if (nullActor == nullActor) { - Console.WriteLine ("BaseHandle Operator (nullActor == nullActor) : test passed"); + Console.WriteLine("BaseHandle Operator (nullActor == nullActor) : test passed"); } else { - Console.WriteLine ("BaseHandle Operator (nullActor == nullActor) : test failed"); + Console.WriteLine("BaseHandle Operator (nullActor == nullActor) : test failed"); } // test || operator - if ( actor || actorSame ) + if (actor || actorSame) { - Console.WriteLine ("BaseHandle Operator (actor || actorSame) : test passed"); + Console.WriteLine("BaseHandle Operator (actor || actorSame) : test passed"); } else { - Console.WriteLine ("BaseHandle Operator (actor || actorSame) : test failed"); + Console.WriteLine("BaseHandle Operator (actor || actorSame) : test failed"); } - if ( actor || nullActor ) + if (actor || nullActor) { - Console.WriteLine ("BaseHandle Operator (actor || nullActor) : test passed"); + Console.WriteLine("BaseHandle Operator (actor || nullActor) : test passed"); } else { - Console.WriteLine ("BaseHandle Operator (actor || nullActor) : test failed"); + Console.WriteLine("BaseHandle Operator (actor || nullActor) : test failed"); } - if ( nullActor || nullActor ) + if (nullActor || nullActor) { - Console.WriteLine ("BaseHandle Operator (nullActor || nullActor) : test failed"); + Console.WriteLine("BaseHandle Operator (nullActor || nullActor) : test failed"); } else { - Console.WriteLine ("BaseHandle Operator (nullActor || nullActor) : test passed"); + Console.WriteLine("BaseHandle Operator (nullActor || nullActor) : test passed"); } // test && operator - if ( actor && actorSame ) + if (actor && actorSame) { - Console.WriteLine ("BaseHandle Operator (actor && actorSame) : test passed"); + Console.WriteLine("BaseHandle Operator (actor && actorSame) : test passed"); } else { - Console.WriteLine ("BaseHandle Operator (actor && actorSame) : test failed"); + Console.WriteLine("BaseHandle Operator (actor && actorSame) : test failed"); } - if ( actor && nullActor ) + if (actor && nullActor) { - Console.WriteLine ("BaseHandle Operator (actor && nullActor) : test failed"); + Console.WriteLine("BaseHandle Operator (actor && nullActor) : test failed"); } else { - Console.WriteLine ("BaseHandle Operator (actor && nullActor) : test passed"); + Console.WriteLine("BaseHandle Operator (actor && nullActor) : test passed"); } - if ( nullActor && nullActor ) + if (nullActor && nullActor) { - Console.WriteLine ("BaseHandle Operator (nullActor && nullActor) : test failed"); + Console.WriteLine("BaseHandle Operator (nullActor && nullActor) : test failed"); } else { - Console.WriteLine ("BaseHandle Operator (nullActor && nullActor) : test passed"); + 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) ); + 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; Vector4 backgroundColor = new Vector4(); background.Find(Dali.Constants.ColorVisualProperty.MixColor).Get(backgroundColor); - if( backgroundColor == Color.Red ) + if (backgroundColor == Color.Red) { - Console.WriteLine ("Custom View Background property : test passed"); + Console.WriteLine("Custom View Background property : test passed"); } else { - Console.WriteLine ("Custom View Background property : test failed"); + Console.WriteLine("Custom View Background property : test failed"); } // BackgroundColor property spin.BackgroundColor = Color.Yellow; - if(spin.BackgroundColor == Color.Yellow) + if (spin.BackgroundColor == Color.Yellow) { - Console.WriteLine ("Custom View BackgroundColor property : test passed"); + Console.WriteLine("Custom View BackgroundColor property : test passed"); } else { - Console.WriteLine ("Custom View BackgroundColor property : test failed"); + Console.WriteLine("Custom View BackgroundColor property : test failed"); } // BackgroundImage property spin.BackgroundImage = "background-image.jpg"; - if(spin.BackgroundImage == "background-image.jpg") + if (spin.BackgroundImage == "background-image.jpg") { - Console.WriteLine ("Custom View BackgroundImage property : test passed"); + Console.WriteLine("Custom View BackgroundImage property : test passed"); } else { - Console.WriteLine ("Custom View BackgroundImage property : test failed"); + Console.WriteLine("Custom View BackgroundImage property : test failed"); } // StyleName property spin.StyleName = "MyCustomStyle"; - if(spin.StyleName == "MyCustomStyle") + if (spin.StyleName == "MyCustomStyle") { - Console.WriteLine ("Custom View StyleName property : test passed"); + Console.WriteLine("Custom View StyleName property : test passed"); } else { - Console.WriteLine ("Custom View StyleName property : test failed"); + Console.WriteLine("Custom View StyleName property : test failed"); } + + Console.WriteLine("### [3] CustomViewPropertyTest END"); } - public void ViewDownCastTest() + + + public void ActorHandleTest() { - View container = new View(); - container.Position = new Position(-800.0f, -800.0f, 0.0f); - Stage.GetCurrent().Add(container); + Console.WriteLine(""); + Console.WriteLine("### [4] ActorHandleTest START"); - // Test downcast for native control - TextLabel myLabel = new TextLabel(); - myLabel.Name = "MyLabelName"; - myLabel.Text = "MyText"; + 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)), Property.AccessMode.READ_WRITE); + Size myProperty2 = new Size(0.0f, 0.0f); + handle.GetProperty(myPropertyIndex2).Get(myProperty2); + Console.WriteLine("myProperty2 value: " + myProperty2.W + ", " + myProperty2.H); + + 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; + Size stageSize = stage.Size; + Console.WriteLine("Stage size: " + stageSize.W + ", " + stageSize.H); + stage.Add(actor); - Console.WriteLine("myLabel.Name = " + myLabel.Name + ", Text = " + myLabel.Text); + TextLabel text = new TextLabel("Hello World"); + text.ParentOrigin = NDalic.ParentOriginCenter; + text.AnchorPoint = NDalic.AnchorPointCenter; + text.HorizontalAlignment = "CENTER"; + stage.Add(text); - container.Add(myLabel); + Console.WriteLine("Text label text: " + text.Text); - Actor myLabelActor = container.FindChildByName("MyLabelName"); - if(myLabelActor) - { - TextLabel newLabel = View.DownCast(myLabelActor); - if(newLabel) + Console.WriteLine("Text label point size: " + text.PointSize); + text.PointSize = 32.0f; + Console.WriteLine("Text label new point size: " + text.PointSize); + + Console.WriteLine("### [4] ActorHandleTest END"); + + } + + + + public void RectanglePaddingClassTest() + { + Console.WriteLine(""); + Console.WriteLine("### [5] RectanglePaddingClassTest START"); + + using (Rectangle r1 = new Rectangle(2, 5, 20, 30)) { - Console.WriteLine("Downcast to TextLabel successful: newLabel Name = " + newLabel.Name + ", Text = " + newLabel.Text); + Console.WriteLine(" Created " + r1); + Console.WriteLine(" IsEmpty() = " + r1.IsEmpty()); + Console.WriteLine(" Left = " + r1.Left()); + Console.WriteLine(" Right = " + r1.Right()); + Console.WriteLine(" Top = " + r1.Top()); + Console.WriteLine(" Bottom = " + r1.Bottom()); + Console.WriteLine(" Area = " + r1.Area()); } - else + + Console.WriteLine(" *************************"); + + using (Rectangle r2 = new Rectangle(2, 5, 20, 30)) { - Console.WriteLine("Downcast to TextLabel failed!"); + Console.WriteLine(" Created " + r2); + r2.Set(1, 1, 40, 40); + Console.WriteLine(" IsEmpty() = " + r2.IsEmpty()); + Console.WriteLine(" Left = " + r2.Left()); + Console.WriteLine(" Right = " + r2.Right()); + Console.WriteLine(" Top = " + r2.Top()); + Console.WriteLine(" Bottom = " + r2.Bottom()); + Console.WriteLine(" Area = " + r2.Area()); } - } - // Test downcast for class directly inherited from View - MyView myView = new MyView(); - myView.Name = "MyViewName"; - myView.MyOwnName = "MyOwnViewName"; - myView._myCurrentValue = 5; + Console.WriteLine(" *************************"); - Console.WriteLine("myView.Name = " + myView.Name + ", MyOwnName = " + myView.MyOwnName + ", myCurrentValue = " + myView._myCurrentValue); + Rectangle r3 = new Rectangle(10, 10, 20, 20); + Rectangle r4 = new Rectangle(10, 10, 20, 20); - container.Add(myView); + if (r3 == r4) + { + Console.WriteLine("r3 == r4"); + } + else + { + Console.WriteLine("r3 != r4"); + } + + r4 = new Rectangle(12, 10, 20, 20); - Actor myViewActor = container.FindChildByName("MyViewName"); - if(myViewActor) - { - MyView newView = View.DownCast(myViewActor); - if(newView) + if (r3 == r4) { - Console.WriteLine("Downcast to MyView successful: newView Name = " + newView.Name + ", MyOwnName = " + newView.MyOwnName + ", myCurrentValue = " + newView._myCurrentValue); + Console.WriteLine("r3 == r4"); } else { - Console.WriteLine("Downcast to MyView failed!"); + Console.WriteLine("r3 != r4"); } - } - // 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; + PaddingType p1 = new PaddingType(10.5f, 10.7f, 20.8f, 20.8f); + PaddingType p2 = new PaddingType(10.5f, 10.7f, 20.8f, 20.8f); - Console.WriteLine("myButton.Name = " + myButton.Name + ", MyOwnName = " + myButton.MyOwnName + ", LabelText = " + myButton.LabelText + ", myCurrentValue = " + myButton._myCurrentValue); + if (p1 == p2) + { + Console.WriteLine("p1 == p2"); + } + else + { + Console.WriteLine("p1 != p2"); + } - container.Add(myButton); + p2 = new PaddingType(12.0f, 10.7f, 20.2f, 20.0f); - Actor myButtonActor = container.FindChildByName("MyButtonName"); - if(myButtonActor) - { - MyButton newButton = View.DownCast(myButtonActor); - if(newButton) + if (p1 == p2) { - Console.WriteLine("Downcast to MyButton successful: newButton Name = " + newButton.Name + ", MyOwnName = " + newButton.MyOwnName + ", LabelText = " + myButton.LabelText + ", myCurrentValue = " + newButton._myCurrentValue); + Console.WriteLine("p1 == p2"); } else { - Console.WriteLine("Downcast to MyButton failed!"); + Console.WriteLine("p1 != p2"); + } + Console.WriteLine("### [5] RectanglePaddingClassTest END"); + + } + + + public void SizePositionTest() + { + Console.WriteLine(""); + Console.WriteLine("### [6] SizePositionTest START"); + + Size Size = new Size(100, 50); + Console.WriteLine(" Created " + Size); + Console.WriteLine(" Size x = " + Size.W + ", y = " + Size.H); + Size += new Size(20, 20); + Console.WriteLine(" Size x = " + Size.W + ", y = " + Size.H); + Size.W += 10; + Size.H += 10; + Console.WriteLine(" Size width = " + Size.W + ", height = " + Size.H); + + Console.WriteLine(" *************************"); + Position Position = new Position(20, 100, 50); + Console.WriteLine(" Created " + Position); + Console.WriteLine(" Position x = " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z); + Position += new Position(20, 20, 20); + Console.WriteLine(" Position x = " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z); + Position.X += 10; + Position.Y += 10; + Position.Z += 10; + Console.WriteLine(" Position width = " + Position.X + ", height = " + Position.Y + ", depth = " + Position.Z); + Position parentOrigin = new Dali.Position(NDalic.ParentOriginBottomRight); + Console.WriteLine(" parentOrigin x = " + parentOrigin.X + ", y = " + parentOrigin.Y + ", z = " + parentOrigin.Z); + + Console.WriteLine(" *************************"); + Color color = new Color(20, 100, 50, 200); + Console.WriteLine(" Created " + color); + Console.WriteLine(" Color R = " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A); + color += new Color(20, 20, 20, 20); + Console.WriteLine(" Color R = " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A); + color.R += 10; + color.G += 10; + color.B += 10; + color.A += 10; + Console.WriteLine(" Color r = " + color.R + ", g = " + color.G + ", b = " + color.B + ", a = " + color.A); + + Console.WriteLine("### [6] SizePositionTest END"); + } + + + public void ViewDownCastTest() + { + Console.WriteLine(""); + Console.WriteLine("### [7] ViewDownCastTest START"); + + 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 a CustomView - Spin spin = new Spin(); - spin.Name = "SpinName"; - spin.MaxValue = 8888; + // Test downcast for class directly inherited from View + MyView myView = new MyView(); + myView.Name = "MyViewName"; + myView.MyOwnName = "MyOwnViewName"; + myView._myCurrentValue = 5; - Console.WriteLine("spin.Name = " + spin.Name + ", MaxValue = " + spin.MaxValue); + Console.WriteLine("myView.Name = " + myView.Name + ", MyOwnName = " + myView.MyOwnName + ", myCurrentValue = " + myView._myCurrentValue); - container.Add(spin); + container.Add(myView); - Actor spinActor = container.FindChildByName("SpinName"); - if(spinActor) - { - Spin newSpin = View.DownCast(spinActor); - if(newSpin) + Actor myViewActor = container.FindChildByName("MyViewName"); + if (myViewActor) { - Console.WriteLine("Downcast to Spin successful: newSpin Name = " + newSpin.Name + ", MaxValue = " + newSpin.MaxValue); + 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!"); + } } - else + + // 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) { - Console.WriteLine("Downcast to Spin failed!"); + 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 class inherited from a CustomView - MySpin mySpin = new MySpin(); - mySpin.Name = "MySpinName"; - mySpin.MyOwnName = "MyOwnSpinName"; - mySpin.MaxValue = 8888; - mySpin._myCurrentValue = 5; + // Test downcast for a CustomView + Spin spin = new Spin(); + spin.Name = "SpinName"; + spin.MaxValue = 8888; - Console.WriteLine("mySpin.Name = " + mySpin.Name + ", MyOwnName = " + mySpin.MyOwnName + ", MaxValue = " + mySpin.MaxValue + ", currentValue = " + mySpin._myCurrentValue); + Console.WriteLine("spin.Name = " + spin.Name + ", MaxValue = " + spin.MaxValue); - container.Add(mySpin); + container.Add(spin); - Actor mySpinActor = container.FindChildByName("MySpinName"); - if(mySpinActor) - { - MySpin newSpin = View.DownCast(mySpinActor); - if(newSpin) + Actor spinActor = container.FindChildByName("SpinName"); + if (spinActor) { - Console.WriteLine("Downcast to MySpin successful: newSpin Name = " + newSpin.Name + ", MyOwnName = " + newSpin.MyOwnName + ", MaxValue = " + newSpin.MaxValue + ", currentValue = " + newSpin._myCurrentValue); + 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!"); + } } - else + + // 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) { - Console.WriteLine("Downcast to MySpin failed!"); + 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!"); + } } - } + + Console.WriteLine("### [7] ViewDownCastTest END"); } public void MainLoop() { - _application.MainLoop (); + _application.MainLoop(); } /// @@ -711,10 +766,12 @@ namespace MyCSharpExample [STAThread] static void Main(string[] args) { - Console.WriteLine ("Hello Mono World"); + Console.WriteLine("Hello World"); Example example = new Example(Application.NewApplication()); - example.MainLoop (); + example.MainLoop(); } } } + +