2 * Copyright(c) 2021 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.Runtime.InteropServices;
23 class ComponentApplication : Application
25 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
27 internal ComponentApplication(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
29 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
32 protected override void Dispose(DisposeTypes type)
39 //Release your own unmanaged resources here.
40 //You should not access any managed member here except static instance.
41 //because the execution order of Finalizes is non-deterministic.
42 if (swigCPtr.Handle != global::System.IntPtr.Zero)
47 Interop.ComponentApplication.DeleteComponentApplication(swigCPtr);
49 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
54 public static ComponentApplication NewComponentApplication(string[] args, string stylesheet)
56 ComponentApplication ret = New(args, stylesheet);
57 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
62 public static ComponentApplication New(string[] args, string stylesheet)
64 int argc = args.Length;
65 string argvStr = string.Join(" ", args);
67 IntPtr widgetIntPtr = Interop.ComponentApplication.New(argc, argvStr, stylesheet);
69 ComponentApplication ret = new ComponentApplication(widgetIntPtr, false);
71 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
76 internal ComponentApplication(ComponentApplication componentApplication) : this(Interop.ComponentApplication.NewComponentApplication(ComponentApplication.getCPtr(componentApplication)), true)
78 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81 internal ComponentApplication Assign(ComponentApplication componentApplication)
83 ComponentApplication ret = new ComponentApplication(Interop.ComponentApplication.Assign(swigCPtr, ComponentApplication.getCPtr(componentApplication)), false);
84 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
88 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
89 private delegate IntPtr NUIComponentApplicationCreatenativeEventCallbackDelegate();
91 public delegate IntPtr CreateNativeEventHandler();
92 private CreateNativeEventHandler applicationCreateNativeEventHandler;
93 private NUIComponentApplicationCreatenativeEventCallbackDelegate applicationCreateNativeEventCallbackDelegate;
96 * @brief Event for Initialized signal which can be used to subscribe/unsubscribe the event handler
97 * provided by the user. Initialized signal is emitted when application is initialized
99 public event CreateNativeEventHandler CreateNative
103 // Restricted to only one listener
104 if (applicationCreateNativeEventHandler == null)
106 applicationCreateNativeEventHandler += value;
108 applicationCreateNativeEventCallbackDelegate = new NUIComponentApplicationCreatenativeEventCallbackDelegate(OnApplicationCreateNative);
109 Connect(applicationCreateNativeEventCallbackDelegate);
115 if (applicationCreateNativeEventHandler != null)
117 Disconnect(applicationCreateNativeEventCallbackDelegate);
120 applicationCreateNativeEventHandler -= value;
125 public void Connect(System.Delegate func)
127 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
129 Interop.ComponentApplication.CreateNativeSignalConnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
130 if (NDalicPINVOKE.SWIGPendingException.Pending)
132 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
137 public void Disconnect(System.Delegate func)
139 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
141 Interop.ComponentApplication.CreateNativeSignalDisconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
142 if (NDalicPINVOKE.SWIGPendingException.Pending)
144 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
149 internal ApplicationSignal CreateNativeSignal()
151 ApplicationSignal ret = new ApplicationSignal(Interop.ComponentApplication.CreateNativeSignal(swigCPtr), false);
152 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
156 // Callback for Application InitSignal
157 private IntPtr OnApplicationCreateNative()
159 return applicationCreateNativeEventHandler?.Invoke() ?? IntPtr.Zero;