dali-1.2.31, nui 0.2.31 upgrade
[platform/core/csapi/nui.git] / NUISamples / NUISamples.TizenTV / examples / hello-test.cs
1 /*
2  * Copyright (c) 2016 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.Applications;
22
23 //------------------------------------------------------------------------------
24 // <manual-generated />
25 //
26 // This file can only run on Tizen target. You should compile it with DaliApplication.cs, and
27 // add tizen c# application related library as reference.
28 //------------------------------------------------------------------------------
29 namespace HelloTest
30 {
31     class Example : NUIApplication
32     {
33         private Animation _animation;
34         private TextLabel _text;
35         private Stage _stage;
36
37         public Example():base()
38         {
39         }
40
41         public Example(string stylesheet):base(stylesheet)
42         {
43         }
44
45         public Example(string stylesheet, WindowMode windowMode):base(stylesheet, windowMode)
46         {
47         }
48
49         protected override void OnCreate()
50         {
51             base.OnCreate();
52             Initialize();
53         }
54
55         private void Initialize()
56         {
57             // Connect the signal callback for stage touched signal
58             _stage = Stage.Instance;
59             _stage.Touch += OnStageTouched;
60
61             // Add a _text label to the stage
62             _text = new TextLabel("Hello Mono World");
63             _text.ParentOrigin = ParentOrigin.Center;
64             _text.AnchorPoint = AnchorPoint.Center;
65             _text.HorizontalAlignment = "CENTER";
66             _text.PointSize = 32.0f;
67
68             _stage.GetDefaultLayer().Add(_text);
69         }
70
71         // Callback for _animation finished signal handling
72         private void AnimationFinished(object sender, EventArgs e)
73         {
74             if (_animation)
75             {
76                 Console.WriteLine("Duration= " + _animation.Duration);
77                 Console.WriteLine("EndAction= " + _animation.EndAction);
78             }
79         }
80
81         // Callback for stage touched signal handling
82         private void OnStageTouched(object sender, Stage.TouchEventArgs e)
83         {
84             // Only animate the _text label when touch down happens
85             if (e.Touch.GetState(0) == PointStateType.Down)
86             {
87                 // Create a new _animation
88                 if (_animation)
89                 {
90                     _animation.Reset();
91                 }
92
93                 _animation = new Animation(1000); // 1 second of duration
94
95                 _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), Vector3.XAxis), 0, 500);
96                 _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), Vector3.XAxis), 500, 1000);
97                 _animation.EndAction = Animation.EndActions.Discard;
98
99                 // Connect the signal callback for animaiton finished signal
100                 _animation.Finished += AnimationFinished;
101
102                 // Play the _animation
103                 _animation.Play();
104             }
105         }
106
107         /// <summary>
108         /// The main entry point for the application.
109         /// </summary>
110
111         [STAThread]
112         static void _Main(string[] args)
113         {
114             Console.WriteLine("Hello mono world.");
115             //Example example = new Example();
116             //Example example = new Example("stylesheet");
117             Example example = new Example("stylesheet", WindowMode.Transparent);
118             example.Run(args);
119         }
120     }
121 }