示例#1
0
        /// <summary>
        /// Called directly from DALi C++ type registry to create a control (view) using no marshalling.
        /// </summary>
        /// <returns>Pointer to the control (views) handle.</returns>
        /// <param name="cPtrControlName">C pointer to the control (view) name.</param>
        private static IntPtr CreateControl(IntPtr cPtrControlName)
        {
            string controlName = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(cPtrControlName);

            NUILog.Debug("Create controlled called from C++ create a " + controlName);

            Func <CustomView> controlConstructor;

            // find the control constructor
            if (Instance._constructorMap.TryGetValue(controlName, out controlConstructor))
            {
                // Create the control
                CustomView newControl = controlConstructor();
                if (newControl != null)
                {
                    return(newControl.GetPtrfromView());  // return pointer to handle
                }
                else
                {
                    return(IntPtr.Zero);
                }
            }
            else
            {
                throw new global::System.InvalidOperationException("C# View not registererd with ViewRegistry" + controlName);
            }
        }