[NUI] Change for Size2D property to own internalSize2D which is cashed to prevent...
[platform/core/csapi/tizenfx.git] / test / NUITizenGallery / Examples / SwipeViewTest / SwipeViewTest1Page.xaml.cs
1 using Tizen.NUI;
2 using Tizen.NUI.BaseComponents;
3 using Tizen.NUI.Components;
4
5 namespace NUITizenGallery
6 {
7     public partial class SwipeViewTest1Page : ContentPage
8     {
9         private PanGestureDetector panGestureDetector;
10         private Direction swipeDirection = Direction.Vertical;
11         private Position initPosition;
12         private int swipeCount;
13
14         public enum Direction
15         {
16             Horizontal,
17             Vertical
18         }
19
20         public SwipeViewTest1Page()
21         {
22             InitializeComponent();
23
24             swipeCount = 0;
25
26             imageView.Scale = imageView.Scale * new Vector3(1.2f, 1.2f, 1.0f);
27
28             initPosition = imageView.Position;
29
30             ContentView.Padding = new Extents(20, 20, 20, 20);
31
32             panGestureDetector = new PanGestureDetector();
33             panGestureDetector.Attach(imageView);
34             panGestureDetector.Detected += (obj, e) =>
35             {
36                 Vector2 velocity = e.PanGesture.Velocity;
37                 if (e.PanGesture.State == Gesture.StateType.Started)
38                 {
39                     if (velocity.X != 0 )
40                     {
41                         swipeDirection = Direction.Horizontal;
42                         if (velocity.X > 0) {
43                             image1.Size = new Size(100, 100);
44                         }
45                         else
46                         {
47                             image2.Size = new Size(100, 100);
48                         }
49                     }
50                     else if (velocity.Y != 0)
51                     {
52                         swipeDirection = Direction.Vertical;
53
54                         swipeCount++;
55                         if ((swipeCount % 2) > 0)
56                         {
57                             imageView.BorderlineWidth = 5f;
58                             imageView.BorderlineColor = Color.Green;
59                         }
60                         else
61                         {
62                             imageView.BorderlineWidth = 0f;
63                         }
64
65                         text2.Text = "Item";
66                         text3.Text = "Item";
67
68                     }
69                 }
70                 else if (e.PanGesture.State == Gesture.StateType.Continuing)
71                 {
72                     if (swipeDirection == Direction.Vertical && imageView.Position.Y < 70 && imageView.Position.Y > -70)
73                     {
74                         imageView.Position += new Position(0, e.PanGesture.ScreenDisplacement.Y, 0);
75                     }
76                     else if (swipeDirection == Direction.Horizontal && imageView.Position.X < 70 && imageView.Position.X > -70)
77                     {
78                         imageView.Position += new Position(e.PanGesture.ScreenDisplacement.X, 0, 0);
79                     }
80                 }
81                 else if (e.PanGesture.State == Gesture.StateType.Finished || e.PanGesture.State == Gesture.StateType.Cancelled)
82                 {
83                     imageView.Position = initPosition;
84
85                     image1.Size = new Size(0, 0);
86                     image2.Size = new Size(0, 0);
87
88                     text2.Text = "";
89                     text3.Text = "";
90                 }
91
92             };
93
94         }
95     }
96 }