2 using Tizen.NUI.BaseComponents;
3 using Tizen.NUI.Components;
5 namespace Tizen.NUI.Samples
7 public class PropertyNotificationTest : IExample
12 global::System.Random rand = new global::System.Random();
14 public void Activate()
16 win = NUIApplication.GetDefaultWindow();
17 win.BackgroundColor = Color.Green;
19 statusText = new TextLabel()
21 Size = new Size(300, 300),
22 Position = new Position(300, 10),
25 BackgroundColor = Color.Cyan,
31 View view = new View()
33 Size = new Size(100, 100),
34 Position = new Position(10, 10),
36 BackgroundColor = Color.White,
40 PropertyNotification propertyNotification = view.AddPropertyNotification("size", PropertyCondition.Step(1.0f));
42 propertyNotification.Notified += (object source, PropertyNotification.NotifyEventArgs args) =>
44 View target = args.PropertyNotification.GetTarget() as View;
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";
54 Tizen.Log.Error("NUI", "Size changed");
57 Button button = new Button()
59 Size = new Size(200, 100),
60 Position = new Position(200, 200),
64 button.Clicked += (object source, ClickedEventArgs args) =>
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);
72 Button resetBtn = new Button()
74 Size = new Size(200, 100),
75 Position = new Position(200, 310),
77 Name = "reset button",
79 resetBtn.Clicked += (object source, ClickedEventArgs args) =>
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);
87 win.GetDefaultLayer().Add(view);
88 win.GetDefaultLayer().Add(button);
89 win.GetDefaultLayer().Add(statusText);
90 win.GetDefaultLayer().Add(resetBtn);
92 view.SetColorMode(ColorMode.UseOwnColor);
94 button.RaiseAbove(statusText);
95 resetBtn.RaiseAbove(statusText);
98 public void Deactivate()
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();