2 using System.Runtime.CompilerServices;
3 using System.Threading.Tasks;
4 using Tizen.Applications.ComponentBased.Common;
6 using Tizen.NUI.BaseComponents;
7 using Tizen.NUI.Components;
8 using Tizen.NUI.WindowSystem;
10 namespace Tizen.NUI.WindowSystem.Samples
12 class Program : NUIApplication
14 Shell.TizenShell tzShell;
15 Shell.QuickPanelClient qpClient;
17 TextLabel textClientVisible;
18 TextLabel textClientScrollable;
19 TextLabel textClientOrientation;
21 Shell.QuickPanelService qpService;
22 Shell.TizenRegion qpRegion;
26 Shell.SoftkeyClient softkeyClient;
27 Button BtnSoftkeyClient;
28 TextLabel textSoftkeyClientVisible;
29 TextLabel textSoftkeyClientExpand;
30 TextLabel textSoftkeyClientOpacity;
32 Shell.SoftkeyService softkeyService;
33 Button BtnSoftkeyService;
34 TextLabel textSoftkeyServiceVisible;
35 TextLabel textSoftkeyServiceExpand;
36 TextLabel textSoftkeyServiceOpacity;
38 protected override void OnCreate()
46 Window window = NUIApplication.GetDefaultWindow();
47 window.KeyEvent += OnKeyEvent;
48 window.BackgroundColor = Color.White;
50 BtnClient = new Button()
52 Text = "QuickPanelClient",
53 Size = new Size(400, 100),
54 Position = new Position(100, 200),
58 BtnService = new Button()
60 Text = "QuickPanelService",
61 Size = new Size(400, 100),
62 Position = new Position(100, 400),
66 BtnSoftkeyClient = new Button()
68 Text = "SoftkeyClient",
69 Size = new Size(400, 100),
70 Position = new Position(100, 600),
74 BtnSoftkeyService = new Button()
76 Text = "SoftkeyService",
77 Size = new Size(400, 100),
78 Position = new Position(100, 800),
82 window.Add(BtnClient);
83 window.Add(BtnService);
84 window.Add(BtnSoftkeyClient);
85 window.Add(BtnSoftkeyService);
87 BtnClient.ClickEvent += BtnClient_ClickEvent;
88 BtnService.ClickEvent += BtnService_ClickEvent;
89 BtnSoftkeyClient.ClickEvent += BtnSoftkeyClient_ClickEvent;
90 BtnSoftkeyService.ClickEvent += BtnSoftkeyService_ClickEvent;
92 tzShell = new Shell.TizenShell();
94 window.AddAvailableOrientation(Window.WindowOrientation.Portrait);
95 window.AddAvailableOrientation(Window.WindowOrientation.Landscape);
96 window.AddAvailableOrientation(Window.WindowOrientation.PortraitInverse);
97 window.AddAvailableOrientation(Window.WindowOrientation.LandscapeInverse);
100 public void OnKeyEvent(object sender, Window.KeyEventArgs e)
102 if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))
108 public void OnVisibleEvent(object sender, Shell.QuickPanelClient.VisibleState state)
110 textClientVisible.Text = $"Visible: {qpClient.Visible}";
113 public void OnOrientationEvent(object sender, Window.WindowOrientation state)
115 textClientOrientation.Text = $"Orientation: {qpClient.Orientation}";
118 private void BtnClient_ClickEvent(object sender, Button.ClickEventArgs e)
120 Window window = NUIApplication.GetDefaultWindow();
122 window.Remove(BtnService);
123 window.Remove(BtnClient);
124 window.Remove(BtnSoftkeyService);
125 window.Remove(BtnSoftkeyClient);
126 qpClient = new Shell.QuickPanelClient(tzShell, window, Shell.QuickPanelClient.Types.SystemDefault);
128 qpClient.VisibleChanged += OnVisibleEvent;
129 qpClient.OrientationChanged += OnOrientationEvent;
131 textClientVisible = new TextLabel($"Visible: {qpClient.Visible}");
132 textClientVisible.Position = new Position(0, -100);
133 textClientVisible.HorizontalAlignment = HorizontalAlignment.Center;
134 textClientVisible.VerticalAlignment = VerticalAlignment.Center;
135 textClientVisible.TextColor = Color.Blue;
136 textClientVisible.PointSize = 12.0f;
137 textClientVisible.HeightResizePolicy = ResizePolicyType.FillToParent;
138 textClientVisible.WidthResizePolicy = ResizePolicyType.FillToParent;
139 window.Add(textClientVisible);
141 textClientScrollable = new TextLabel($"Scrollable: {qpClient.Scrollable}");
142 textClientScrollable.HorizontalAlignment = HorizontalAlignment.Center;
143 textClientScrollable.VerticalAlignment = VerticalAlignment.Center;
144 textClientScrollable.TextColor = Color.Blue;
145 textClientScrollable.PointSize = 12.0f;
146 textClientScrollable.HeightResizePolicy = ResizePolicyType.FillToParent;
147 textClientScrollable.WidthResizePolicy = ResizePolicyType.FillToParent;
148 window.Add(textClientScrollable);
150 textClientOrientation = new TextLabel($"Orientation: {qpClient.Orientation}");
151 textClientOrientation.Position = new Position(0, 100);
152 textClientOrientation.HorizontalAlignment = HorizontalAlignment.Center;
153 textClientOrientation.VerticalAlignment = VerticalAlignment.Center;
154 textClientOrientation.TextColor = Color.Blue;
155 textClientOrientation.PointSize = 12.0f;
156 textClientOrientation.HeightResizePolicy = ResizePolicyType.FillToParent;
157 textClientOrientation.WidthResizePolicy = ResizePolicyType.FillToParent;
158 window.Add(textClientOrientation);
160 Button BtnScrollableSet = new Button()
162 Text = "Scrollable Set",
163 Size = new Size(400, 100),
164 Position = new Position(50, 800),
167 Button BtnScrollableUnset = new Button()
169 Text = "Scrollable Unset",
170 Size = new Size(400, 100),
171 Position = new Position(50, 920),
174 Button BtnScrollableRetain = new Button()
176 Text = "Scrollable Retain",
177 Size = new Size(400, 100),
178 Position = new Position(50, 1040),
181 Button BtnShow = new Button()
184 Size = new Size(200, 100),
185 Position = new Position(470, 850),
188 Button BtnHide = new Button()
191 Size = new Size(200, 100),
192 Position = new Position(470, 990),
196 BtnScrollableSet.ClickEvent += BtnScrollableSet_ClickEvent;
197 BtnScrollableUnset.ClickEvent += BtnScrollableUnset_ClickEvent;
198 BtnScrollableRetain.ClickEvent += BtnScrollableRetain_ClickEvent;
199 BtnShow.ClickEvent += BtnClientShow_ClickEvent;
200 BtnHide.ClickEvent += BtnClientHide_ClickEvent;
202 window.Add(BtnScrollableSet);
203 window.Add(BtnScrollableUnset);
204 window.Add(BtnScrollableRetain);
209 private void BtnScrollableSet_ClickEvent(object sender, Button.ClickEventArgs e)
211 qpClient.Scrollable = Shell.QuickPanelClient.ScrollableState.Set;
212 textClientScrollable.Text = $"Scrollable: {qpClient.Scrollable}";
214 private void BtnScrollableUnset_ClickEvent(object sender, Button.ClickEventArgs e)
216 qpClient.Scrollable = Shell.QuickPanelClient.ScrollableState.Unset;
217 textClientScrollable.Text = $"Scrollable: {qpClient.Scrollable}";
219 private void BtnScrollableRetain_ClickEvent(object sender, Button.ClickEventArgs e)
221 qpClient.Scrollable = Shell.QuickPanelClient.ScrollableState.Retain;
222 textClientScrollable.Text = $"Scrollable: {qpClient.Scrollable}";
224 private void BtnClientShow_ClickEvent(object sender, Button.ClickEventArgs e)
228 private void BtnClientHide_ClickEvent(object sender, Button.ClickEventArgs e)
233 private void BtnService_ClickEvent(object sender, Button.ClickEventArgs e)
235 Window window = NUIApplication.GetDefaultWindow();
236 Shell.QuickPanelService.Types type = Shell.QuickPanelService.Types.AppsMenu;
238 window.Remove(BtnService);
239 window.Remove(BtnClient);
240 window.Remove(BtnSoftkeyService);
241 window.Remove(BtnSoftkeyClient);
242 qpService = new Shell.QuickPanelService(tzShell, window, type);
243 //if ((type == Shell.QuickPanelService.Types.ContextMenu) || (type == Shell.QuickPanelService.Types.AppsMenu))
244 //window.AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
246 TextLabel textServiceType = new TextLabel($"Type: {qpService.ServiceType}");
247 textServiceType.Position = new Position(0, -300);
248 textServiceType.HorizontalAlignment = HorizontalAlignment.Center;
249 textServiceType.VerticalAlignment = VerticalAlignment.Center;
250 textServiceType.TextColor = Color.Blue;
251 textServiceType.PointSize = 12.0f;
252 textServiceType.HeightResizePolicy = ResizePolicyType.FillToParent;
253 textServiceType.WidthResizePolicy = ResizePolicyType.FillToParent;
254 window.Add(textServiceType);
256 Button BtnShow = new Button()
259 Size = new Size(200, 100),
260 Position = new Position(50, 500),
263 Button BtnHide = new Button()
266 Size = new Size(200, 100),
267 Position = new Position(410, 500),
271 Button BtnEffectSwipe = new Button()
273 Text = "EffectSwipe",
274 Size = new Size(400, 80),
275 Position = new Position(50, 700),
278 Button BtnEffectMove = new Button()
281 Size = new Size(400, 80),
282 Position = new Position(50, 800),
285 Button BtnEffectAppCustom = new Button()
287 Text = "EffectAppCustom",
288 Size = new Size(400, 80),
289 Position = new Position(50, 900),
293 Button BtnLockTrue = new Button()
296 Size = new Size(300, 80),
297 Position = new Position(50, 1000),
300 Button BtnLockFalse = new Button()
303 Size = new Size(300, 80),
304 Position = new Position(400, 1000),
307 Button BtnTimerStop = new Button()
310 Size = new Size(300, 80),
311 Position = new Position(50, 50),
315 BtnShow.ClickEvent += BtnServiceShow_ClickEvent;
316 BtnHide.ClickEvent += BtnServiceHide_ClickEvent;
318 BtnEffectSwipe.ClickEvent += BtnEffectSwipe_ClickEvent;
319 BtnEffectMove.ClickEvent += BtnEffectMove_ClickEvent;
320 BtnEffectAppCustom.ClickEvent += BtnEffectAppCustom_ClickEvent;
322 BtnLockTrue.ClickEvent += BtnLockTrue_ClickEvent;
323 BtnLockFalse.ClickEvent += BtnLockFalse_ClickEvent;
325 BtnTimerStop.ClickEvent += BtnTimerStop_ClickEvent;
330 window.Add(BtnEffectSwipe);
331 window.Add(BtnEffectMove);
332 window.Add(BtnEffectAppCustom);
334 window.Add(BtnLockTrue);
335 window.Add(BtnLockFalse);
337 window.Add(BtnTimerStop);
339 qpRegion = new Shell.TizenRegion(tzShell);
340 qpRegion.Add(window.WindowPosition.X, window.WindowPosition.Y, window.WindowSize.Width, window.WindowSize.Height - 50);
341 qpService.SetContentRegion(0, qpRegion);
344 qpRegion = new Shell.TizenRegion(tzShell);
345 qpRegion.Add(window.WindowPosition.X, window.WindowPosition.Y + window.WindowSize.Height - 50, window.WindowSize.Width, 50);
346 qpService.SetHandlerRegion(0, qpRegion);
349 _timer = new Timer(2000);
350 _timer.Tick += Timer_Tick;
356 private bool Timer_Tick(object source, Timer.TickEventArgs e)
371 private void BtnServiceShow_ClickEvent(object sender, Button.ClickEventArgs e)
375 private void BtnServiceHide_ClickEvent(object sender, Button.ClickEventArgs e)
380 private void BtnEffectSwipe_ClickEvent(object sender, Button.ClickEventArgs e)
382 qpService.SetEffectType(Shell.QuickPanelService.EffectType.Swipe);
384 private void BtnEffectMove_ClickEvent(object sender, Button.ClickEventArgs e)
386 qpService.SetEffectType(Shell.QuickPanelService.EffectType.Move);
388 private void BtnEffectAppCustom_ClickEvent(object sender, Button.ClickEventArgs e)
390 qpService.SetEffectType(Shell.QuickPanelService.EffectType.Custom);
392 private void BtnLockTrue_ClickEvent(object sender, Button.ClickEventArgs e)
394 qpService.LockScroll(true);
396 private void BtnLockFalse_ClickEvent(object sender, Button.ClickEventArgs e)
398 qpService.LockScroll(false);
400 private void BtnTimerStop_ClickEvent(object sender, Button.ClickEventArgs e)
405 private void BtnSoftkeyClient_ClickEvent(object sender, Button.ClickEventArgs e)
407 Window window = NUIApplication.GetDefaultWindow();
409 window.Remove(BtnService);
410 window.Remove(BtnClient);
411 window.Remove(BtnSoftkeyService);
412 window.Remove(BtnSoftkeyClient);
413 softkeyClient = new Shell.SoftkeyClient(tzShell, window);
415 textSoftkeyClientVisible = new TextLabel($"Visible: {softkeyClient.Visible}");
416 textSoftkeyClientVisible.Position = new Position(0, -100);
417 textSoftkeyClientVisible.HorizontalAlignment = HorizontalAlignment.Center;
418 textSoftkeyClientVisible.VerticalAlignment = VerticalAlignment.Center;
419 textSoftkeyClientVisible.TextColor = Color.Blue;
420 textSoftkeyClientVisible.PointSize = 12.0f;
421 textSoftkeyClientVisible.HeightResizePolicy = ResizePolicyType.FillToParent;
422 textSoftkeyClientVisible.WidthResizePolicy = ResizePolicyType.FillToParent;
423 window.Add(textSoftkeyClientVisible);
425 textSoftkeyClientExpand = new TextLabel($"Expand: {softkeyClient.Expand}");
426 textSoftkeyClientExpand.Position = new Position(0, 0);
427 textSoftkeyClientExpand.HorizontalAlignment = HorizontalAlignment.Center;
428 textSoftkeyClientExpand.VerticalAlignment = VerticalAlignment.Center;
429 textSoftkeyClientExpand.TextColor = Color.Blue;
430 textSoftkeyClientExpand.PointSize = 12.0f;
431 textSoftkeyClientExpand.HeightResizePolicy = ResizePolicyType.FillToParent;
432 textSoftkeyClientExpand.WidthResizePolicy = ResizePolicyType.FillToParent;
433 window.Add(textSoftkeyClientExpand);
435 textSoftkeyClientOpacity = new TextLabel($"Opacity: {softkeyClient.Opacity}");
436 textSoftkeyClientOpacity.Position = new Position(0, 100);
437 textSoftkeyClientOpacity.HorizontalAlignment = HorizontalAlignment.Center;
438 textSoftkeyClientOpacity.VerticalAlignment = VerticalAlignment.Center;
439 textSoftkeyClientOpacity.TextColor = Color.Blue;
440 textSoftkeyClientOpacity.PointSize = 12.0f;
441 textSoftkeyClientOpacity.HeightResizePolicy = ResizePolicyType.FillToParent;
442 textSoftkeyClientOpacity.WidthResizePolicy = ResizePolicyType.FillToParent;
443 window.Add(textSoftkeyClientOpacity);
445 Button BtnExpandSetOn = new Button()
448 Size = new Size(300, 100),
449 Position = new Position(50, 800),
452 Button BtnExpandSetOff = new Button()
455 Size = new Size(300, 100),
456 Position = new Position(400, 800),
459 Button BtnOpacitySetOpaque = new Button()
461 Text = "Opacity Opaque",
462 Size = new Size(300, 100),
463 Position = new Position(50, 1000),
466 Button BtnOpacitySetTransparent = new Button()
468 Text = "Opacity Transparent",
469 Size = new Size(300, 100),
470 Position = new Position(400, 1000),
473 Button BtnShow = new Button()
476 Size = new Size(200, 100),
477 Position = new Position(50, 1100),
480 Button BtnHide = new Button()
483 Size = new Size(200, 100),
484 Position = new Position(410, 1100),
488 BtnExpandSetOn.ClickEvent += BtnExpandSetOn_ClickEvent;
489 BtnExpandSetOff.ClickEvent += BtnExpandSetOff_ClickEvent;
490 BtnOpacitySetOpaque.ClickEvent += BtnOpacitySetOpaque_ClickEvent;
491 BtnOpacitySetTransparent.ClickEvent += BtnOpacitySetTransparent_ClickEvent;
492 BtnShow.ClickEvent += BtnSoftkeyClientShow_ClickEvent;
493 BtnHide.ClickEvent += BtnSoftkeyClientHide_ClickEvent;
495 window.Add(BtnExpandSetOn);
496 window.Add(BtnExpandSetOff);
497 window.Add(BtnOpacitySetOpaque);
498 window.Add(BtnOpacitySetTransparent);
503 private void BtnExpandSetOn_ClickEvent(object sender, Button.ClickEventArgs e)
505 softkeyClient.Expand = Shell.SoftkeyExpandState.On;
506 textSoftkeyClientExpand.Text = $"Expand: {softkeyClient.Expand}";
509 private void BtnExpandSetOff_ClickEvent(object sender, Button.ClickEventArgs e)
511 softkeyClient.Expand = Shell.SoftkeyExpandState.Off;
512 textSoftkeyClientExpand.Text = $"Expand: {softkeyClient.Expand}";
515 private void BtnOpacitySetOpaque_ClickEvent(object sender, Button.ClickEventArgs e)
517 softkeyClient.Opacity = Shell.SoftkeyOpacityState.Opaque;
518 textSoftkeyClientOpacity.Text = $"Opacity: {softkeyClient.Opacity}";
521 private void BtnOpacitySetTransparent_ClickEvent(object sender, Button.ClickEventArgs e)
523 softkeyClient.Opacity = Shell.SoftkeyOpacityState.Transparent;
524 textSoftkeyClientOpacity.Text = $"Opacity: {softkeyClient.Opacity}";
527 private async Task ControlSoftKeyVisible(bool visible)
530 softkeyClient.Show();
532 softkeyClient.Hide();
533 await Task.Delay(50);
534 textSoftkeyClientVisible.Text = $"Visible: {softkeyClient.Visible}";
537 private void BtnSoftkeyClientShow_ClickEvent(object sender, Button.ClickEventArgs e)
539 _ = ControlSoftKeyVisible(true);
542 private void BtnSoftkeyClientHide_ClickEvent(object sender, Button.ClickEventArgs e)
544 _ = ControlSoftKeyVisible(false);
547 private void BtnSoftkeyService_ClickEvent(object sender, Button.ClickEventArgs e)
549 Window window = NUIApplication.GetDefaultWindow();
550 window.WindowSize = new Size(500, 500);
551 window.WindowPosition = new Position(0, 700);
553 window.Remove(BtnService);
554 window.Remove(BtnClient);
555 window.Remove(BtnSoftkeyService);
556 window.Remove(BtnSoftkeyClient);
557 softkeyService = new Shell.SoftkeyService(tzShell, window);
559 textSoftkeyServiceVisible = new TextLabel($"Visible: None");
560 textSoftkeyServiceVisible.Position = new Position(0, -100);
561 textSoftkeyServiceVisible.HorizontalAlignment = HorizontalAlignment.Center;
562 textSoftkeyServiceVisible.VerticalAlignment = VerticalAlignment.Center;
563 textSoftkeyServiceVisible.TextColor = Color.Blue;
564 textSoftkeyServiceVisible.PointSize = 12.0f;
565 textSoftkeyServiceVisible.HeightResizePolicy = ResizePolicyType.FillToParent;
566 textSoftkeyServiceVisible.WidthResizePolicy = ResizePolicyType.FillToParent;
567 window.Add(textSoftkeyServiceVisible);
569 textSoftkeyServiceExpand = new TextLabel($"Expand: None");
570 textSoftkeyServiceExpand.Position = new Position(0, 0);
571 textSoftkeyServiceExpand.HorizontalAlignment = HorizontalAlignment.Center;
572 textSoftkeyServiceExpand.VerticalAlignment = VerticalAlignment.Center;
573 textSoftkeyServiceExpand.TextColor = Color.Blue;
574 textSoftkeyServiceExpand.PointSize = 12.0f;
575 textSoftkeyServiceExpand.HeightResizePolicy = ResizePolicyType.FillToParent;
576 textSoftkeyServiceExpand.WidthResizePolicy = ResizePolicyType.FillToParent;
577 window.Add(textSoftkeyServiceExpand);
579 textSoftkeyServiceOpacity = new TextLabel($"Opacity: None");
580 textSoftkeyServiceOpacity.Position = new Position(0, 100);
581 textSoftkeyServiceOpacity.HorizontalAlignment = HorizontalAlignment.Center;
582 textSoftkeyServiceOpacity.VerticalAlignment = VerticalAlignment.Center;
583 textSoftkeyServiceOpacity.TextColor = Color.Blue;
584 textSoftkeyServiceOpacity.PointSize = 12.0f;
585 textSoftkeyServiceOpacity.HeightResizePolicy = ResizePolicyType.FillToParent;
586 textSoftkeyServiceOpacity.WidthResizePolicy = ResizePolicyType.FillToParent;
587 window.Add(textSoftkeyServiceOpacity);
589 Button BtnShow = new Button()
592 Size = new Size(200, 100),
593 Position = new Position(50, 800),
596 Button BtnHide = new Button()
599 Size = new Size(200, 100),
600 Position = new Position(410, 800),
607 BtnShow.ClickEvent += BtnSoftkeyServiceShow_ClickEvent;
608 BtnHide.ClickEvent += BtnSoftkeyServiceHide_ClickEvent;
610 softkeyService.VisibleChanged += OnSoftkeyServiceVisibleEvent;
611 softkeyService.ExpandChanged += OnSoftkeyServiceExpandEvent;
612 softkeyService.OpacityChanged += OnSoftkeyServiceOpacityEvent;
615 public void OnSoftkeyServiceVisibleEvent(object sender, Shell.SoftkeyVisibleState state)
617 Shell.SoftkeyService obj = (Shell.SoftkeyService)sender;
618 textSoftkeyServiceVisible.Text = $"Visible: {state}";
619 if (state == Shell.SoftkeyVisibleState.Shown)
629 public void OnSoftkeyServiceExpandEvent(object sender, Shell.SoftkeyExpandState state)
631 textSoftkeyServiceExpand.Text = $"Expand: {state}";
634 public void OnSoftkeyServiceOpacityEvent(object sender, Shell.SoftkeyOpacityState state)
636 textSoftkeyServiceOpacity.Text = $"Opacity: {state}";
639 private void BtnSoftkeyServiceShow_ClickEvent(object sender, Button.ClickEventArgs e)
641 softkeyService.Show();
644 private void BtnSoftkeyServiceHide_ClickEvent(object sender, Button.ClickEventArgs e)
646 softkeyService.Hide();
649 static void Main(string[] args)
651 var app = new Program();