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;
35 CallbackDelegate initializeCallback = new CallbackDelegate( Initialize );
36 Console.WriteLine( "InitSignal connection count = " + _application.InitSignal().GetConnectionCount() );
38 _application.InitSignal().Connect( initializeCallback );
39 Console.WriteLine( "InitSignal connection count = " + _application.InitSignal().GetConnectionCount() );
42 private void Initialize(IntPtr appPtr)
44 Handle handle = new Handle();
45 int myPropertyIndex = handle.RegisterProperty("myProperty", new Property.Value(10.0f), Property.AccessMode.READ_WRITE);
46 float myProperty = 0.0f;
47 handle.GetProperty(myPropertyIndex).Get(ref myProperty);
48 Console.WriteLine( "myProperty value: " + myProperty );
50 int myPropertyIndex2 = handle.RegisterProperty("myProperty2", new Property.Value(new Vector2(5.0f, 5.0f)), Property.AccessMode.READ_WRITE);
51 Vector2 myProperty2 = new Vector2(0.0f, 0.0f);
52 handle.GetProperty(myPropertyIndex2).Get(myProperty2);
53 Console.WriteLine( "myProperty2 value: " + myProperty2.x + ", " + myProperty2.y );
55 Actor actor = new Actor();
56 actor.Size = new Vector3(200.0f, 200.0f, 0.0f);
57 actor.Name = "MyActor";
58 actor.Color = new Vector4(1.0f, 0.0f, 1.0f, 0.8f);
59 Console.WriteLine("Actor id: {0}", actor.GetId());
60 Console.WriteLine("Actor size: " + actor.Size.x + ", " + actor.Size.y);
61 Console.WriteLine("Actor name: " + actor.Name);
63 Stage stage = Stage.GetCurrent();
64 stage.SetBackgroundColor( NDalic.WHITE );
66 Vector2 stageSize = stage.GetSize();
67 Console.WriteLine("Stage size: " + stageSize.x + ", " + stageSize.y);
70 TextLabel text = new TextLabel("Hello Mono World");
71 text.ParentOrigin = NDalic.ParentOriginCenter;
72 text.AnchorPoint = NDalic.AnchorPointCenter;
73 text.HorizontalAlignment = "CENTER";
76 Console.WriteLine( "Text label text: " + text.Text );
78 Console.WriteLine( "Text label point size: " + text.PointSize );
79 text.PointSize = 32.0f;
80 Console.WriteLine( "Text label new point size: " + text.PointSize );
82 using (RectInteger ri = new RectInteger(02,05,20,30))
84 Console.WriteLine( " Created " + ri );
85 Console.WriteLine( " IsEmpty() = " + ri.IsEmpty() );
86 Console.WriteLine( " Left = " + ri.Left() );
87 Console.WriteLine( " Right = " + ri.Right() );
88 Console.WriteLine( " Top = " + ri.Top() );
89 Console.WriteLine( " Bottom = " + ri.Bottom() );
90 Console.WriteLine( " Area = " + ri.Area() );
92 Console.WriteLine( " *************************" );
93 using (RectInteger ri2 = new RectInteger(02,05,20,30))
95 Console.WriteLine( " Created " + ri2 );
97 Console.WriteLine( " IsEmpty() = " + ri2.IsEmpty() );
98 Console.WriteLine( " Left = " + ri2.Left() );
99 Console.WriteLine( " Right = " + ri2.Right() );
100 Console.WriteLine( " Top = " + ri2.Top() );
101 Console.WriteLine( " Bottom = " + ri2.Bottom() );
102 Console.WriteLine( " Area = " + ri2.Area() );
104 Console.WriteLine( " *************************" );
105 using (RectDouble rd = new RectDouble(02,05,20.5,30.5))
107 Console.WriteLine( " Created " + rd );
108 Console.WriteLine( " IsEmpty() = " + rd.IsEmpty() );
109 Console.WriteLine( " Left = " + rd.Left() );
110 Console.WriteLine( " Right = " + rd.Right() );
111 Console.WriteLine( " Top = " + rd.Top() );
112 Console.WriteLine( " Bottom = " + rd.Bottom() );
113 Console.WriteLine( " Area = " + rd.Area() );
115 Console.WriteLine( " *************************" );
116 RectDouble rd2 = new RectDouble();
121 Console.WriteLine( " Created " + rd2 );
122 Console.WriteLine( " IsEmpty() = " + rd2.IsEmpty() );
123 Console.WriteLine( " Left = " + rd2.Left() );
124 Console.WriteLine( " Right = " + rd2.Right() );
125 Console.WriteLine( " Top = " + rd2.Top() );
126 Console.WriteLine( " Bottom = " + rd2.Bottom() );
127 Console.WriteLine( " Area = " + rd2.Area() );
129 Console.WriteLine( " *************************" );
130 Vector2 vector2 = new Vector2(100, 50);
131 Console.WriteLine( " Created " + vector2 );
132 Console.WriteLine( " Vector2 x = " + vector2.x + ", y = " + vector2.y );
133 vector2 += new Vector2(20, 20);
134 Console.WriteLine( " Vector2 x = " + vector2[0] + ", y = " + vector2[1] );
137 Console.WriteLine( " Vector2 width = " + vector2.width + ", height = " + vector2.height );
138 vector2 += new Vector2(15, 15);
139 Console.WriteLine( " Vector2 width = " + vector2[0] + ", height = " + vector2[1] );
141 Console.WriteLine( " *************************" );
142 Vector3 vector3 = new Vector3(20, 100, 50);
143 Console.WriteLine( " Created " + vector3 );
144 Console.WriteLine( " Vector3 x = " + vector3.x + ", y = " + vector3.y + ", z = " + vector3.z );
145 vector3 += new Vector3(20, 20, 20);
146 Console.WriteLine( " Vector3 x = " + vector3[0] + ", y = " + vector3[1] + ", z = " + vector3[2] );
150 Console.WriteLine( " Vector3 width = " + vector3.width + ", height = " + vector3.height + ", depth = " + vector3.depth );
151 Vector3 parentOrigin = NDalic.ParentOriginBottomRight;
152 Console.WriteLine( " parentOrigin x = " + parentOrigin.x + ", y = " + parentOrigin.y + ", z = " + parentOrigin.z );
154 Console.WriteLine( " *************************" );
155 Vector4 vector4 = new Vector4(20, 100, 50, 200);
156 Console.WriteLine( " Created " + vector4 );
157 Console.WriteLine( " Vector4 x = " + vector4.x + ", y = " + vector4.y + ", z = " + vector4.z + ", w = " + vector4.w );
158 vector4 += new Vector4(20, 20, 20, 20);
159 Console.WriteLine( " Vector4 x = " + vector4[0] + ", y = " + vector4[1] + ", z = " + vector4[2] + ", w = " + vector4[3] );
164 Console.WriteLine( " Vector4 r = " + vector4.r + ", g = " + vector4.g + ", b = " + vector4.b + ", a = " + vector4.a );
167 public void MainLoop()
169 _application.MainLoop ();
173 /// The main entry point for the application.
176 static void Main(string[] args)
178 Console.WriteLine ("Hello Mono World");
180 Example example = new Example(Application.NewApplication());