2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 using System.Runtime.InteropServices;
22 namespace MyCSharpExample
26 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
27 delegate void CallbackDelegate(IntPtr appPtr); // void, void delgate
29 private Dali.Application _application;
31 public Example(Dali.Application application)
33 _application = application;
34 Console.WriteLine( "InitSignal connection count = " + _application.InitSignal().GetConnectionCount() );
36 _application.Initialized += Initialize;
37 Console.WriteLine( "InitSignal connection count = " + _application.InitSignal().GetConnectionCount() );
40 public void Initialize(object source, AUIApplicationInitEventArgs e)
42 Handle handle = new Handle();
43 int myPropertyIndex = handle.RegisterProperty("myProperty", new Property.Value(10.0f), Property.AccessMode.READ_WRITE);
44 float myProperty = 0.0f;
45 handle.GetProperty(myPropertyIndex).Get(ref myProperty);
46 Console.WriteLine( "myProperty value: " + myProperty );
48 int myPropertyIndex2 = handle.RegisterProperty("myProperty2", new Property.Value(new Vector2(5.0f, 5.0f)), Property.AccessMode.READ_WRITE);
49 Vector2 myProperty2 = new Vector2(0.0f, 0.0f);
50 handle.GetProperty(myPropertyIndex2).Get(myProperty2);
51 Console.WriteLine( "myProperty2 value: " + myProperty2.x + ", " + myProperty2.y );
53 Actor actor = new Actor();
54 actor.Size = new Vector3(200.0f, 200.0f, 0.0f);
55 actor.Name = "MyActor";
56 actor.Color = new Vector4(1.0f, 0.0f, 1.0f, 0.8f);
57 Console.WriteLine("Actor id: {0}", actor.GetId());
58 Console.WriteLine("Actor size: " + actor.Size.x + ", " + actor.Size.y);
59 Console.WriteLine("Actor name: " + actor.Name);
61 Stage stage = Stage.GetCurrent();
62 stage.BackgroundColor = NDalic.WHITE ;
64 Vector2 stageSize = stage.Size;
65 Console.WriteLine("Stage size: " + stageSize.x + ", " + stageSize.y);
68 TextLabel text = new TextLabel("Hello Mono World");
69 text.ParentOrigin = NDalic.ParentOriginCenter;
70 text.AnchorPoint = NDalic.AnchorPointCenter;
71 text.HorizontalAlignment = "CENTER";
74 Console.WriteLine( "Text label text: " + text.Text );
76 Console.WriteLine( "Text label point size: " + text.PointSize );
77 text.PointSize = 32.0f;
78 Console.WriteLine( "Text label new point size: " + text.PointSize );
80 using (RectInteger ri = new RectInteger(02,05,20,30))
82 Console.WriteLine( " Created " + ri );
83 Console.WriteLine( " IsEmpty() = " + ri.IsEmpty() );
84 Console.WriteLine( " Left = " + ri.Left() );
85 Console.WriteLine( " Right = " + ri.Right() );
86 Console.WriteLine( " Top = " + ri.Top() );
87 Console.WriteLine( " Bottom = " + ri.Bottom() );
88 Console.WriteLine( " Area = " + ri.Area() );
90 Console.WriteLine( " *************************" );
91 using (RectInteger ri2 = new RectInteger(02,05,20,30))
93 Console.WriteLine( " Created " + ri2 );
95 Console.WriteLine( " IsEmpty() = " + ri2.IsEmpty() );
96 Console.WriteLine( " Left = " + ri2.Left() );
97 Console.WriteLine( " Right = " + ri2.Right() );
98 Console.WriteLine( " Top = " + ri2.Top() );
99 Console.WriteLine( " Bottom = " + ri2.Bottom() );
100 Console.WriteLine( " Area = " + ri2.Area() );
102 Console.WriteLine( " *************************" );
103 using (RectDouble rd = new RectDouble(02,05,20.5,30.5))
105 Console.WriteLine( " Created " + rd );
106 Console.WriteLine( " IsEmpty() = " + rd.IsEmpty() );
107 Console.WriteLine( " Left = " + rd.Left() );
108 Console.WriteLine( " Right = " + rd.Right() );
109 Console.WriteLine( " Top = " + rd.Top() );
110 Console.WriteLine( " Bottom = " + rd.Bottom() );
111 Console.WriteLine( " Area = " + rd.Area() );
113 Console.WriteLine( " *************************" );
114 RectDouble rd2 = new RectDouble();
119 Console.WriteLine( " Created " + rd2 );
120 Console.WriteLine( " IsEmpty() = " + rd2.IsEmpty() );
121 Console.WriteLine( " Left = " + rd2.Left() );
122 Console.WriteLine( " Right = " + rd2.Right() );
123 Console.WriteLine( " Top = " + rd2.Top() );
124 Console.WriteLine( " Bottom = " + rd2.Bottom() );
125 Console.WriteLine( " Area = " + rd2.Area() );
127 Console.WriteLine( " *************************" );
128 Vector2 vector2 = new Vector2(100, 50);
129 Console.WriteLine( " Created " + vector2 );
130 Console.WriteLine( " Vector2 x = " + vector2.x + ", y = " + vector2.y );
131 vector2 += new Vector2(20, 20);
132 Console.WriteLine( " Vector2 x = " + vector2[0] + ", y = " + vector2[1] );
135 Console.WriteLine( " Vector2 width = " + vector2.width + ", height = " + vector2.height );
136 vector2 += new Vector2(15, 15);
137 Console.WriteLine( " Vector2 width = " + vector2[0] + ", height = " + vector2[1] );
139 Console.WriteLine( " *************************" );
140 Vector3 vector3 = new Vector3(20, 100, 50);
141 Console.WriteLine( " Created " + vector3 );
142 Console.WriteLine( " Vector3 x = " + vector3.x + ", y = " + vector3.y + ", z = " + vector3.z );
143 vector3 += new Vector3(20, 20, 20);
144 Console.WriteLine( " Vector3 x = " + vector3[0] + ", y = " + vector3[1] + ", z = " + vector3[2] );
148 Console.WriteLine( " Vector3 width = " + vector3.width + ", height = " + vector3.height + ", depth = " + vector3.depth );
149 Vector3 parentOrigin = NDalic.ParentOriginBottomRight;
150 Console.WriteLine( " parentOrigin x = " + parentOrigin.x + ", y = " + parentOrigin.y + ", z = " + parentOrigin.z );
152 Console.WriteLine( " *************************" );
153 Vector4 vector4 = new Vector4(20, 100, 50, 200);
154 Console.WriteLine( " Created " + vector4 );
155 Console.WriteLine( " Vector4 x = " + vector4.x + ", y = " + vector4.y + ", z = " + vector4.z + ", w = " + vector4.w );
156 vector4 += new Vector4(20, 20, 20, 20);
157 Console.WriteLine( " Vector4 x = " + vector4[0] + ", y = " + vector4[1] + ", z = " + vector4[2] + ", w = " + vector4[3] );
162 Console.WriteLine( " Vector4 r = " + vector4.r + ", g = " + vector4.g + ", b = " + vector4.b + ", a = " + vector4.a );
165 public void MainLoop()
167 _application.MainLoop ();
171 /// The main entry point for the application.
174 static void Main(string[] args)
176 Console.WriteLine ("Hello Mono World");
178 Example example = new Example(Application.NewApplication());