Fixed resource package install error
[platform/core/uifw/dali-toolkit.git] / plugins / dali-sharp / 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 Dali;
21
22 namespace MyCSharpExample
23 {
24     class MyView : View
25     {
26         private string _myOwnName;
27         public int _myCurrentValue;
28
29         public MyView()
30         {
31             _myCurrentValue = 0;
32         }
33
34         public string MyOwnName
35         {
36             get
37             {
38                 return _myOwnName;
39             }
40             set
41             {
42                 _myOwnName = value;
43             }
44         }
45     }
46
47     class MyButton : PushButton
48     {
49         private string _myOwnName;
50         public int _myCurrentValue;
51
52         public MyButton()
53         {
54             _myCurrentValue = 0;
55         }
56
57         public string MyOwnName
58         {
59             get
60             {
61                 return _myOwnName;
62             }
63             set
64             {
65                 _myOwnName = value;
66             }
67         }
68     }
69
70     class MySpin : Spin
71     {
72         private string _myOwnName;
73         public int _myCurrentValue;
74
75         public MySpin()
76         {
77             _myCurrentValue = 0;
78         }
79
80         public string MyOwnName
81         {
82             get
83             {
84                 return _myOwnName;
85             }
86             set
87             {
88                 _myOwnName = value;
89             }
90         }
91     }
92
93     class Example
94     {
95         private Dali.Application _application;
96
97         public Example(Dali.Application application)
98         {
99             _application = application;
100             Console.WriteLine("1) InitSignal connection count = " + _application.InitSignal().GetConnectionCount());
101
102             _application.Initialized += Initialize;
103             Console.WriteLine("2) InitSignal connection count = " + _application.InitSignal().GetConnectionCount());
104         }
105
106         public void Initialize(object source, NUIApplicationInitEventArgs e)
107         {
108
109             //1)
110             NavigationPropertiesTests();
111
112             //2)
113             OperatorTests();
114
115             //3)
116             CustomViewPropertyTest();
117
118             //4)
119             ActorHandleTest();
120
121             //5)
122             RectanglePaddingClassTest();
123
124             //6)
125             SizePositionTest();
126
127             //7)
128             ViewDownCastTest();
129
130         }
131
132
133         public void NavigationPropertiesTests()
134         {
135             Console.WriteLine("");
136             Console.WriteLine("### [1] NavigationPropertiesTests START");
137
138             View view = new View();
139             View leftView, rightView, upView, downView, tmpView;
140
141             leftView = new View();
142             leftView.Name = "leftView";
143             rightView = new View();
144             rightView.Name = "rightView";
145             upView = new View();
146             upView.Name = "upView";
147             downView = new View();
148             downView.Name = "downView";
149
150             Stage.Instance.Add(leftView);
151             Stage.Instance.Add(rightView);
152             Stage.Instance.Add(upView);
153             Stage.Instance.Add(downView);
154
155             view.LeftFocusableView = leftView;
156             tmpView = view.LeftFocusableView;
157             if (string.Compare(tmpView.Name, "leftView") == 0)
158             {
159                 Console.WriteLine("Passed: LeftFocusedView = " + tmpView.Name);
160             }
161             else
162             {
163                 Console.WriteLine("Failed: LeftFocusedView = " + tmpView.Name);
164             }
165
166             view.RightFocusableView = rightView;
167             tmpView = view.RightFocusableView;
168             if (string.Compare(tmpView.Name, "rightView") == 0)
169             {
170                 Console.WriteLine("Passed: RightFocusedView = " + tmpView.Name);
171             }
172             else
173             {
174                 Console.WriteLine("Failed: RightFocusedView = " + tmpView.Name);
175             }
176
177             Stage.Instance.Add(view);
178
179             view.UpFocusableView = upView;
180             tmpView = view.UpFocusableView;
181             if (string.Compare(tmpView.Name, "upView") == 0)
182             {
183                 Console.WriteLine("Passed: UpFocusedView = " + tmpView.Name);
184             }
185             else
186             {
187                 Console.WriteLine("Failed: UpFocusedView = " + tmpView.Name);
188             }
189
190             view.DownFocusableView = downView;
191             tmpView = view.DownFocusableView;
192             if (string.Compare(tmpView.Name, "downView") == 0)
193             {
194                 Console.WriteLine("Passed: DownFocusedView = " + tmpView.Name);
195             }
196             else
197             {
198                 Console.WriteLine("Failed: DownFocusedView = " + tmpView.Name);
199             }
200
201             Stage.Instance.Remove(leftView);
202             tmpView = view.LeftFocusableView;
203             if (!tmpView)
204             {
205                 Console.WriteLine("Passed: NULL LeftFocusedView");
206             }
207             else
208             {
209                 Console.WriteLine("Failed: LeftFocusedView = " + tmpView.Name);
210             }
211
212             Console.WriteLine("### [1] NavigationPropertiesTests END");
213         }
214
215         public void OperatorTests()
216         {
217             Console.WriteLine("");
218             Console.WriteLine("### [2] OperatorTests START");
219             Actor actor = new Actor();
220             Actor differentActor = new Actor();
221             Actor actorSame = actor;
222             Actor nullActor = null;
223
224             // test the true operator
225             if (actor)
226             {
227                 Console.WriteLine("BaseHandle Operator true (actor) : test passed ");
228             }
229             else
230             {
231                 Console.WriteLine("BaseHandle Operator true (actor): test failed ");
232             }
233
234             Actor parent = actor.GetParent();
235
236             if (parent)
237             {
238                 Console.WriteLine("Handle with Empty body  :failed ");
239             }
240             else
241             {
242                 Console.WriteLine("Valid with Empty body  :passed ");
243             }
244
245             actor.Add(differentActor);
246
247             // here we test two different C# objects, which on the native side have the same body/ ref-object
248             if (actor == differentActor.GetParent())
249             {
250                 Console.WriteLine("actor == differentActor.GetParent() :passed ");
251             }
252             else
253             {
254                 Console.WriteLine("actor == differentActor.GetParent() :failed ");
255             }
256
257             if (differentActor == differentActor.GetParent())
258             {
259                 Console.WriteLine("differentActor == differentActor.GetParent() :failed ");
260             }
261             else
262             {
263                 Console.WriteLine("differentActor == differentActor.GetParent() :passed ");
264             }
265
266             if (nullActor)
267             {
268                 Console.WriteLine("BaseHandle Operator true (nullActor) : test failed ");
269             }
270             else
271             {
272                 Console.WriteLine("BaseHandle Operator true (nullActor): test passed ");
273             }
274
275             // ! operator
276             if (!actor)
277             {
278                 Console.WriteLine("BaseHandle Operator !(actor) : test failed ");
279             }
280             else
281             {
282                 Console.WriteLine("BaseHandle Operator !(actor): test passed ");
283             }
284
285             if (!nullActor)
286             {
287                 Console.WriteLine("BaseHandle Operator !(nullActor) : test passed ");
288             }
289             else
290             {
291                 Console.WriteLine("BaseHandle Operator !(nullActor): test failed ");
292             }
293
294             // Note: operator false only used inside & operator
295             // test equality operator ==
296             if (actor == actorSame)
297             {
298                 Console.WriteLine("BaseHandle Operator  (actor == actorSame) : test passed");
299             }
300             else
301             {
302                 Console.WriteLine("BaseHandle Operator  (actor == actorSame) : test failed");
303             }
304
305             if (actor == differentActor)
306             {
307                 Console.WriteLine("BaseHandle Operator (actor == differentActor) : test failed");
308             }
309             else
310             {
311                 Console.WriteLine("BaseHandle Operator (actor == differentActor) : test passed");
312             }
313
314             if (actor == nullActor)
315             {
316                 Console.WriteLine("BaseHandle Operator (actor == nullActor) : test failed");
317             }
318             else
319             {
320                 Console.WriteLine("BaseHandle Operator (actor == nullActor) : test passed");
321             }
322
323             if (nullActor == nullActor)
324             {
325                 Console.WriteLine("BaseHandle Operator (nullActor == nullActor) : test passed");
326             }
327             else
328             {
329                 Console.WriteLine("BaseHandle Operator (nullActor == nullActor) : test failed");
330             }
331
332             // test || operator
333             if (actor || actorSame)
334             {
335                 Console.WriteLine("BaseHandle Operator (actor || actorSame) : test passed");
336             }
337             else
338             {
339                 Console.WriteLine("BaseHandle Operator (actor || actorSame) : test failed");
340             }
341
342             if (actor || nullActor)
343             {
344                 Console.WriteLine("BaseHandle Operator (actor || nullActor) : test passed");
345             }
346             else
347             {
348                 Console.WriteLine("BaseHandle Operator (actor || nullActor) : test failed");
349             }
350
351             if (nullActor || nullActor)
352             {
353                 Console.WriteLine("BaseHandle Operator (nullActor || nullActor) : test failed");
354             }
355             else
356             {
357                 Console.WriteLine("BaseHandle Operator (nullActor || nullActor) : test passed");
358             }
359
360             // test && operator
361             if (actor && actorSame)
362             {
363                 Console.WriteLine("BaseHandle Operator (actor && actorSame) : test passed");
364             }
365             else
366             {
367                 Console.WriteLine("BaseHandle Operator (actor && actorSame) : test failed");
368             }
369
370             if (actor && nullActor)
371             {
372                 Console.WriteLine("BaseHandle Operator (actor && nullActor) : test failed");
373             }
374             else
375             {
376                 Console.WriteLine("BaseHandle Operator (actor && nullActor) : test passed");
377             }
378
379             if (nullActor && nullActor)
380             {
381                 Console.WriteLine("BaseHandle Operator (nullActor && nullActor) : test failed");
382             }
383             else
384             {
385                 Console.WriteLine("BaseHandle Operator (nullActor && nullActor) : test passed");
386             }
387
388             Console.WriteLine("### [2] OperatorTests END");
389
390         }
391
392         public void CustomViewPropertyTest()
393         {
394             Console.WriteLine("");
395             Console.WriteLine("### [3] CustomViewPropertyTest START");
396
397             // Create a Spin control
398             Spin spin = new Spin();
399
400             // Background property
401             Property.Map background = new Property.Map();
402             background.Add(Dali.Constants.Visual.Property.Type, new Property.Value((int)Dali.Constants.Visual.Type.Color))
403                       .Add(Dali.Constants.ColorVisualProperty.MixColor, new Property.Value(Color.Red));
404             spin.Background = background;
405
406             background = spin.Background;
407             Color backgroundColor = new Color();
408             background.Find(Dali.Constants.ColorVisualProperty.MixColor).Get(backgroundColor);
409
410             if (backgroundColor == Color.Red)
411             {
412                 Console.WriteLine("Custom View Background property : test passed");
413             }
414             else
415             {
416                 Console.WriteLine("Custom View Background property : test failed");
417             }
418
419             // BackgroundColor property
420             spin.BackgroundColor = Color.Yellow;
421
422             if (spin.BackgroundColor.EqualTo(Color.Yellow))
423             {
424                 Console.WriteLine("Custom View BackgroundColor property : test passed");
425             }
426             else
427             {
428                 Console.WriteLine("Custom View BackgroundColor property : test failed");
429             }
430
431             // BackgroundImage property
432             spin.BackgroundImage = "background-image.jpg";
433             if (spin.BackgroundImage == "background-image.jpg")
434             {
435                 Console.WriteLine("Custom View BackgroundImage property : test passed");
436             }
437             else
438             {
439                 Console.WriteLine("Custom View BackgroundImage property : test failed");
440             }
441
442             // StyleName property
443             spin.StyleName = "MyCustomStyle";
444             if (spin.StyleName == "MyCustomStyle")
445             {
446                 Console.WriteLine("Custom View StyleName property : test passed");
447             }
448             else
449             {
450                 Console.WriteLine("Custom View StyleName property : test failed");
451             }
452
453             Console.WriteLine("### [3] CustomViewPropertyTest END");
454         }
455
456
457
458         public void ActorHandleTest()
459         {
460             Console.WriteLine("");
461             Console.WriteLine("### [4] ActorHandleTest START");
462
463             Handle handle = new Handle();
464             int myPropertyIndex = handle.RegisterProperty("myProperty", new Property.Value(10.0f), Property.AccessMode.READ_WRITE);
465             float myProperty = 0.0f;
466             handle.GetProperty(myPropertyIndex).Get(ref myProperty);
467             Console.WriteLine("myProperty value: " + myProperty);
468
469             int myPropertyIndex2 = handle.RegisterProperty("myProperty2", new Property.Value(new Size(5.0f, 5.0f, 5.0f)), Property.AccessMode.READ_WRITE);
470             Size myProperty2 = new Size(0.0f, 0.0f, 0.0f);
471             handle.GetProperty(myPropertyIndex2).Get(myProperty2);
472             Console.WriteLine("myProperty2 value: " + myProperty2.Width + ", " + myProperty2.Height);
473
474             Actor actor = new Actor();
475             actor.Size = new Position(200.0f, 200.0f, 0.0f);
476             actor.Name = "MyActor";
477             Console.WriteLine("Actor id: {0}", actor.GetId());
478             Console.WriteLine("Actor size: " + actor.Size.X + ", " + actor.Size.Y);
479             Console.WriteLine("Actor name: " + actor.Name);
480
481             Stage stage = Stage.GetCurrent();
482             stage.BackgroundColor = Color.White;
483             Size2D stageSize = stage.Size;
484             Console.WriteLine("Stage size: " + stageSize.Width + ", " + stageSize.Height);
485             stage.Add(actor);
486
487             TextLabel text = new TextLabel("Hello World");
488             text.ParentOrigin = NDalic.ParentOriginCenter;
489             text.AnchorPoint = NDalic.AnchorPointCenter;
490             text.HorizontalAlignment = "CENTER";
491             stage.Add(text);
492
493             Console.WriteLine("Text label text:  " + text.Text);
494
495             Console.WriteLine("Text label point size:  " + text.PointSize);
496             text.PointSize = 32.0f;
497             Console.WriteLine("Text label new point size:  " + text.PointSize);
498
499             Console.WriteLine("### [4] ActorHandleTest END");
500
501         }
502
503
504
505         public void RectanglePaddingClassTest()
506         {
507             Console.WriteLine("");
508             Console.WriteLine("### [5] RectanglePaddingClassTest START");
509
510             using (Rectangle r1 = new Rectangle(2, 5, 20, 30))
511             {
512                 Console.WriteLine("    Created " + r1);
513                 Console.WriteLine("    IsEmpty() =  " + r1.IsEmpty());
514                 Console.WriteLine("    Left =  " + r1.Left());
515                 Console.WriteLine("    Right =  " + r1.Right());
516                 Console.WriteLine("    Top  = " + r1.Top());
517                 Console.WriteLine("    Bottom  = " + r1.Bottom());
518                 Console.WriteLine("    Area  = " + r1.Area());
519             }
520
521             Console.WriteLine(" *************************");
522
523             using (Rectangle r2 = new Rectangle(2, 5, 20, 30))
524             {
525                 Console.WriteLine("    Created " + r2);
526                 r2.Set(1, 1, 40, 40);
527                 Console.WriteLine("    IsEmpty() =  " + r2.IsEmpty());
528                 Console.WriteLine("    Left =  " + r2.Left());
529                 Console.WriteLine("    Right =  " + r2.Right());
530                 Console.WriteLine("    Top  = " + r2.Top());
531                 Console.WriteLine("    Bottom  = " + r2.Bottom());
532                 Console.WriteLine("    Area  = " + r2.Area());
533             }
534
535             Console.WriteLine(" *************************");
536
537             Rectangle r3 = new Rectangle(10, 10, 20, 20);
538             Rectangle r4 = new Rectangle(10, 10, 20, 20);
539
540             if (r3 == r4)
541             {
542                 Console.WriteLine("r3 == r4");
543             }
544             else
545             {
546                 Console.WriteLine("r3 != r4");
547             }
548
549             r4 = new Rectangle(12, 10, 20, 20);
550
551             if (r3 == r4)
552             {
553                 Console.WriteLine("r3 == r4");
554             }
555             else
556             {
557                 Console.WriteLine("r3 != r4");
558             }
559
560             PaddingType p1 = new PaddingType(10.5f, 10.7f, 20.8f, 20.8f);
561             PaddingType p2 = new PaddingType(10.5f, 10.7f, 20.8f, 20.8f);
562
563             if (p1 == p2)
564             {
565                 Console.WriteLine("p1 == p2");
566             }
567             else
568             {
569                 Console.WriteLine("p1 != p2");
570             }
571
572             p2 = new PaddingType(12.0f, 10.7f, 20.2f, 20.0f);
573
574             if (p1 == p2)
575             {
576                 Console.WriteLine("p1 == p2");
577             }
578             else
579             {
580                 Console.WriteLine("p1 != p2");
581             }
582             Console.WriteLine("### [5] RectanglePaddingClassTest END");
583
584         }
585
586
587         public void SizePositionTest()
588         {
589             Console.WriteLine("");
590             Console.WriteLine("### [6] SizePositionTest START");
591
592             Size Size = new Size(100, 50, 25);
593             Console.WriteLine("    Created " + Size);
594             Console.WriteLine("    Size w =  " + Size.Width + ", h = " + Size.Height + ", d = " + Size.Depth);
595             Size += new Size(20, 20, 20);
596             Console.WriteLine("    Size w =  " + Size.Width + ", h = " + Size.Height + ", d = " + Size.Depth);
597             Size.Width += 10;
598             Size.Height += 10;
599             Size.Depth += 10;
600             Console.WriteLine("    Size width =  " + Size.Width+ ", height = " + Size.Height + ", depth = " + Size.Depth);
601
602             Console.WriteLine(" *************************");
603             Position Position = new Position(20, 100, 50);
604             Console.WriteLine("    Created " + Position);
605             Console.WriteLine("    Position x =  " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z);
606             Position += new Position(20, 20, 20);
607             Console.WriteLine("    Position x =  " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z);
608             Position.X += 10;
609             Position.Y += 10;
610             Position.Z += 10;
611             Console.WriteLine("    Position width =  " + Position.X + ", height = " + Position.Y + ", depth = " + Position.Z);
612             Position parentOrigin = ParentOrigin.BottomRight;
613             Console.WriteLine("    parentOrigin x =  " + parentOrigin.X + ", y = " + parentOrigin.Y + ", z = " + parentOrigin.Z);
614
615             Console.WriteLine(" *************************");
616             Color color = new Color(20, 100, 50, 200);
617             Console.WriteLine("    Created " + color);
618             Console.WriteLine("    Color R =  " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A);
619             color += new Color(20, 20, 20, 20);
620             Console.WriteLine("    Color R =  " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A);
621             color.R += 10;
622             color.G += 10;
623             color.B += 10;
624             color.A += 10;
625             Console.WriteLine("    Color r =  " + color.R + ", g = " + color.G + ", b = " + color.B + ", a = " + color.A);
626
627             Console.WriteLine("### [6] SizePositionTest END");
628         }
629
630
631         public void ViewDownCastTest()
632         {
633             Console.WriteLine("");
634             Console.WriteLine("### [7] ViewDownCastTest START");
635
636             View container = new View();
637             container.Position = new Position(-800.0f, -800.0f, 0.0f);
638             Stage.GetCurrent().Add(container);
639
640             // Test downcast for native control
641             TextLabel myLabel = new TextLabel();
642             myLabel.Name = "MyLabelName";
643             myLabel.Text = "MyText";
644
645             Console.WriteLine("myLabel.Name = " + myLabel.Name + ", Text = " + myLabel.Text);
646
647             container.Add(myLabel);
648
649             Actor myLabelActor = container.FindChildByName("MyLabelName");
650             if (myLabelActor)
651             {
652                 TextLabel newLabel = View.DownCast<TextLabel>(myLabelActor);
653                 if (newLabel)
654                 {
655                     Console.WriteLine("Downcast to TextLabel successful: newLabel Name = " + newLabel.Name + ", Text = " + newLabel.Text);
656                 }
657                 else
658                 {
659                     Console.WriteLine("Downcast to TextLabel failed!");
660                 }
661             }
662
663             // Test downcast for class directly inherited from View
664             MyView myView = new MyView();
665             myView.Name = "MyViewName";
666             myView.MyOwnName = "MyOwnViewName";
667             myView._myCurrentValue = 5;
668
669             Console.WriteLine("myView.Name = " + myView.Name + ", MyOwnName = " + myView.MyOwnName + ", myCurrentValue = " + myView._myCurrentValue);
670
671             container.Add(myView);
672
673             Actor myViewActor = container.FindChildByName("MyViewName");
674             if (myViewActor)
675             {
676                 MyView newView = View.DownCast<MyView>(myViewActor);
677                 if (newView)
678                 {
679                     Console.WriteLine("Downcast to MyView successful: newView Name = " + newView.Name + ", MyOwnName = " + newView.MyOwnName + ", myCurrentValue = " + newView._myCurrentValue);
680                 }
681                 else
682                 {
683                     Console.WriteLine("Downcast to MyView failed!");
684                 }
685             }
686
687             // Test downcast for class directly inherited from native control
688             MyButton myButton = new MyButton();
689             myButton.Name = "MyButtonName";
690             myButton.MyOwnName = "MyOwnViewName";
691             myButton.LabelText = "MyLabelText";
692             myButton._myCurrentValue = 5;
693
694             Console.WriteLine("myButton.Name = " + myButton.Name + ", MyOwnName = " + myButton.MyOwnName + ", LabelText = " + myButton.LabelText + ", myCurrentValue = " + myButton._myCurrentValue);
695
696             container.Add(myButton);
697
698             Actor myButtonActor = container.FindChildByName("MyButtonName");
699             if (myButtonActor)
700             {
701                 MyButton newButton = View.DownCast<MyButton>(myButtonActor);
702                 if (newButton)
703                 {
704                     Console.WriteLine("Downcast to MyButton successful: newButton Name = " + newButton.Name + ", MyOwnName = " + newButton.MyOwnName + ", LabelText = " + myButton.LabelText + ", myCurrentValue = " + newButton._myCurrentValue);
705                 }
706                 else
707                 {
708                     Console.WriteLine("Downcast to MyButton failed!");
709                 }
710             }
711
712             // Test downcast for a CustomView
713             Spin spin = new Spin();
714             spin.Name = "SpinName";
715             spin.MaxValue = 8888;
716
717             Console.WriteLine("spin.Name = " + spin.Name + ", MaxValue = " + spin.MaxValue);
718
719             container.Add(spin);
720
721             Actor spinActor = container.FindChildByName("SpinName");
722             if (spinActor)
723             {
724                 Spin newSpin = View.DownCast<Spin>(spinActor);
725                 if (newSpin)
726                 {
727                     Console.WriteLine("Downcast to Spin successful: newSpin Name = " + newSpin.Name + ", MaxValue = " + newSpin.MaxValue);
728                 }
729                 else
730                 {
731                     Console.WriteLine("Downcast to Spin failed!");
732                 }
733             }
734
735             // Test downcast for class inherited from a CustomView
736             MySpin mySpin = new MySpin();
737             mySpin.Name = "MySpinName";
738             mySpin.MyOwnName = "MyOwnSpinName";
739             mySpin.MaxValue = 8888;
740             mySpin._myCurrentValue = 5;
741
742             Console.WriteLine("mySpin.Name = " + mySpin.Name + ", MyOwnName = " + mySpin.MyOwnName + ", MaxValue = " + mySpin.MaxValue + ", currentValue = " + mySpin._myCurrentValue);
743
744             container.Add(mySpin);
745
746             Actor mySpinActor = container.FindChildByName("MySpinName");
747             if (mySpinActor)
748             {
749                 MySpin newSpin = View.DownCast<MySpin>(mySpinActor);
750                 if (newSpin)
751                 {
752                     Console.WriteLine("Downcast to MySpin successful: newSpin Name = " + newSpin.Name + ", MyOwnName = " + newSpin.MyOwnName + ", MaxValue = " + newSpin.MaxValue + ", currentValue = " + newSpin._myCurrentValue);
753                 }
754                 else
755                 {
756                     Console.WriteLine("Downcast to MySpin failed!");
757                 }
758             }
759
760             Console.WriteLine("### [7] ViewDownCastTest END");
761         }
762
763         public void MainLoop()
764         {
765             _application.MainLoop();
766         }
767
768         /// <summary>
769         /// The main entry point for the application.
770         /// </summary>
771         [STAThread]
772         static void Main(string[] args)
773         {
774             Console.WriteLine("Hello World");
775
776             Example example = new Example(Application.NewApplication());
777             example.MainLoop();
778         }
779
780       private void LOG(string str, int result = -1)
781       {
782         if (result == 1) Console.WriteLine(str + " : test passed!");
783         else if (result == 0) Console.WriteLine(str + " : test failed! TEST FAILED! test failed! TEST FAILED!");
784         else Console.WriteLine(str);
785       }
786
787       private void CustomPropertyHighLevelClassTest()
788       {
789         LOG("=================================");
790         LOG(" high level class test");
791         LOG("=================================");
792
793         Handle handle = new Handle();
794         int myPropertyIndex1 = handle.RegisterProperty("myProperty1", new Property.Value(new Size(10, 20, 30)), Property.AccessMode.READ_WRITE);
795         Size myProperty1 = Dali.Size.Zero;
796         handle.GetProperty(myPropertyIndex1).Get(myProperty1);
797         if (myProperty1.EqualTo(new Size(10, 20, 30))) LOG( "myProperty1 must be Size(10, 20, 30) get=" + myProperty1, 1);
798         else LOG( "myProperty1 must be Size(10, 20, 30) get=" + myProperty1, 0);
799
800         int myPropertyIndex2 = handle.RegisterProperty("myProperty2", new Property.Value(new Position(40, 50, 60)), Property.AccessMode.READ_WRITE);
801         Position myProperty2 = Dali.Position.Zero;
802         handle.GetProperty(myPropertyIndex2).Get(myProperty2);
803         if (myProperty2.EqualTo(new Position(40, 50, 60))) LOG( "myProperty2 must be Position(40, 50, 60) get=" + myProperty2, 1);
804         else LOG( "myProperty2 must be Position(40, 50, 60) get=" + myProperty2, 0);
805
806         int myPropertyIndex3 = handle.RegisterProperty("myProperty3", new Property.Value(Color.Cyan), Property.AccessMode.READ_WRITE);
807         Color myProperty3 = Color.Transparent;
808         handle.GetProperty(myPropertyIndex3).Get(myProperty3);
809         if (myProperty3.EqualTo(Color.Cyan)) LOG( "myProperty3 must be Color.Cyan get=" + myProperty3, 1);
810         else LOG( "myProperty3 must be Color.Cyan get=" + myProperty3, 0);
811
812         int myPropertyIndex4 = handle.RegisterProperty("myProperty4", new Property.Value(new Size2D(100, 200)), Property.AccessMode.READ_WRITE);
813         Size2D myProperty4 = new Size2D(0, 0);
814         handle.GetProperty(myPropertyIndex4).Get(myProperty4);
815         if (myProperty4.EqualTo(new Size2D(100, 200))) LOG( "myProperty4 must be new Size2D(100, 200) get=" + myProperty4, 1);
816         else LOG( "myProperty4 must be new Size2D(100, 200) get=" + myProperty4, 0);
817
818         int myPropertyIndex5 = handle.RegisterProperty("myProperty5", new Property.Value(new Position2D(200, 300)), Property.AccessMode.READ_WRITE);
819         Position2D myProperty5 = new Position2D(0, 0);
820         handle.GetProperty(myPropertyIndex5).Get(myProperty5);
821         if (myProperty5.EqualTo(new Position2D(200, 300))) LOG( "myProperty5 must be new Position2D(200, 300) get=" + myProperty5, 1);
822         else LOG( "myProperty5 must be new Position2D(200, 300) get=" + myProperty5, 0);
823
824         View view = new View();
825         view.Size2D = new Size2D(new Size(200.0f, 200.0f, 0.0f));
826         view.Name = "MyView1";
827         view.BackgroundColor = new Color(1.0f, 0.0f, 1.0f, 0.8f);
828         LOG("view id: " + view.GetId());
829         LOG("view size: " + view.Size.Width + ", " + view.Size.Height + "," + view.Size.Depth);
830         LOG("view size2d: " + view.Size2D.Width + ", " + view.Size2D.Height);
831         LOG("view name: " + view.Name);
832
833         Stage stage = Stage.GetCurrent();
834         Size2D stageSize = stage.Size;
835         LOG("Stage size2d: " + stageSize.Width + ", " + stageSize.Height);
836         stage.Add(view);
837
838         Size Size = new Size(100, 50, 25);
839         LOG( Size +  "Created. this should be (100, 50, 25)!");
840         LOG( "Size width= " + Size.Width + ", height=" + Size.Height + ",depth=" + Size.Depth );
841         Size += new Size(20, 20, 20);
842         if(Size.EqualTo(new Size(120, 70, 45))){ LOG( "plus Size(20,20,20) should be +20 for each! x =  " + Size.Width + ", y = " + Size.Height + ", z = " + Size.Depth, 1);}
843         else { LOG( "plus Size(20,20,20) should be +20 for each! x =  " + Size.Width + ", y = " + Size.Height + ", z = " + Size.Depth, 0);}
844
845         Size.Width += 10;
846         Size.Height += 10;
847         Size.Depth += 10;
848         if(Size.EqualTo(new Size(130, 80, 55))){ LOG( "plus 10 for each! width =  " + Size.Width + ", height = " + Size.Height + ", depth = " + Size.Depth, 1); }
849         else { LOG( "plus 10 for each! width =  " + Size.Width + ", height = " + Size.Height + ", depth = " + Size.Depth, 0); }
850
851         Position Position = new Position(20, 100, 50);
852         LOG(Position + "Created ");
853         LOG( "Position x =  " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z );
854         Position += new Position(20, 20, 20);
855         if(Position.EqualTo(new Position(40, 120, 70))) LOG( "plus Position(20, 20, 20)! Position x =  " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z, 1);
856         else LOG( "plus Position(20, 20, 20)! Position x =  " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z, 0);
857
858         Position.X += 10;
859         Position.Y += 10;
860         Position.Z += 10;
861         if(Position.EqualTo(new Position(50, 130, 80))) LOG( "plus +10 for each! Position width =  " + Position.X + ", height = " + Position.Y + ", depth = " + Position.Z, 1 );
862         else  LOG( "plus +10 for each! Position width =  " + Position.X + ", height = " + Position.Y + ", depth = " + Position.Z, 0 );
863
864         Position2D _position2d = new Position2D(new Position(600.0f, 700.0f, 800.0f));
865         LOG(_position2d + "Created ");
866         LOG( "_postion2d x =  " + _position2d.X + ", y = " + _position2d.Y);
867         _position2d += new Position2D(20, 20);
868         if(_position2d.EqualTo(new Position2D(620, 720))) LOG( "plus Position2D(20, 20)! Position x =  " + _position2d.X + ", y = " + _position2d.Y, 1);
869         else LOG( "plus Position2D(20, 20)! Position x =  " + _position2d.X + ", y = " + _position2d.Y, 0);
870
871         Position parentOrigin = ParentOrigin.BottomRight;
872         LOG( "parentOrigin.BottomRight x=" + parentOrigin.X + ", y=" + parentOrigin.Y + ", z=" + parentOrigin.Z );
873
874         Color color = new Color(20, 100, 50, 200);
875         LOG( color +  "    Created ");
876         LOG( "Color R =  " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A );
877         color += new Color(20, 20, 20, 20);
878         if(color.EqualTo(new Color(40, 120, 70, 220))) LOG( "plus Color(20, 20, 20, 20)! Color R =  " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A, 1 );
879         else LOG( "plus Color(20, 20, 20, 20)! Color R =  " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A, 0 );
880         color.R += 10;
881         color.G += 10;
882         color.B += 10;
883         color.A += 10;
884         if(color.EqualTo(new Color(50, 130, 80, 230))) LOG( "plus +10 for each! Color r =  " + color.R + ", g = " + color.G + ", b = " + color.B + ", a = " + color.A, 1 );
885         else LOG( "plus +10 for each! Color r =  " + color.R + ", g = " + color.G + ", b = " + color.B + ", a = " + color.A, 0 );
886
887         LOG("=================================");
888       }
889
890     }
891 }
892