2 * Copyright(c) 2020 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.Collections.Generic;
20 using System.ComponentModel;
23 namespace Tizen.NUI.WindowSystem.Shell
26 /// Class for the Tizen quickpanel service.
28 /// This class is need to be hidden as inhouse API.
29 [EditorBrowsable(EditorBrowsableState.Never)]
30 public class QuickPanelService : IDisposable
32 private TizenShell _tzsh;
33 private IntPtr _tzshQpService;
35 private bool disposed = false;
36 private bool isDisposeQueued = false;
44 /// Unknown type. There is no quickpanel service.
48 /// System default type.
52 /// Context menu type.
64 public enum EffectType
75 /// App control effect
81 /// Creates a new Quickpanel Service handle.
83 /// <param name="tzShell">The TzShell instance.</param>
84 /// <param name="win">The window to provide service of the quickpanel.</param>
85 /// <param name="type">The type of quickpanel service.</param>
86 /// <exception cref="Tizen.Applications.Exceptions.OutOfMemoryException">Thrown when the memory is not enough to allocate.</exception>
87 /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
88 /// <exception cref="ArgumentNullException">Thrown when a argument is null.</exception>
89 public QuickPanelService(TizenShell tzShell, Window win, Types type)
93 throw new ArgumentNullException(nameof(tzShell));
95 if (tzShell.GetNativeHandle() == IntPtr.Zero)
97 throw new ArgumentException("tzShell is not initialized.");
101 throw new ArgumentNullException(nameof(win));
105 _tzshWin = win.GetNativeId();
106 _tzshQpService = Interop.QuickPanelService.CreateWithType(_tzsh.GetNativeHandle(), (IntPtr)_tzshWin, (int)type);
107 if (_tzshQpService == IntPtr.Zero)
109 int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult();
110 _tzsh.ErrorCodeThrow(err);
117 /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
120 if (!isDisposeQueued)
122 isDisposeQueued = true;
123 DisposeQueue.Instance.Add(this);
130 /// <exception cref="MemberAccessException">Thrown when private memeber is a corrupted.</exception>
131 public void Dispose()
135 Dispose(DisposeTypes.Implicit);
139 Dispose(DisposeTypes.Explicit);
140 GC.SuppressFinalize(this);
145 protected virtual void Dispose(DisposeTypes disposing)
150 if (_tzshQpService != IntPtr.Zero)
152 res = Interop.QuickPanelService.Destroy(_tzshQpService);
155 _tzsh.ErrorCodeThrow(res);
157 catch (ArgumentException e)
159 throw new MemberAccessException("QuickPanelService is a corrupted");
161 _tzshQpService = IntPtr.Zero;
168 /// Gets the type of the quickpanel service handle.
170 /// <returns>The type of the quickpanel service handle</returns>
171 /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
172 public Types ServiceType
180 private new Types GetType()
185 res = Interop.QuickPanelService.GetType(_tzshQpService, out type);
187 _tzsh.ErrorCodeThrow(res);
193 /// Requests to show the quickpanel service window.
195 /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
200 res = Interop.QuickPanelService.Show(_tzshQpService);
201 _tzsh.ErrorCodeThrow(res);
205 /// Requests to hide the quickpanel service window.
207 /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
212 res = Interop.QuickPanelService.Hide(_tzshQpService);
213 _tzsh.ErrorCodeThrow(res);
217 /// Sets the content region of the quickpanel service handle.
219 /// <param name="angle">The angle setting the region</param>
220 /// <param name="region">The region of the content</param>
221 /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
222 /// <exception cref="ArgumentNullException">Thrown when a argument is null.</exception>
223 public void SetContentRegion(uint angle, TizenRegion region)
229 throw new ArgumentNullException(nameof(region));
231 res = Interop.QuickPanelService.SetContentRegion(_tzshQpService, angle, region.GetNativeHandle());
232 _tzsh.ErrorCodeThrow(res);
236 /// Sets the handler region of the quickpanel service handle.
238 /// <param name="angle">The angle setting the region</param>
239 /// <param name="region">The region of the content</param>
240 /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
241 /// <exception cref="ArgumentNullException">Thrown when a argument is null.</exception>
242 public void SetHandlerRegion(uint angle, TizenRegion region)
248 throw new ArgumentNullException(nameof(region));
250 res = Interop.QuickPanelService.SetHandlerRegion(_tzshQpService, angle, region.GetNativeHandle());
251 _tzsh.ErrorCodeThrow(res);
255 /// Requests to change the effect of animation.
257 /// <param name="type">The type of effect, enumeration for effect type.</param>
258 /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
259 public void SetEffectType(EffectType type)
263 res = Interop.QuickPanelService.SetEffectType(_tzshQpService, (int)type);
264 _tzsh.ErrorCodeThrow(res);
268 /// Requests to lock/unlock scrolling the quickpanel service window.
270 /// <param name="locked">The scroll lock state</param>
271 /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
272 public void LockScroll(bool locked)
276 res = Interop.QuickPanelService.LockScroll(_tzshQpService, locked);
277 _tzsh.ErrorCodeThrow(res);