friend assembly, nuget lib test
[platform/core/csapi/nui.git] / NUISamples / NUISamples.TizenTV / examples / hello-world.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.ExtTEST;
22
23 namespace HelloWorldTest
24 {
25     class Example : NUIApplication
26     {
27         private Animation _animation;
28         private TextLabel _text;
29         private int cnt;
30         private View _view;
31
32         public Example() : base()
33         {
34         }
35
36         public Example(string stylesheet) : base(stylesheet)
37         {
38         }
39
40         public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
41         {
42         }
43
44         protected override void OnCreate()
45         {
46             base.OnCreate();
47             Initialize();
48         }
49
50         public void Initialize()
51         {
52             Stage stage = Stage.Instance;
53             stage.BackgroundColor = Color.White;
54             stage.Touch += OnStageTouched;
55             stage.Key += OnStageKeyEvent;
56
57             _text = new TextLabel("Hello NUI World");
58             _text.ParentOrigin = ParentOrigin.Center;
59             _text.AnchorPoint = AnchorPoint.Center;
60             _text.HorizontalAlignment = "CENTER";
61             _text.PointSize = 32.0f;
62             _text.TextColor = Color.Magenta;
63             stage.GetDefaultLayer().Add(_text);
64
65             _view = new View();
66             _view.Size = new Size(100, 100, 100);
67             _view.SizeWidth = 50;
68             Tizen.Log.Debug("NUI", "[1]_view SizeWidth=" + _view.SizeWidth);
69
70             _animation = new Animation
71             {
72                 Duration = 2000
73             };
74             _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.X), 0, 500);
75             _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.X), 500, 1000);
76             _animation.AnimateBy(_text, "ScaleX", 3.0f, 1000, 1500);
77             _animation.AnimateBy(_text, "ScaleY", 4.0f, 1500, 2000);
78             _animation.EndAction = Animation.EndActions.Discard;
79             _animation.Finished += AnimationFinished;
80
81             _view.SizeWidth = 50;
82             Tizen.Log.Debug("NUI", "[2]_view SizeWidth=" + _view.SizeWidth);
83
84             ActorEXT _actorExt = new ActorEXT();
85             Actor _actor1 = _actorExt.CreateActor();
86             if(_actor1) Tizen.Log.Debug("NUI", "FriendAssembly Test _actor1 name = " + _actor1.Name);
87             else Tizen.Log.Debug("NUI", "FriendAssembly Test _actor1 is NULL!");
88
89         }
90
91         public void AnimationFinished(object sender, EventArgs e)
92         {
93             Tizen.Log.Debug("NUI", "AnimationFinished()! cnt=" + (cnt));
94             if (_animation)
95             {
96                 Tizen.Log.Debug("NUI", "Duration= " + _animation.Duration + "EndAction= " + _animation.EndAction);
97             }
98             _view.SizeWidth = 50;
99             Tizen.Log.Debug("NUI", "[3]_view SizeWidth=" + _view.SizeWidth);
100         }
101
102         public void OnStageKeyEvent(object sender, Stage.KeyEventArgs e)
103         {
104             if (e.Key.State == Key.StateType.Down)
105             {
106                 if (e.Key.KeyPressedName == "Up")
107                 {
108                     if (_animation)
109                     {
110                         _animation.Finished += AnimationFinished;
111                         cnt++;
112                         Tizen.Log.Debug("NUI", "AnimationFinished added!");
113                     }
114                 }
115                 else if (e.Key.KeyPressedName == "Down")
116                 {
117                     if (_animation)
118                     {
119                         _animation.Finished -= AnimationFinished;
120                         cnt--;
121                         Tizen.Log.Debug("NUI", "AnimationFinished removed!");
122                     }
123                 }
124             }
125         }
126
127         public void OnStageTouched(object sender, Stage.TouchEventArgs e)
128         {
129             if (e.Touch.GetState(0) == PointStateType.Down)
130             {
131                 if (_animation)
132                 {
133                     //_animation.Stop(Dali.Constants.Animation.EndAction.Stop);
134                     //_animation.Reset();
135                 }
136                 _animation.Play();
137             }
138         }
139
140         [STAThread]
141         static void _Main(string[] args)
142         {
143             //Console.WriteLine("Main() called!");
144             Example example = new Example();
145             example.Run(args);
146         }
147     }
148 }