2 using System.Collections.Generic;
4 namespace Tizen.Applications.AttachPanel
7 /// Attach panel internal implementation
9 /// <since_tizen> 4 </since_tizen>
10 public partial class AttachPanel
12 private static IntPtr _attachPanel;
13 private bool isCreationSucceed;
15 private static event EventHandler<StateEventArgs> _eventEventHandler;
16 private static event EventHandler<ResultEventArgs> _resultEventHandler;
18 private static Interop.AttachPanel.AttachPanelEventCallback SetEventListener;
19 private static Interop.AttachPanel.AttachPanelResultCallback SetResultListener;
21 private void StateEventListenStart()
23 Interop.AttachPanel.ErrorCode err = 0;
25 SetEventListener = (attachPanel, eventType, eventInfo, userData) =>
27 _eventEventHandler?.Invoke(null, new StateEventArgs((EventType)eventType));
29 err = Interop.AttachPanel.SetEventCb(_attachPanel, SetEventListener, IntPtr.Zero);
33 private void StateEventListenStop()
35 Interop.AttachPanel.ErrorCode err = 0;
36 err = Interop.AttachPanel.UnsetEventCb(_attachPanel);
40 private void ResultEventListenStart()
42 Interop.AttachPanel.ErrorCode err = 0;
43 SetResultListener = (attachPanel, category, resulthandler, resultCode, userData) =>
45 SafeAppControlHandle handle = new SafeAppControlHandle(resulthandler, false);
46 AppControl result = new AppControl(handle);
47 _resultEventHandler?.Invoke(null, new ResultEventArgs((ContentCategory)category, result, (AppControlReplyResult)resultCode));
49 err = Interop.AttachPanel.SetResultCb(_attachPanel, SetResultListener, IntPtr.Zero);
53 private void ResultEventListenStop()
55 Interop.AttachPanel.ErrorCode err = 0;
56 err = Interop.AttachPanel.UnsetResultCb(_attachPanel);
60 internal static void CheckException(Interop.AttachPanel.ErrorCode err)
64 case Interop.AttachPanel.ErrorCode.InvalidParameter:
65 throw new ArgumentOutOfRangeException("Invalid parameter error at unmanaged code");
66 case Interop.AttachPanel.ErrorCode.OutOfMemory:
67 throw new OutOfMemoryException("Out of Memory");
68 case Interop.AttachPanel.ErrorCode.PermissionDenied:
69 throw new UnauthorizedAccessException();
70 case Interop.AttachPanel.ErrorCode.AlreadyExists:
71 throw new InvalidOperationException("Already Exists");
72 case Interop.AttachPanel.ErrorCode.NotInitialized:
73 throw new InvalidOperationException("Not initialized");
74 case Interop.AttachPanel.ErrorCode.UnsupportedContentCategory:
75 throw new NotSupportedException("Unsupported Content Category");
76 case Interop.AttachPanel.ErrorCode.AlreadyDestroyed:
77 throw new InvalidOperationException("Already Destroyed");