Beispiel #1
0
        public MySlotter() : base("x-slotter")
        {
            var div  = Create("div");
            var slot = Create("slot");

            ShadowRoot.AppendChild(div);
            div.AppendChild(slot);
        }
Beispiel #2
0
 public MyTwoDivComponent(bool useShadow) : base("x-twodiv")
 {
     if (!useShadow)
     {
         return;
     }
     ShadowRoot.AppendChild(Create("div"));
     ShadowRoot.AppendText("hello");
 }
Beispiel #3
0
        private void Update()
        {
            var rendered = _criteria();

            if (rendered == _rendered)
            {
                return;
            }
            _rendered = rendered;
            if (rendered)
            {
                ShadowRoot.AppendChild(_factory());
            }
            else
            {
                ShadowRoot.ClearChildren();
            }
        }
Beispiel #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 public Fragment()
 {
     ShadowRoot.AppendChild(new Slot());
 }
        public __TextBox()
        {
            #region InternalContainer
            //this.InternalContainer = new IHTMLDiv();
            this.InternalContainer = new IHTMLElement(ElementName);

            // are we excluding older browsers? does the app analyzer let the developer know what devices can be used now?
            this.InternalContainer_shadow = this.InternalContainer.createShadowRoot();
            // if we only create shadow, empty, other children dissapear dont they. as there are no insertion points

            this.InternalContainer.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;

            // in Forms we use typeof() because we see Component. WPF objects are more like XElements..
            this.InternalContainer.name = "__TextBox";

            this.InternalContainer.style.left = "0px";
            this.InternalContainer.style.top = "0px";

            // do we create any new havoc?
            this.InternalContainer.style.zIndex = 0;
            #endregion


            #region InternalTextField_ShadowContainer

            // when is it attached?
            this.InternalTextField_ShadowContainer = new IHTMLDiv();


            this.InternalTextField_ShadowContainer.style.position = IStyle.PositionEnum.absolute;
            this.InternalTextField_ShadowContainer.style.overflow = IStyle.OverflowEnum.hidden;
            this.InternalTextField_ShadowContainer.style.SetSize(0, 0);

            this.InternalTextField_Shadow = new IHTMLSpan();
            this.InternalTextField_Shadow.AttachTo(this.InternalTextField_ShadowContainer);
            this.InternalTextField_Shadow.style.whiteSpace = IStyle.WhiteSpaceEnum.pre;
            this.InternalTextField_Shadow.style.display = IStyle.DisplayEnum.inline_block;
            this.InternalTextField_Shadow.style.position = IStyle.PositionEnum.absolute;
            #endregion

            #region InternalTextField
            this.InternalTextField = new IHTMLInput(ScriptCoreLib.Shared.HTMLInputTypeEnum.text)
            {

                //}.AttachTo(this.InternalContainer);
                // public static T AttachTo<T>(this T e, IHTMLElement c) where T : INodeConvertible<IHTMLElement>;
            }.AttachTo(this.InternalContainer_shadow);

            this.InternalSetDefaultFont();

            this.InternalTextField.style.position = IStyle.PositionEnum.absolute;
            this.InternalTextField.style.margin = "0";
            this.InternalTextField.style.paddingTop = "0";
            this.InternalTextField.style.paddingBottom = "0";
            this.InternalTextField.style.border = "1px solid gray";
            #endregion


            Action InternalAutoSizeUpdate =
                delegate
                {
                    if (this.InternalTextField_Shadow == null)
                        return;

                    InternalAutoSizeToText(this.InternalTextField.value);
                };

            this.InternalTextField.onchange +=
                delegate
                {
                    InternalAutoSizeUpdate();
                };

            this.InternalTextField.onkeyup +=
                delegate
                {
                    InternalAutoSizeUpdate();
                };
        }
        public __TextBox()
        {
            #region InternalContainer
            //this.InternalContainer = new IHTMLDiv();
            this.InternalContainer = new IHTMLElement(ElementName);

            // are we excluding older browsers? does the app analyzer let the developer know what devices can be used now?
            this.InternalContainer_shadow = this.InternalContainer.createShadowRoot();
            // if we only create shadow, empty, other children dissapear dont they. as there are no insertion points

            this.InternalContainer.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;

            // in Forms we use typeof() because we see Component. WPF objects are more like XElements..
            this.InternalContainer.name = "__TextBox";

            this.InternalContainer.style.left = "0px";
            this.InternalContainer.style.top  = "0px";

            // do we create any new havoc?
            this.InternalContainer.style.zIndex = 0;
            #endregion


            #region InternalTextField_ShadowContainer

            // when is it attached?
            this.InternalTextField_ShadowContainer = new IHTMLDiv();


            this.InternalTextField_ShadowContainer.style.position = IStyle.PositionEnum.absolute;
            this.InternalTextField_ShadowContainer.style.overflow = IStyle.OverflowEnum.hidden;
            this.InternalTextField_ShadowContainer.style.SetSize(0, 0);

            this.InternalTextField_Shadow = new IHTMLSpan();
            this.InternalTextField_Shadow.AttachTo(this.InternalTextField_ShadowContainer);
            this.InternalTextField_Shadow.style.whiteSpace = IStyle.WhiteSpaceEnum.pre;
            this.InternalTextField_Shadow.style.display    = IStyle.DisplayEnum.inline_block;
            this.InternalTextField_Shadow.style.position   = IStyle.PositionEnum.absolute;
            #endregion

            #region InternalTextField
            this.InternalTextField = new IHTMLInput(ScriptCoreLib.Shared.HTMLInputTypeEnum.text)
            {
                //}.AttachTo(this.InternalContainer);
                // public static T AttachTo<T>(this T e, IHTMLElement c) where T : INodeConvertible<IHTMLElement>;
            }.AttachTo(this.InternalContainer_shadow);

            this.InternalSetDefaultFont();

            this.InternalTextField.style.position      = IStyle.PositionEnum.absolute;
            this.InternalTextField.style.margin        = "0";
            this.InternalTextField.style.paddingTop    = "0";
            this.InternalTextField.style.paddingBottom = "0";
            this.InternalTextField.style.border        = "1px solid gray";
            #endregion


            Action InternalAutoSizeUpdate =
                delegate
            {
                if (this.InternalTextField_Shadow == null)
                {
                    return;
                }

                InternalAutoSizeToText(this.InternalTextField.value);
            };

            this.InternalTextField.onchange +=
                delegate
            {
                InternalAutoSizeUpdate();
            };

            this.InternalTextField.onkeyup +=
                delegate
            {
                InternalAutoSizeUpdate();
            };
        }
