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