replace Console.WriteLine() with Tizen.Log.Debug()
[platform/core/csapi/tizenfx.git] / NUISamples / 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             InternalSetting.DefaultParentOriginAsTopLeft = false;
58             // Connect the signal callback for stage touched signal
59             _stage = Stage.Instance;
60             _stage.Touch += OnStageTouched;
61
62             // Add a _text label to the stage
63             _text = new TextLabel("Hello Mono World");
64             _text.ParentOrigin = ParentOrigin.Center;
65             _text.AnchorPoint = AnchorPoint.Center;
66             _text.HorizontalAlignment = "CENTER";
67             _text.PointSize = 32.0f;
68
69             _stage.GetDefaultLayer().Add(_text);
70         }
71
72         // Callback for _animation finished signal handling
73         private void AnimationFinished(object sender, EventArgs e)
74         {
75             if (_animation)
76             {
77                 Tizen.Log.Debug("NUI", "Duration= " + _animation.Duration);
78                 Tizen.Log.Debug("NUI", "EndAction= " + _animation.EndAction);
79             }
80         }
81
82         // Callback for stage touched signal handling
83         private void OnStageTouched(object sender, Stage.TouchEventArgs e)
84         {
85             // Only animate the _text label when touch down happens
86             if (e.Touch.GetState(0) == PointStateType.Down)
87             {
88                 // Create a new _animation
89                 if (_animation)
90                 {
91                     _animation.Reset();
92                 }
93
94                 _animation = new Animation(1000); // 1 second of duration
95
96                 _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), Vector3.XAxis), 0, 500);
97                 _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), Vector3.XAxis), 500, 1000);
98                 _animation.EndAction = Animation.EndActions.Discard;
99
100                 // Connect the signal callback for animaiton finished signal
101                 _animation.Finished += AnimationFinished;
102
103                 // Play the _animation
104                 _animation.Play();
105             }
106         }
107
108         /// <summary>
109         /// The main entry point for the application.
110         /// </summary>
111
112         [STAThread]
113         static void _Main(string[] args)
114         {
115             Tizen.Log.Debug("NUI", "Hello mono world.");
116             //Example example = new Example();
117             //Example example = new Example("stylesheet");
118             Example example = new Example("stylesheet", WindowMode.Transparent);
119             example.Run(args);
120         }
121     }
122 }