2 * Copyright(c) 2023 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.ComponentModel;
21 namespace Tizen.NUI.WindowSystem.Shell
24 /// Class for the Tizen taskbar service.
26 /// This class is need to be hidden as inhouse API.
27 [EditorBrowsable(EditorBrowsableState.Never)]
28 public class TaskbarService : IDisposable
30 private TizenShell _tzsh;
31 private IntPtr _taskbarService;
33 private bool disposed = false;
34 private bool isDisposeQueued = false;
37 /// Enumeration for placed type of taskbar service window.
42 /// Place to Bottom of Screen. Default type.
46 /// Place to Top of Screen.
50 /// Place to Left Side of Screen.
54 /// Place to Right Side of Screen.
60 /// Creates a new Taskbar Service handle.
62 /// <param name="tzShell">The TizenShell instance.</param>
63 /// <param name="win">The window to provide service of the taskbar.</param>
64 /// <param name="type">The type to be placed on the screen.</param>
65 /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
66 /// <exception cref="ArgumentNullException">Thrown when a argument is null.</exception>
67 public TaskbarService(TizenShell tzShell, Window win, PlaceType type = PlaceType.Bottom)
71 throw new ArgumentNullException(nameof(tzShell));
73 if (tzShell.GetNativeHandle() == IntPtr.Zero)
75 throw new ArgumentException("tzShell is not initialized.");
79 throw new ArgumentNullException(nameof(win));
83 _tzshWin = win.GetNativeId();
84 _taskbarService = Interop.TaskbarService.Create(_tzsh.GetNativeHandle(), (IntPtr)_tzshWin);
85 if (_taskbarService == IntPtr.Zero)
87 int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult();
88 _tzsh.ErrorCodeThrow(err);
91 Interop.TaskbarService.SetPlaceType(_taskbarService, (int)type);
101 isDisposeQueued = true;
102 DisposeQueue.Instance.Add(this);
109 public void Dispose()
113 Dispose(DisposeTypes.Implicit);
117 Dispose(DisposeTypes.Explicit);
118 GC.SuppressFinalize(this);
123 protected virtual void Dispose(DisposeTypes type)
127 if (_taskbarService != IntPtr.Zero)
129 int res = Interop.TaskbarService.Destroy(_taskbarService);
130 _taskbarService = IntPtr.Zero;
137 /// Set the current place type.
138 /// The window manager can use this to determine the geometry of another applications.
140 /// <param name="type">The type of placement, enumeration for the place type.</param>
141 /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
142 public void SetPlaceType(PlaceType type)
146 res = Interop.TaskbarService.SetPlaceType(_taskbarService, (int)type);
147 _tzsh.ErrorCodeThrow(res);
151 /// Set the size of the taskbar.
152 /// This may be different from the actual size. The window manager can use this to
153 /// determine the geometry of another applications.
155 /// <param name="width">The width of the taskbar area.</param>
156 /// <param name="height">The height of the taskbar area.</param>
157 /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
158 public void SetSize(uint width, uint height)
162 res = Interop.TaskbarService.SetSize(_taskbarService, width, height);
163 _tzsh.ErrorCodeThrow(res);