Exemple #1
0
 internal DynamicDomElement(INTERNAL_HtmlDomElementReference domElementRef)
 {
     _domElementRef = domElementRef;
 }
        public static PopupRoot CreateAndAppendNewPopupRoot(Window parentWindow)
        {
            // Generate a unique identifier for the PopupRoot:
            CurrentPopupRootIndentifier++;
            string uniquePopupRootIdentifier = "INTERNAL_Cshtml5_PopupRoot_" + CurrentPopupRootIndentifier.ToString();

            //--------------------------------------
            // Create a DIV for the PopupRoot in the DOM tree:
            //--------------------------------------

            CSHTML5.Interop.ExecuteJavaScriptAsync(
                @"
var popupRoot = document.createElement('div');
popupRoot.setAttribute('id', $0);
popupRoot.style.position = 'absolute';
popupRoot.style.width = '100%';
popupRoot.style.height = '100%';
popupRoot.style.overflowX = 'hidden';
popupRoot.style.overflowY = 'hidden';
popupRoot.style.pointerEvents = 'none';
$1.appendChild(popupRoot);
", uniquePopupRootIdentifier, parentWindow.INTERNAL_RootDomElement);

            //--------------------------------------
            // Get the PopupRoot DIV:
            //--------------------------------------

            object popupRootDiv;

#if OPENSILVER
            if (true)
#elif BRIDGE
            if (Interop.IsRunningInTheSimulator)
#endif
            { popupRootDiv = new INTERNAL_HtmlDomElementReference(uniquePopupRootIdentifier, null); }
            else
            {
                popupRootDiv = Interop.ExecuteJavaScriptAsync("document.getElementByIdSafe($0)", uniquePopupRootIdentifier);
            }

            //--------------------------------------
            // Create the C# class that points to the PopupRoot DIV:
            //--------------------------------------

            var popupRoot = new PopupRoot(uniquePopupRootIdentifier, parentWindow);
            popupRoot.INTERNAL_OuterDomElement
                  = popupRoot.INTERNAL_InnerDomElement
                  = popupRootDiv;

            //--------------------------------------
            // Listen to clicks anywhere in the popup (this is used to close other popups that are not supposed to stay open):
            //--------------------------------------

#if MIGRATION
            popupRoot.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(INTERNAL_PopupsManager.OnClickOnPopupOrWindow), true);
#else
            popupRoot.AddHandler(UIElement.PointerPressedEvent, new PointerEventHandler(INTERNAL_PopupsManager.OnClickOnPopupOrWindow), true);
#endif

            //--------------------------------------
            // Remember the PopupRoot for later use:
            //--------------------------------------

            PopupRootIdentifierToInstance.Add(uniquePopupRootIdentifier, popupRoot);

            return(popupRoot);
        }
Exemple #3
0
 internal DynamicDomElementChildrenCollection(INTERNAL_HtmlDomElementReference parentDomElementRef)
 {
     _parentDomElementRef = parentDomElementRef;
 }