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;
23 namespace MyCSharpExample
27 private Dali.Application _application;
28 private Animation _animation;
29 private TextLabel _text;
31 public Example(Dali.Application application)
33 _application = application;
34 _application.Initialized += Initialize;
37 public void Initialize(object source, AUIApplicationInitEventArgs e)
39 Console.WriteLine("Customized Application Initialize event handler");
40 Stage stage = Stage.GetCurrent();
41 stage.BackgroundColor = Color.Cyan;
42 stage.TouchEvent += OnStageTouched;
43 stage.WheelEvent += OnStageWheelMoved;
44 stage.KeyEvent += OnStageKeyPressed;
45 stage.EventProcessingFinished += OnStageEventProcessingFinished;
47 // Add a _text label to the stage
48 _text = new TextLabel("Hello Mono World");
49 _text.ParentOrigin = ParentOrigin.Center;
50 _text.AnchorPoint = AnchorPoint.Center;
51 _text.HorizontalAlignment = "CENTER";
52 _text.PointSize = 32.0f;
53 _text.TextColor = Color.Magenta;
57 // Callback for _animation finished signal handling
58 public void AnimationFinished(object sender, EventArgs e)
60 Console.WriteLine("AnimationFinished()!");
63 // Callback for _animation finished signal handling
64 public void AnimationFinished2(object sender, EventArgs e)
66 Console.WriteLine("AnimationFinished2()!");
69 Console.WriteLine("Duration= " + _animation.Duration);
70 Console.WriteLine("EndAction= " + _animation.EndAction);
74 public void OnStageEventProcessingFinished(object sender, EventArgs e)
76 Console.WriteLine("OnStageEventProcessingFinished()!");
79 Console.WriteLine("e != null !");
83 public void OnStageKeyPressed(object sender, Stage.KeyEventArgs e)
85 Console.WriteLine("OnStageKeyEventOccured()!");
86 Console.WriteLine("keyPressedName=" + e.KeyEvent.keyPressedName);
87 Console.WriteLine("state=" + e.KeyEvent.state);
90 public void OnStageWheelMoved(object sender, Stage.WheelEventArgs e)
92 Console.WriteLine("OnStageWheelEventOccured()!");
93 Console.WriteLine("direction=" + e.WheelEvent.direction);
94 Console.WriteLine("type=" + e.WheelEvent.type);
97 // Callback for stage touched signal handling
98 public void OnStageTouched(object sender, Stage.TouchEventArgs e)
100 // Only animate the _text label when touch down happens
101 if( e.TouchData.GetState(0) == PointStateType.DOWN )
103 Console.WriteLine("Customized Stage Touch event handler");
104 // Create a new _animation
107 //_animation.Stop(Dali.Constants.Animation.EndAction.Stop);
111 _animation = new Animation {
115 TargetPoperty = "Orientation",
116 Destination = new Quaternion( new Radian( new Degree( 180.0f ) ), Vect3.Xaxis)
118 _animation.AnimateTo(_text);
120 _animation.StartTime = 500;
121 _animation.EndTime = 1000;
122 _animation.TargetPoperty = "Orientation";
123 _animation.Destination = new Quaternion( new Radian( new Degree( 0.0f ) ), Vect3.Xaxis );
124 _animation.AnimateTo(_text);
126 _animation.StartTime = 1000;
127 _animation.EndTime = 1500;
128 _animation.TargetPoperty = "ScaleX";
129 _animation.Destination = 3.0f;
130 _animation.AnimateBy(_text);
132 _animation.StartTime = 1500;
133 _animation.EndTime = 2000;
134 _animation.TargetPoperty = "ScaleY";
135 _animation.Destination = 4.0f;
136 _animation.AnimateBy(_text);
138 _animation.EndAction = Dali.Constants.Animation.EndAction.Discard;
140 // Connect the signal callback for animaiton finished signal
141 _animation.Finished += AnimationFinished;
142 _animation.Finished += AnimationFinished2;
144 // Play the _animation
150 public void MainLoop()
152 _application.MainLoop ();
156 /// The main entry point for the application.
159 static void Main(string[] args)
161 Console.WriteLine ("Main() called!");
163 Example example = new Example(Application.NewApplication());