[Tizen] temporal API to make users use Container class
[platform/core/csapi/nui.git] / NUISamples / NUISamples / NUISamples.Tizen / examples / relative-vector.cs
1 /*
2  * Copyright (c) 2017 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.BaseComponents;
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 RelativeVectorTest
32 {
33     class Example : NUIApplication
34     {
35         private Animation _animation;
36         private ImageView _imageView;
37         private Window _window;
38         private const string resources = "/home/owner/apps_rw/NUISamples.TizenTV/res";
39
40         public Example():base()
41         {
42         }
43
44         public Example(string stylesheet):base(stylesheet)
45         {
46         }
47
48         public Example(string stylesheet, WindowMode windowMode):base(stylesheet, windowMode)
49         {
50         }
51
52         protected override void OnCreate()
53         {
54             base.OnCreate();
55             Initialize();
56         }
57
58         private void Initialize()
59         {
60             _window = Window.Instance;
61             _window.TouchEvent += OnWindowTouched;
62
63             _imageView = new ImageView();
64             _imageView.ResourceUrl = resources+"/images/gallery-3.jpg";
65             _imageView.ParentOrigin = ParentOrigin.Center;
66             _imageView.PivotPoint = PivotPoint.Center;
67             _imageView.PixelArea = new RelativeVector4(0.0f, 0.0f, 0.0f, 0.0f);
68
69             _window.Add(_imageView);
70         }
71
72         // Callback for window touched signal handling
73         private void OnWindowTouched(object sender, Window.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 }