Beispiel #7
0
 /// <summary>
 /// Constructor
 /// </summary>
 public AutocompleteElement() : base(CustomTag)
 {
     InnerInput.Autocomplete = "off";
     ShadowRoot.AppendChild(InnerInput);
 }
Beispiel #8
0
    //创建动态阴影(比较消耗)
    public void CreateDynamicShadow(Vector3 lightDir,
                                    GameObject shadowRoot,
                                    GameObject renderRoot,
                                    List <Object> objs,
                                    int shadowLayer = -1,
                                    int cullingMask = -1)
    {
        ResourceManager.PrepareResource <GameObject>(Resource.PrefabPath.DynamicShadowCaster, resCaster =>
        {
            if (gameObject == null)
            {
                return;
            }

            if (shadowRoot == null)
            {
                return;
            }

            var caster = Instantiate(resCaster) as GameObject;
            caster.GetComponent <TransformConstraint>().target = shadowRoot.transform;

            ResourceManager.PrepareResource <GameObject>(Resource.PrefabPath.DynamicShadowReceiver, resReceiver =>
            {
                if (gameObject == null)
                {
                    return;
                }

                if (cullingMask == -1)
                {
                    caster.camera.cullingMask = LayerMask.GetMask(GAMELAYER.MainPlayer);
                }
                else
                {
                    caster.camera.cullingMask = cullingMask;
                }

                var receiver = Instantiate(resReceiver) as GameObject;
                if (-1 != shadowLayer)
                {
                    receiver.layer = shadowLayer;
                }
                var meshShadowReceiver             = receiver.GetComponent <MeshShadowReceiver>();
                meshShadowReceiver.meshTree        = MeshTree;
                meshShadowReceiver.meshTransform   = gameObject.transform;
                meshShadowReceiver.customProjector = caster.GetComponent <CustomProjector>();

                // create render texture for the camera
                var renderTexture = new RenderTexture(256, 256, 8, RenderTextureFormat.Default);
                caster.GetComponent <Camera>().targetTexture = renderTexture;
                receiver.GetComponent <MeshRenderer>().sharedMaterial.SetTexture("_ShadowTex", renderTexture);

                var shadowRootTransform  = ShadowRoot.transform;
                var receiverTransform    = receiver.transform;
                caster.transform.parent  = shadowRootTransform;
                receiverTransform.parent = shadowRootTransform;

#if UNITY_EDITOR
                ResourceManager.ChangeShader(receiverTransform);
#endif

                objs.Add(renderTexture);
                objs.Add(caster);
                objs.Add(receiver);

                ShadowRoot.SetActive(GameSetting.Instance.ShowDynamicShadow);
            });
        });
    }