4 using Tizen.NUI.BaseComponents;
6 using System.Collections.Generic;
9 namespace Tizen.NUI.Samples
11 using log = Tizen.Log;
12 public class WindowTest : IExample
14 string tag = "NUITEST";
24 private const string KEY_NUM_1 = "1";
25 private const string KEY_NUM_2 = "2";
26 private const string KEY_NUM_3 = "3";
27 private const string KEY_NUM_4 = "4";
28 private const string KEY_NUM_5 = "5";
29 private const string KEY_NUM_6 = "6";
30 private const string KEY_NUM_7 = "7";
31 private const string KEY_NUM_8 = "8";
32 private const string KEY_NUM_9 = "9";
33 private const string KEY_NUM_0 = "0";
38 mainWin = NUIApplication.GetDefaultWindow();
39 mainWin.KeyEvent += OnKeyEvent;
40 mainWin.TouchEvent += WinTouchEvent;
41 mainWin.BackgroundColor = Color.Cyan;
43 Information.TryGetValue<int>("http://tizen.org/feature/screen.width", out screenWidth);
44 Information.TryGetValue<int>("http://tizen.org/feature/screen.height", out screenHeight);
45 log.Fatal(tag, $"Initialize= screenWidth {screenWidth}, screenHeight {screenHeight} ");
46 Rectangle inputRegion = new Rectangle(0,0,screenWidth,screenHeight/2);
47 mainWin.IncludeInputRegion(inputRegion);
51 TextLabel text = new TextLabel("NUI Window Test");
52 text.HorizontalAlignment = HorizontalAlignment.Center;
53 text.VerticalAlignment = VerticalAlignment.Center;
54 text.TextColor = Color.Blue;
55 text.PointSize = 12.0f;
56 text.HeightResizePolicy = ResizePolicyType.FillToParent;
57 text.WidthResizePolicy = ResizePolicyType.FillToParent;
60 List<Window.WindowOrientation> list = new List<Window.WindowOrientation>();
62 list.Add(Window.WindowOrientation.Landscape);
63 list.Add(Window.WindowOrientation.LandscapeInverse);
64 list.Add(Window.WindowOrientation.NoOrientationPreference);
65 list.Add(Window.WindowOrientation.Portrait);
66 list.Add(Window.WindowOrientation.PortraitInverse);
68 mainWin.SetAvailableOrientations(list);
70 Animation animation = new Animation(2000);
71 animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.X), 0, 500);
72 animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.X), 500, 1000);
73 animation.Looping = true;
76 manualRotation = false;
84 private bool Tm_Tick(object source, Timer.TickEventArgs e)
86 bool rotating = mainWin.IsWindowRotating();
87 log.Fatal(tag, $"window is Rotating: {rotating}");
88 if(rotating && manualRotation)
91 if(rotationCount > 100)
93 log.Fatal(tag, $"call SendRotationCompletedAcknowledgement");
94 mainWin.SendRotationCompletedAcknowledgement();
101 private void WinTouchEvent(object sender, Window.TouchEventArgs e)
103 if (e.Touch.GetState(0) == PointStateType.Down)
105 Vector2 touchpoint = e.Touch.GetScreenPosition(0);
106 log.Fatal(tag, $"WinTouchEvent={touchpoint.X}, {touchpoint.Y}");
110 if(touchpoint.Y > (screenHeight/2 - 50))
112 int yPostion = screenHeight/2 + 1;
113 int height = screenHeight/2;
114 log.Fatal(tag, $"WinTouchEvent= Include {xPosition},{yPostion} {screenWidth}x{height} ");
115 mainWin.IncludeInputRegion(new Rectangle(xPosition,yPostion,screenWidth,height));
121 if(touchpoint.Y > (screenHeight - 50))
123 int yPostion = screenHeight/2 + 1;
124 int height = screenHeight/2;
125 log.Fatal(tag, $"WinTouchEvent= Exclude {xPosition},{yPostion} {screenWidth}x{height} ");
126 mainWin.ExcludeInputRegion(new Rectangle(xPosition, yPostion, screenWidth, height));
133 public void OnKeyEvent(object sender, Window.KeyEventArgs e)
135 if (e.Key.State == Key.StateType.Down)
137 log.Fatal(tag, $"key down! key={e.Key.KeyPressedName}");
139 switch (e.Key.KeyPressedName)
147 log.Fatal(tag, $"pressed Key Num 1!");
151 mainWin.Maximize(true);
155 if(mainWin.IsMaximized())
157 mainWin.Maximize(false);
161 mainWin.SetMaximumSize(new Size2D(700, 700));
164 mainWin.SetMimimumSize(new Size2D(100, 100));
167 if(manualRotation == false)
169 manualRotation = true;
170 log.Fatal(tag, $"Enable manual rotation");
174 manualRotation = false;
175 log.Fatal(tag, $"Disable manual rotation");
177 mainWin.SetNeedsRotationCompletedAcknowledgement(manualRotation);
180 mainWin.SetMimimumSize(new Size2D(100, 100));
183 if(mainWin.GetFullScreen() == false)
185 mainWin.SetFullScreen(true);
189 mainWin.SetFullScreen(false);
194 log.Fatal(tag, $"no test!");
200 public void Activate() { Initialize(); }
201 public void Deactivate() { }