[NUI] Add an API for getting web view when request is intercepted.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Samples / Tizen.NUI.Samples / Samples / PropertyNotificationTest.cs
1 
2 using Tizen.NUI.BaseComponents;
3 using Tizen.NUI.Components;
4
5 namespace Tizen.NUI.Samples
6 {
7     public class PropertyNotificationTest : IExample
8     {
9         Window win;
10         int cnt;
11         TextLabel statusText;
12         global::System.Random rand = new global::System.Random();
13
14         public void Activate()
15         {
16             win = NUIApplication.GetDefaultWindow();
17             win.BackgroundColor = Color.Green;
18
19             statusText = new TextLabel()
20             {
21                 Size = new Size(300, 300),
22                 Position = new Position(300, 10),
23                 Text = "Status Text",
24                 PointSize = 12,
25                 BackgroundColor = Color.Cyan,
26                 MultiLine = true,
27                 Opacity = 0.6f,
28                 Name = "test text",
29             };
30
31             View view = new View()
32             {
33                 Size = new Size(100, 100),
34                 Position = new Position(10, 10),
35                 Color = Color.Yellow,
36                 BackgroundColor = Color.White,
37                 Name = "test view",
38             };
39
40             PropertyNotification propertyNotification = view.AddPropertyNotification("size", PropertyCondition.Step(1.0f));
41
42             propertyNotification.Notified += (object source, PropertyNotification.NotifyEventArgs args) =>
43             {
44                 View target = args.PropertyNotification.GetTarget() as View;
45                 if (target != null)
46                 {
47                     Tizen.Log.Error("NUI", $"Size changed! ({target.SizeWidth},{target.SizeHeight})");
48                     global::System.Console.WriteLine($"Size changed! ({target.SizeWidth},{target.SizeHeight})");
49                     statusText.Text = $"size changed! \n CurrentSize:({target.CurrentSize.Width},{target.CurrentSize.Height}) \n" +
50                         $" CurrentPosition:({target.CurrentPosition.X},{target.CurrentPosition.Y},{target.CurrentPosition.Z}) \n" +
51                         $" CurrentColor:({target.CurrentColor.R},{target.CurrentColor.G},{target.CurrentColor.B}) \n" +
52                         $" CurrentScale:({target.CurrentScale.X},{target.CurrentScale.Y},{target.CurrentScale.Z}) \n";
53                 }
54                 Tizen.Log.Error("NUI", "Size changed");
55             };
56
57             Button button = new Button()
58             {
59                 Size = new Size(200, 100),
60                 Position = new Position(200, 200),
61                 Text = "change size",
62                 Name = "test button",
63             };
64             button.Clicked += (object source, ClickedEventArgs args) =>
65             {
66                 view.Size += new Size(2, 2);
67                 view.Position += new Position(30, 30);
68                 view.Color += new Color(0.03f, 0.06f, 0.03f, 1f);
69                 view.Scale += new Vector3(0.3f, 0.2f, 0);
70             };
71
72             Button resetBtn = new Button()
73             {
74                 Size = new Size(200, 100),
75                 Position = new Position(200, 310),
76                 Text = "reset",
77                 Name = "reset button",
78             };
79             resetBtn.Clicked += (object source, ClickedEventArgs args) =>
80             {
81                 view.Size = new Size(rand.Next(50, 100), rand.Next(50, 100));
82                 view.Position = new Position(rand.Next(5, 10), rand.Next(5, 10));
83                 view.Color = new Color(rand.Next(5, 10) / 255.0f, rand.Next(5, 10) / 255.0f, rand.Next(5, 10) / 255.0f, 1);
84                 view.Scale = new Vector3(1, 1, 0);
85             };
86
87             win.GetDefaultLayer().Add(view);
88             win.GetDefaultLayer().Add(button);
89             win.GetDefaultLayer().Add(statusText);
90             win.GetDefaultLayer().Add(resetBtn);
91
92             view.SetColorMode(ColorMode.UseOwnColor);
93             view.LowerToBottom();
94             button.RaiseAbove(statusText);
95             resetBtn.RaiseAbove(statusText);
96         }
97
98         public void Deactivate()
99         {
100             win.GetDefaultLayer().FindChildByName("test view")?.Unparent();
101             win.GetDefaultLayer().FindChildByName("test button")?.Unparent();
102             win.GetDefaultLayer().FindChildByName("test text")?.Unparent();
103             win.GetDefaultLayer().FindChildByName("reset button")?.Unparent();
104         }
105     }
106 }