internal static void CreateContent(IntPtr htmlId, string htmlTag, IntPtr handle, int uiElementRegistrationId, bool htmlTagIsSvg, bool isFocusable) { if (UseJavascriptEval) { var isSvgStr = htmlTagIsSvg ? "true" : "false"; var isFocusableStr = isFocusable ? "true" : "false"; // by default all control are not focusable, it has to be change latter by the control itself WebAssemblyRuntime.InvokeJS( "Uno.UI.WindowManager.current.createContent({" + "id:\"" + htmlId + "\"," + "tagName:\"" + htmlTag + "\", " + "handle:" + handle + ", " + "uiElementRegistrationId: " + uiElementRegistrationId + ", " + "isSvg:" + isSvgStr + ", " + "isFocusable:" + isFocusableStr + "});"); } else { var parms = new WindowManagerCreateContentParams { HtmlId = htmlId, TagName = htmlTag, Handle = handle, UIElementRegistrationId = uiElementRegistrationId, IsSvg = htmlTagIsSvg, IsFocusable = isFocusable }; TSInteropMarshaller.InvokeJS("Uno:createContentNative", parms); } }
private static void InvokeFast(int value) { var parms = new WindowManagerCreateContentParams { HtmlId = (IntPtr)value, TagName = value.ToString(), Handle = (IntPtr)44, Type = "MyType", IsSvg = true, IsFrameworkElement = false, IsFocusable = true, ClassesCount = 2, Classes = new[] { "class1", "class2" }, }; var pParms = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(WindowManagerCreateContentParams))); try { Marshal.StructureToPtr(parms, pParms, false); var ret = InternalCalls.InvokeJSUnmarshalled<IntPtr, object, object, IntPtr>(out var exception, $"testLayoutFast", pParms, null, null); if (ret != parms.HtmlId) { throw new Exception($"Invalid fast response [{ret}]"); } } finally { Marshal.DestroyStructure(pParms, typeof(WindowManagerCreateContentParams)); // Free the unmanaged memory. Marshal.FreeHGlobal(pParms); } }
internal static void CreateContent(IntPtr htmlId, string htmlTag, IntPtr handle, string fullName, bool htmlTagIsSvg, bool isFrameworkElement, bool isFocusable, string[] classes) { if (UseJavascriptEval) { var isSvgStr = htmlTagIsSvg ? "true" : "false"; var isFrameworkElementStr = isFrameworkElement ? "true" : "false"; var isFocusableStr = isFocusable ? "true" : "false"; // by default all control are not focusable, it has to be change latter by the control itself var classesParam = classes.Select(c => $"\"{c}\"").JoinBy(","); WebAssemblyRuntime.InvokeJS( "Uno.UI.WindowManager.current.createContent({" + "id:\"" + htmlId + "\"," + "tagName:\"" + htmlTag + "\", " + "handle:" + handle + ", " + "type:\"" + fullName + "\", " + "isSvg:" + isSvgStr + ", " + "isFrameworkElement:" + isFrameworkElementStr + ", " + "isFocusable:" + isFocusableStr + ", " + "classes:[" + classesParam + "]" + "});"); } else { var parms = new WindowManagerCreateContentParams { HtmlId = htmlId, TagName = htmlTag, Handle = handle, Type = fullName, IsSvg = htmlTagIsSvg, IsFrameworkElement = isFrameworkElement, IsFocusable = isFocusable, Classes_Length = classes.Length, Classes = classes, }; TSInteropMarshaller.InvokeJS <WindowManagerCreateContentParams, bool>("Uno:createContentNative", parms); } }