replace Console.WriteLine() with Tizen.Log.Debug()
[platform/core/csapi/tizenfx.git] / NUISamples / NUISamples / NUISamples.TizenTV / examples / relative-vector.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 RelativeVectorTest
30 {
31     class Example : NUIApplication
32     {
33         private Animation _animation;
34         private ImageView _imageView;
35         private Stage _stage;
36         private const string resources = "/home/owner/apps_rw/NUISamples.TizenTV/res";
37
38         public Example():base()
39         {
40         }
41
42         public Example(string stylesheet):base(stylesheet)
43         {
44         }
45
46         public Example(string stylesheet, WindowMode windowMode):base(stylesheet, windowMode)
47         {
48         }
49
50         protected override void OnCreate()
51         {
52             base.OnCreate();
53             Initialize();
54         }
55
56         private void Initialize()
57         {
58             // Connect the signal callback for stage touched signal
59             InternalSetting.DefaultParentOriginAsTopLeft = false;
60             _stage = Stage.Instance;
61             _stage.Touch += OnStageTouched;
62
63             _imageView = new ImageView();
64             _imageView.ResourceUrl = resources+"/images/gallery-3.jpg";
65             _imageView.ParentOrigin = ParentOrigin.Center;
66             _imageView.AnchorPoint = AnchorPoint.Center;
67             _imageView.PixelArea = new RelativeVector4(0.0f, 0.0f, 0.0f, 0.0f);
68
69             _stage.GetDefaultLayer().Add(_imageView);
70         }
71
72         // Callback for stage touched signal handling
73         private void OnStageTouched(object sender, Stage.TouchEventArgs e)
74         {
75             // Only animate the _text label when touch down happens
76             if (e.Touch.GetState(0) == PointStateType.Down)
77             {
78                 // Create a new _animation
79                 if (_animation)
80                 {
81                     _animation.Reset();
82                 }
83
84                 _animation = new Animation(1000); // 1 second of duration
85                  _animation.AnimateTo(_imageView, "PixelArea", new RelativeVector4(0.0f, 0.0f, 1.0f, 1.0f), 0, 1000);
86                 _animation.EndAction = Animation.EndActions.Discard;
87                 _animation.PlayRange = new RelativeVector2(0.2f, 0.8f);
88
89                 // Play the _animation
90                 _animation.Play();
91             }
92         }
93
94         /// <summary>
95         /// The main entry point for the application.
96         /// </summary>
97
98         [STAThread]
99         static void _Main(string[] args)
100         {
101             Tizen.Log.Debug("NUI", "Hello mono world.");
102             Example example = new Example("stylesheet", WindowMode.Transparent);
103             example.Run(args);
104         }
105     }
106 }