1.[NUI 276] c# nui visual high level class refactorying.
[platform/core/csapi/nui.git] / NUISamples / NUISamples / NUISamples.TizenTV / examples / dali-test.cs
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 using System;
19 using System.Runtime.InteropServices;
20 using Tizen.NUI;
21 using Tizen.NUI.UIComponents;
22 using Tizen.NUI.Constants;
23
24 namespace DaliTest
25 {
26     class MyView : View
27     {
28         private string _myOwnName;
29         public int _myCurrentValue;
30
31         public MyView()
32         {
33             _myCurrentValue = 0;
34         }
35
36         public string MyOwnName
37         {
38             get
39             {
40                 return _myOwnName;
41             }
42             set
43             {
44               _myOwnName = value;
45             }
46         }
47     }
48
49     class MyButton : PushButton
50     {
51         private string _myOwnName;
52         public int _myCurrentValue;
53
54         public MyButton()
55         {
56             _myCurrentValue = 0;
57         }
58
59         public string MyOwnName
60         {
61             get
62             {
63                 return _myOwnName;
64             }
65             set
66             {
67               _myOwnName = value;
68             }
69         }
70     }
71
72     class MySpin : Spin
73     {
74         private string _myOwnName;
75         public int _myCurrentValue;
76
77         public MySpin()
78         {
79             _myCurrentValue = 0;
80         }
81
82         public string MyOwnName
83         {
84             get
85             {
86                 return _myOwnName;
87             }
88             set
89             {
90               _myOwnName = value;
91             }
92         }
93     }
94
95     class Example : NUIApplication
96     {
97         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
98         delegate void CallbackDelegate(IntPtr appPtr); // void, void delgate
99
100         public Example() : base()
101         {
102         }
103
104         public Example(string stylesheet) : base(stylesheet)
105         {
106         }
107
108         public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
109         {
110         }
111
112         protected override void OnCreate()
113         {
114             base.OnCreate();
115             Initialize();
116         }
117
118         public void Initialize()
119         {
120             DowncastTest();
121
122             NavigationPropertiesTests();
123
124             OperatorTests();
125
126             CustomViewPropertyTest();
127
128             Handle handle = new Handle();
129             int myPropertyIndex = handle.RegisterProperty("myProperty", new PropertyValue(10.0f), PropertyAccessMode.ReadWrite);
130             float myProperty = 0.0f;
131             handle.GetProperty(myPropertyIndex).Get(ref myProperty);
132             Tizen.Log.Debug("NUI",  "myProperty value: " + myProperty );
133
134             int myPropertyIndex2 = handle.RegisterProperty("myProperty2", new PropertyValue(new Size(5.0f, 5.0f, 0.0f)), PropertyAccessMode.ReadWrite);
135             Size myProperty2 = new Size(0.0f, 0.0f, 0.0f);
136             handle.GetProperty(myPropertyIndex2).Get(myProperty2);
137             Tizen.Log.Debug("NUI",  "myProperty2 value: " + myProperty2.Width + ", " + myProperty2.Height );
138
139             Actor actor = new Actor();
140             actor.Size = new Size(200.0f, 200.0f, 0.0f);
141             actor.Name = "MyActor";
142             //actor.MixColor = new Color(1.0f, 0.0f, 1.0f, 0.8f);
143             Tizen.Log.Debug("NUI", "Actor size: " + actor.Size.Width + ", " + actor.Size.Height);
144             Tizen.Log.Debug("NUI", "Actor name: " + actor.Name);
145
146             Stage stage = Stage.Instance;
147             stage.BackgroundColor = Color.White;
148             Size stageSize = new Size(stage.Size.Width, stage.Size.Height, 0.0f);
149             Tizen.Log.Debug("NUI", "Stage size: " + stageSize.Width + ", " + stageSize.Height);
150             stage.GetDefaultLayer().Add(actor);
151
152             TextLabel text = new TextLabel("Hello Mono World");
153             text.ParentOrigin = ParentOrigin.Center;
154             text.AnchorPoint = AnchorPoint.Center;
155             text.HorizontalAlignment = HorizontalAlignment.Center;
156             stage.GetDefaultLayer().Add(text);
157
158             Tizen.Log.Debug("NUI",  "Text label text:  " + text.Text );
159
160             Tizen.Log.Debug("NUI",  "Text label point size:  " + text.PointSize );
161             text.PointSize = 32.0f;
162             Tizen.Log.Debug("NUI",  "Text label new point size:  " + text.PointSize );
163
164             RectanglePaddingClassTest();
165
166             Tizen.Log.Debug("NUI",  " *************************" );
167             Size Size = new Size(100, 50, 0);
168             Tizen.Log.Debug("NUI",  "    Created " + Size );
169             Tizen.Log.Debug("NUI",  "    Size x =  " + Size.Width + ", y = " + Size.Height );
170             Size += new Size(20, 20, 0);
171             Tizen.Log.Debug("NUI",  "    Size x =  " + Size.Width + ", y = " + Size.Height );
172             Size.Width += 10;
173             Size.Height += 10;
174             Tizen.Log.Debug("NUI",  "    Size width =  " + Size.Width + ", height = " + Size.Height );
175
176             Tizen.Log.Debug("NUI",  " *************************" );
177             Position Position = new Position(20, 100, 50);
178             Tizen.Log.Debug("NUI",  "    Created " + Position );
179             Tizen.Log.Debug("NUI",  "    Position x =  " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z );
180             Position += new Position(20, 20, 20);
181             Tizen.Log.Debug("NUI",  "    Position x =  " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z );
182             Position.X += 10;
183             Position.Y += 10;
184             Position.Z += 10;
185             Tizen.Log.Debug("NUI",  "    Position width =  " + Position.X + ", height = " + Position.Y + ", depth = " + Position.Z );
186
187             Tizen.Log.Debug("NUI",  " *************************" );
188             Color color = new Color(20, 100, 50, 200);
189             Tizen.Log.Debug("NUI",  "    Created " + color );
190             Tizen.Log.Debug("NUI",  "    Color R =  " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A );
191             color += new Color(20, 20, 20, 20);
192             Tizen.Log.Debug("NUI",  "    Color R =  " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A );
193             color.R += 10;
194             color.G += 10;
195             color.B += 10;
196             color.A += 10;
197             Tizen.Log.Debug("NUI",  "    Color r =  " + color.R + ", g = " + color.G + ", b = " + color.B + ", a = " + color.A );
198
199             ViewDownCastTest();
200         }
201
202         public void RectanglePaddingClassTest()
203         {
204             using (Rectangle r1 = new Rectangle(2, 5, 20, 30))
205             {
206                 Tizen.Log.Debug("NUI",  "    Created " + r1 );
207                 Tizen.Log.Debug("NUI",  "    IsEmpty() =  " + r1.IsEmpty() );
208                 Tizen.Log.Debug("NUI",  "    Left =  " + r1.Left() );
209                 Tizen.Log.Debug("NUI",  "    Right =  " + r1.Right() );
210                 Tizen.Log.Debug("NUI",  "    Top  = " + r1.Top() );
211                 Tizen.Log.Debug("NUI",  "    Bottom  = " + r1.Bottom() );
212                 Tizen.Log.Debug("NUI",  "    Area  = " + r1.Area() );
213             }
214
215             Tizen.Log.Debug("NUI",  " *************************" );
216
217             using (Rectangle r2 = new Rectangle(2, 5, 20, 30))
218             {
219                 Tizen.Log.Debug("NUI",  "    Created " + r2 );
220                 r2.Set(1,1,40,40);
221                 Tizen.Log.Debug("NUI",  "    IsEmpty() =  " + r2.IsEmpty() );
222                 Tizen.Log.Debug("NUI",  "    Left =  " + r2.Left() );
223                 Tizen.Log.Debug("NUI",  "    Right =  " + r2.Right() );
224                 Tizen.Log.Debug("NUI",  "    Top  = " + r2.Top() );
225                 Tizen.Log.Debug("NUI",  "    Bottom  = " + r2.Bottom() );
226                 Tizen.Log.Debug("NUI",  "    Area  = " + r2.Area() );
227             }
228
229             Tizen.Log.Debug("NUI",  " *************************" );
230
231             Rectangle r3 = new Rectangle(10, 10, 20, 20);
232             Rectangle r4 = new Rectangle(10, 10, 20, 20);
233
234             if (r3 == r4)
235             {
236                 Tizen.Log.Debug("NUI", "r3 == r4");
237             }
238             else
239             {
240                 Tizen.Log.Debug("NUI", "r3 != r4");
241             }
242
243             r4 = new Rectangle(12, 10, 20, 20);
244
245             if (r3 == r4)
246             {
247                 Tizen.Log.Debug("NUI", "r3 == r4");
248             }
249             else
250             {
251                 Tizen.Log.Debug("NUI", "r3 != r4");
252             }
253
254             PaddingType p1 = new PaddingType(10.5f, 10.7f, 20.8f, 20.8f);
255             PaddingType p2 = new PaddingType(10.5f, 10.7f, 20.8f, 20.8f);
256
257             if (p1 == p2)
258             {
259                 Tizen.Log.Debug("NUI", "p1 == p2");
260             }
261             else
262             {
263                 Tizen.Log.Debug("NUI", "p1 != p2");
264             }
265
266             p2 = new PaddingType(12.0f, 10.7f, 20.2f, 20.0f);
267
268             if (p1 == p2)
269             {
270                 Tizen.Log.Debug("NUI", "p1 == p2");
271             }
272             else
273             {
274                 Tizen.Log.Debug("NUI", "p1 != p2");
275             }
276         }
277
278         public void NavigationPropertiesTests()
279         {
280             View view = new View();
281             View leftView, rightView, upView, downView, tmpView;
282
283             leftView = new View();
284             leftView.Name = "leftView";
285             rightView = new View();
286             rightView.Name = "rightView";
287             upView = new View();
288             upView.Name = "upView";
289             downView = new View();
290             downView.Name = "downView";
291
292             Stage.Instance.GetDefaultLayer().Add(leftView);
293             Stage.Instance.GetDefaultLayer().Add(rightView);
294             Stage.Instance.GetDefaultLayer().Add(upView);
295             Stage.Instance.GetDefaultLayer().Add(downView);
296
297             view.LeftFocusableView = leftView;
298             tmpView = view.LeftFocusableView;
299             if (string.Compare(tmpView.Name, "leftView") == 0)
300             {
301                 Tizen.Log.Debug("NUI", "Passed: LeftFocusedView = " + tmpView.Name);
302             }
303             else
304             {
305                 Tizen.Log.Debug("NUI", "Failed: LeftFocusedView = " + tmpView.Name);
306             }
307
308             view.RightFocusableView = rightView;
309             tmpView = view.RightFocusableView;
310             if (string.Compare(tmpView.Name, "rightView") == 0)
311             {
312                 Tizen.Log.Debug("NUI", "Passed: RightFocusedView = " + tmpView.Name);
313             }
314             else
315             {
316                 Tizen.Log.Debug("NUI", "Failed: RightFocusedView = " + tmpView.Name);
317             }
318
319             Stage.Instance.GetDefaultLayer().Add(view);
320
321             view.UpFocusableView = upView;
322             tmpView = view.UpFocusableView;
323             if (string.Compare(tmpView.Name, "upView") == 0)
324             {
325                 Tizen.Log.Debug("NUI", "Passed: UpFocusedView = " + tmpView.Name);
326             }
327             else
328             {
329                 Tizen.Log.Debug("NUI", "Failed: UpFocusedView = " + tmpView.Name);
330             }
331
332             view.DownFocusableView = downView;
333             tmpView = view.DownFocusableView;
334             if (string.Compare(tmpView.Name, "downView") == 0)
335             {
336                 Tizen.Log.Debug("NUI", "Passed: DownFocusedView = " + tmpView.Name);
337             }
338             else
339             {
340                 Tizen.Log.Debug("NUI", "Failed: DownFocusedView = " + tmpView.Name);
341             }
342
343             Stage.Instance.GetDefaultLayer().Remove(leftView);
344             tmpView = view.LeftFocusableView;
345             if (!tmpView)
346             {
347                 Tizen.Log.Debug("NUI", "Passed: NULL LeftFocusedView");
348             }
349             else
350             {
351                 Tizen.Log.Debug("NUI", "Failed: LeftFocusedView = " + tmpView.Name);
352             }
353         }
354
355         public void OperatorTests()
356         {
357             Actor actor = new Actor();
358             Actor differentActor = new Actor();
359             Actor actorSame = actor;
360             Actor nullActor = null;
361
362             // test the true operator
363             if ( actor )
364             {
365                 Tizen.Log.Debug("NUI", "BaseHandle Operator true (actor) : test passed ");
366             }
367             else
368             {
369                 Tizen.Log.Debug("NUI", "BaseHandle Operator true (actor): test failed ");
370             }
371
372             Actor parent = actor.Parent;
373
374             if ( parent )
375             {
376                 Tizen.Log.Debug("NUI", "Handle with Empty body  :failed ");
377             }
378             else
379             {
380                 Tizen.Log.Debug("NUI", "Valid with Empty body  :passed ");
381             }
382
383             actor.Add( differentActor );
384
385             // here we test two different C# objects, which on the native side have the same body/ ref-object
386             if ( actor == differentActor.Parent )
387             {
388                 Tizen.Log.Debug("NUI", "actor == differentActor.GetParent() :passed ");
389             }
390             else
391             {
392                 Tizen.Log.Debug("NUI", "actor == differentActor.GetParent() :failed ");
393             }
394
395             if ( differentActor == differentActor.Parent )
396             {
397                 Tizen.Log.Debug("NUI", "differentActor == differentActor.GetParent() :failed ");
398             }
399             else
400             {
401                 Tizen.Log.Debug("NUI", "differentActor == differentActor.GetParent() :passed ");
402             }
403
404             if ( nullActor )
405             {
406                 Tizen.Log.Debug("NUI", "BaseHandle Operator true (nullActor) : test failed ");
407             }
408             else
409             {
410                 Tizen.Log.Debug("NUI", "BaseHandle Operator true (nullActor): test passed ");
411             }
412
413             // ! operator
414             if ( !actor )
415             {
416                 Tizen.Log.Debug("NUI", "BaseHandle Operator !(actor) : test failed ");
417             }
418             else
419             {
420                 Tizen.Log.Debug("NUI", "BaseHandle Operator !(actor): test passed ");
421             }
422
423             if ( !nullActor )
424             {
425                 Tizen.Log.Debug("NUI", "BaseHandle Operator !(nullActor) : test passed ");
426             }
427             else
428             {
429                 Tizen.Log.Debug("NUI", "BaseHandle Operator !(nullActor): test failed ");
430             }
431
432             // Note: operator false only used inside & operator
433             // test equality operator ==
434             if ( actor == actorSame )
435             {
436                 Tizen.Log.Debug("NUI", "BaseHandle Operator  (actor == actorSame) : test passed");
437             }
438             else
439             {
440                 Tizen.Log.Debug("NUI", "BaseHandle Operator  (actor == actorSame) : test failed");
441             }
442
443             if ( actor == differentActor )
444             {
445                 Tizen.Log.Debug("NUI", "BaseHandle Operator (actor == differentActor) : test failed");
446             }
447             else
448             {
449                 Tizen.Log.Debug("NUI", "BaseHandle Operator (actor == differentActor) : test passed");
450             }
451
452             if ( actor == nullActor )
453             {
454                 Tizen.Log.Debug("NUI", "BaseHandle Operator (actor == nullActor) : test failed");
455             }
456             else
457             {
458                 Tizen.Log.Debug("NUI", "BaseHandle Operator (actor == nullActor) : test passed");
459             }
460
461             if ( nullActor == nullActor )
462             {
463                 Tizen.Log.Debug("NUI", "BaseHandle Operator (nullActor == nullActor) : test passed");
464             }
465             else
466             {
467                 Tizen.Log.Debug("NUI", "BaseHandle Operator (nullActor == nullActor) : test failed");
468             }
469
470             // test || operator
471             if ( actor || actorSame )
472             {
473                 Tizen.Log.Debug("NUI", "BaseHandle Operator (actor || actorSame) : test passed");
474             }
475             else
476             {
477                 Tizen.Log.Debug("NUI", "BaseHandle Operator (actor || actorSame) : test failed");
478             }
479
480             if ( actor || nullActor )
481             {
482                 Tizen.Log.Debug("NUI", "BaseHandle Operator (actor || nullActor) : test passed");
483             }
484             else
485             {
486                 Tizen.Log.Debug("NUI", "BaseHandle Operator (actor || nullActor) : test failed");
487             }
488
489             if ( nullActor || nullActor )
490             {
491                 Tizen.Log.Debug("NUI", "BaseHandle Operator (nullActor || nullActor) : test failed");
492             }
493             else
494             {
495                 Tizen.Log.Debug("NUI", "BaseHandle Operator (nullActor || nullActor) : test passed");
496             }
497
498             // test && operator
499             if ( actor && actorSame )
500             {
501                 Tizen.Log.Debug("NUI", "BaseHandle Operator (actor && actorSame) : test passed");
502             }
503             else
504             {
505                 Tizen.Log.Debug("NUI", "BaseHandle Operator (actor && actorSame) : test failed");
506             }
507
508             if ( actor && nullActor )
509             {
510                 Tizen.Log.Debug("NUI", "BaseHandle Operator (actor && nullActor) : test failed");
511             }
512             else
513             {
514                 Tizen.Log.Debug("NUI", "BaseHandle Operator (actor && nullActor) : test passed");
515             }
516
517             if ( nullActor && nullActor )
518             {
519                 Tizen.Log.Debug("NUI", "BaseHandle Operator (nullActor && nullActor) : test failed");
520             }
521             else
522             {
523                 Tizen.Log.Debug("NUI", "BaseHandle Operator (nullActor && nullActor) : test passed");
524             }
525         }
526
527         public void CustomViewPropertyTest()
528         {
529             // Create a Spin control
530             Spin spin = new Spin();
531
532             // Background property
533             PropertyMap background = new PropertyMap();
534             background.Add( Visual.Property.Type, new PropertyValue((int)Visual.Type.Color) )
535                       .Add( ColorVisualProperty.MixColor, new PropertyValue(Color.Red) );
536             spin.Background = background;
537
538             background = spin.Background;
539             Color backgroundColor = new Color();
540             background.Find(ColorVisualProperty.MixColor).Get(backgroundColor);
541             if( backgroundColor == Color.Red )
542             {
543                 Tizen.Log.Debug("NUI", "Custom View Background property : test passed");
544             }
545             else
546             {
547                 Tizen.Log.Debug("NUI", "Custom View Background property : test failed");
548             }
549
550             // BackgroundColor property
551             spin.BackgroundColor = Color.Yellow;
552             if(spin.BackgroundColor == Color.Yellow)
553             {
554                 Tizen.Log.Debug("NUI", "Custom View BackgroundColor property : test passed");
555             }
556             else
557             {
558                 Tizen.Log.Debug("NUI", "Custom View BackgroundColor property : test failed");
559             }
560
561             // BackgroundImage property
562             spin.BackgroundImage = "background-image.jpg";
563             if(spin.BackgroundImage == "background-image.jpg")
564             {
565                 Tizen.Log.Debug("NUI", "Custom View BackgroundImage property : test passed");
566             }
567             else
568             {
569                 Tizen.Log.Debug("NUI", "Custom View BackgroundImage property : test failed");
570             }
571
572             // StyleName property
573             spin.StyleName = "MyCustomStyle";
574             if(spin.StyleName == "MyCustomStyle")
575             {
576                 Tizen.Log.Debug("NUI", "Custom View StyleName property : test passed");
577             }
578             else
579             {
580                 Tizen.Log.Debug("NUI", "Custom View StyleName property : test failed");
581             }
582         }
583
584         public void ViewDownCastTest()
585         {
586           View container = new View();
587           container.Position = new Position(-800.0f, -800.0f, 0.0f);
588           Stage.Instance.GetDefaultLayer().Add(container);
589
590           // Test downcast for native control
591           TextLabel myLabel = new TextLabel();
592           myLabel.Name = "MyLabelName";
593           myLabel.Text = "MyText";
594
595           Tizen.Log.Debug("NUI", "myLabel.Name = " + myLabel.Name + ", Text = " + myLabel.Text);
596
597           container.Add(myLabel);
598
599           Actor myLabelActor  = container.FindChildByName("MyLabelName");
600           if(myLabelActor)
601           {
602             TextLabel newLabel = View.DownCast<TextLabel>(myLabelActor);
603             if(newLabel)
604             {
605               Tizen.Log.Debug("NUI", "Downcast to TextLabel successful: newLabel Name = " + newLabel.Name + ", Text = " + newLabel.Text);
606             }
607             else
608             {
609               Tizen.Log.Debug("NUI", "Downcast to TextLabel failed!");
610             }
611           }
612
613           // Test downcast for class directly inherited from View
614           MyView myView = new MyView();
615           myView.Name = "MyViewName";
616           myView.MyOwnName = "MyOwnViewName";
617           myView._myCurrentValue = 5;
618
619           Tizen.Log.Debug("NUI", "myView.Name = " + myView.Name + ", MyOwnName = " + myView.MyOwnName + ", myCurrentValue = " + myView._myCurrentValue);
620
621           container.Add(myView);
622
623           Actor myViewActor  = container.FindChildByName("MyViewName");
624           if(myViewActor)
625           {
626             MyView newView = View.DownCast<MyView>(myViewActor);
627             if(newView)
628             {
629               Tizen.Log.Debug("NUI", "Downcast to MyView successful: newView Name = " + newView.Name + ", MyOwnName = " + newView.MyOwnName + ", myCurrentValue = " + newView._myCurrentValue);
630             }
631             else
632             {
633               Tizen.Log.Debug("NUI", "Downcast to MyView failed!");
634             }
635           }
636
637           // Test downcast for class directly inherited from native control
638           MyButton myButton = new MyButton();
639           myButton.Name = "MyButtonName";
640           myButton.MyOwnName = "MyOwnViewName";
641           myButton.LabelText = "MyLabelText";
642           myButton._myCurrentValue = 5;
643
644           Tizen.Log.Debug("NUI", "myButton.Name = " + myButton.Name + ", MyOwnName = " + myButton.MyOwnName + ", LabelText = " + myButton.LabelText + ", myCurrentValue = " + myButton._myCurrentValue);
645
646           container.Add(myButton);
647
648           Actor myButtonActor  = container.FindChildByName("MyButtonName");
649           if(myButtonActor)
650           {
651             MyButton newButton = View.DownCast<MyButton>(myButtonActor);
652             if(newButton)
653             {
654               Tizen.Log.Debug("NUI", "Downcast to MyButton successful: newButton Name = " + newButton.Name + ", MyOwnName = " + newButton.MyOwnName + ", LabelText = " + myButton.LabelText + ", myCurrentValue = " + newButton._myCurrentValue);
655             }
656             else
657             {
658               Tizen.Log.Debug("NUI", "Downcast to MyButton failed!");
659             }
660           }
661
662           // Test downcast for a CustomView
663           Spin spin = new Spin();
664           spin.Name = "SpinName";
665           spin.MaxValue = 8888;
666
667           Tizen.Log.Debug("NUI", "spin.Name = " + spin.Name + ", MaxValue = " + spin.MaxValue);
668
669           container.Add(spin);
670
671           Actor spinActor  = container.FindChildByName("SpinName");
672           if(spinActor)
673           {
674             Spin newSpin = View.DownCast<Spin>(spinActor);
675             if(newSpin)
676             {
677               Tizen.Log.Debug("NUI", "Downcast to Spin successful: newSpin Name = " + newSpin.Name + ", MaxValue = " + newSpin.MaxValue);
678             }
679             else
680             {
681               Tizen.Log.Debug("NUI", "Downcast to Spin failed!");
682             }
683           }
684
685           // Test downcast for class inherited from a CustomView
686           MySpin mySpin = new MySpin();
687           mySpin.Name = "MySpinName";
688           mySpin.MyOwnName = "MyOwnSpinName";
689           mySpin.MaxValue = 8888;
690           mySpin._myCurrentValue = 5;
691
692           Tizen.Log.Debug("NUI", "mySpin.Name = " + mySpin.Name + ", MyOwnName = " + mySpin.MyOwnName + ", MaxValue = " + mySpin.MaxValue + ", currentValue = " + mySpin._myCurrentValue);
693
694           container.Add(mySpin);
695
696           Actor mySpinActor  = container.FindChildByName("MySpinName");
697           if(mySpinActor)
698           {
699             MySpin newSpin = View.DownCast<MySpin>(mySpinActor);
700             if(newSpin)
701             {
702               Tizen.Log.Debug("NUI", "Downcast to MySpin successful: newSpin Name = " + newSpin.Name + ", MyOwnName = " + newSpin.MyOwnName + ", MaxValue = " + newSpin.MaxValue + ", currentValue = " + newSpin._myCurrentValue);
703             }
704             else
705             {
706               Tizen.Log.Debug("NUI", "Downcast to MySpin failed!");
707             }
708           }
709         }
710
711
712
713         public void DowncastTest()
714         {
715             //Create a View as a child of parent View, get it use parent.GetChildAt(i), then DownCast to View handle, but call BackgroundColor property will crash.
716             View parent = new View();
717             View[] childs = new View[5];
718
719             for (int i = 0; i < 5; i++)
720             {
721                 childs[i] = new View();
722                 childs[i].Name = "child_view_" + i;
723                 childs[i].BackgroundColor = Color.Red;
724                 parent.Add(childs[i]);
725             }
726
727             for (uint i = 0; i < parent.GetChildCount(); i++)
728             {
729                 Actor child = parent.GetChildAt(i);
730                 View childView = View.DownCast<View>(child);
731                 if (childView)
732                 {
733                     Tizen.Log.Debug("NUI", "Type[" + childView.GetTypeName() + "] BGColor[" + childView.BackgroundColor.R + "]" + " Name[" + childView.Name + "]");
734                 }
735             }
736
737             PushButton button = new PushButton();
738             button.LabelText = "ButtonTest!";
739             button.BackgroundColor = Color.White;
740             View parentView = new View();
741             parentView.Add(button);
742             PushButton view = PushButton.DownCast(parentView.GetChildAt(0));
743             if (view)
744             {
745                 Tizen.Log.Debug("NUI", "NUI view GetTypeName= " + view.GetTypeName());
746                 Tizen.Log.Debug("NUI", "NUI view LabelText= " + view.LabelText);
747                 Tizen.Log.Debug("NUI", "NUI view color= " +  view.BackgroundColor.R);
748             }
749         }
750
751
752
753         /// <summary>
754         /// The main entry point for the application.
755         /// </summary>
756         [STAThread]
757         static void _Main(string[] args)
758         {
759             Tizen.Log.Debug("NUI", "Hello Mono World");
760
761             Example example = new Example();
762             example.Run(args);
763         }
764     }
765 }