[NUI] Add InterceptTouchEvent (#2098)
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Seamless / NUISimpleCaller / NUISimpleCaller.cs
1 using System;
2 using Tizen.NUI;
3 using Tizen.NUI.BaseComponents;
4 using Tizen.Applications;
5
6 namespace NUISimpleCaller
7 {
8     class Program : NUIApplication
9     {
10         protected override void OnCreate()
11         {
12             base.OnCreate();
13             Initialize();
14         }
15
16         void Initialize()
17         {
18             Window.Instance.KeyEvent += OnKeyEvent;
19             Window.Instance.TouchEvent += OnTouchEvent;
20
21             TextLabel text = new TextLabel("NUI Simple Caller Sample");
22             text.HorizontalAlignment = HorizontalAlignment.Center;
23             text.VerticalAlignment = VerticalAlignment.Center;
24             text.TextColor = Color.Blue;
25             text.PointSize = 12.0f;
26             text.HeightResizePolicy = ResizePolicyType.FillToParent;
27             text.WidthResizePolicy = ResizePolicyType.FillToParent;
28             Window.Instance.GetDefaultLayer().Add(text);
29
30
31             TransitionOptions = new TransitionOptions(GetDefaultWindow());
32             TransitionOptions.EnableTransition = true;
33             TransitionOptions.ForwardAnimation = new SlideIn(300);
34             TransitionOptions.BackwardAnimation = new SlideOut(300);
35
36             ////TransitionOptions.AnimationStart += TransitionOptions_AnimationStart;
37             ////TransitionOptions.AnimationFinished += TransitionOptions_AnimationFinished;
38         }
39
40         private void TransitionOptions_AnimationFinished()
41         {
42             Tizen.Log.Error("MYLOG", "Finish Animation");
43         }
44
45         private void TransitionOptions_AnimationStart()
46         {
47             Tizen.Log.Error("MYLOG", "Start Animation");
48         }
49
50         private void OnTouchEvent(object sender, Window.TouchEventArgs e)
51         {
52             if (e.Touch.GetState(0) == PointStateType.Up)
53             {
54                 AppControl appControl = new AppControl();
55                 appControl.ApplicationId = "org.tizen.example.NUISimpleCallee";
56                 SendLaunchRequest(appControl);
57             }
58         }
59
60         public void OnKeyEvent(object sender, Window.KeyEventArgs e)
61         {
62             if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))
63             {
64                 Exit();
65             }
66         }
67
68         static void Main(string[] args)
69         {
70             var app = new Program();
71             app.Run(args);
72         }
73     }
74 }