当前位置: 首页>>代码示例>>C#>>正文


C# IHTMLElement.requestPointerLock方法代码示例

本文整理汇总了C#中IHTMLElement.requestPointerLock方法的典型用法代码示例。如果您正苦于以下问题:C# IHTMLElement.requestPointerLock方法的具体用法?C# IHTMLElement.requestPointerLock怎么用?C# IHTMLElement.requestPointerLock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IHTMLElement的用法示例。


在下文中一共展示了IHTMLElement.requestPointerLock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Spawn

        //async Task __buttryfly()
        //{ 
        //    //Task.Factory.
        //}

        //async 
        void Spawn(IHTMLElement e)
        {


            Native.Document.body.style.margin = "0px";
            Native.Document.body.style.padding = "0px";
            Native.Document.body.style.overflow = IStyle.OverflowEnum.hidden;

            e.style.position = IStyle.PositionEnum.absolute;
            e.style.left = "0px";
            e.style.top = "0px";
            e.style.right = "0px";
            e.style.bottom = "0px";

            e.style.backgroundColor = Color.FromRGB(209, 245, 245);

            IHTMLElement loading = new IHTMLElement(IHTMLElement.HTMLElementEnum.code, "loading...");

            loading.style.SetLocation(64, 64, 200, 64);

            e.appendChild(loading);

            //await __buttryfly();

            new global::ButterFly.HTML.Images.FromAssets.buttryfly().InvokeOnComplete(
                img =>
                {
                    loading.FadeOut();

                    try
                    {
                        //IStyleSheet.Default.AddRule("*", "cursor: none, url('" + new global::ButterFly.HTML.Images.FromAssets.nocursor().src + "'), auto;", 0);
                        IStyleSheet.Default.AddRule("*", "cursor: none;", 0);
                    }
                    catch (Exception exc)
                    {
                        new IHTMLElement(IHTMLElement.HTMLElementEnum.pre, exc.Message).AttachToDocument();
                    }


                    e.style.backgroundImage = "url(" + img.src + ")";
                    e.style.backgroundRepeat = "no-repeat";



                    e.DisableContextMenu();


                    var x = 0;
                    var y = 0;

                    Action update =
                        delegate
                        {
                            e.style.backgroundPosition = x + "px " + y + "px";
                        };

                    e.onmousemove +=
                        delegate(IEvent i)
                        {


                            #region where is the cursor?
                            if (Native.Document.pointerLockElement == e)
                            {
                                x += i.movementX;
                                y += i.movementY;
                            }
                            else
                            {
                                x = i.CursorX;
                                y = i.CursorY;
                            }

                            if (x < -img.width / 2)
                                x += Native.window.Width;

                            if (y < -img.height / 2)
                                y += Native.window.Height;

                            x = x % Native.window.Width;
                            y = y % Native.window.Height;
                            #endregion


                            update();

                        };

                    e.onclick +=
                        delegate
                        {
                            e.requestPointerLock();
                        };
//.........这里部分代码省略.........
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:101,代码来源:Butterfly.cs

示例2: Spawn


//.........这里部分代码省略.........
            IHTMLElement loading = new IHTMLElement(IHTMLElement.HTMLElementEnum.code, "loading...");

            loading.style.SetLocation(64, 64, 200, 64);

            e.appendChild(loading);

            //await __buttryfly();

            new global::ButterFlyWithInteractiveInt32Offset.HTML.Images.FromAssets.buttryfly().InvokeOnComplete(
                img =>
                {
                    loading.FadeOut();

                    try
                    {
                        //IStyleSheet.Default.AddRule("*", "cursor: none, url('" + new global::ButterFlyWithInteractiveInt32Offset.HTML.Images.FromAssets.nocursor().src + "'), auto;", 0);
                        //IStyleSheet.Default.AddRule("*", "cursor: none;", 0);
                    }
                    catch (Exception exc)
                    {
                        new IHTMLElement(IHTMLElement.HTMLElementEnum.pre, exc.Message).AttachToDocument();
                    }


                    e.style.backgroundImage = "url(" + img.src + ")";
                    e.style.backgroundRepeat = "no-repeat";



                    e.DisableContextMenu();


                    var x = 0;
                    var y = 0;


                    var overlay = new IHTMLDiv();
                    overlay.style.border = "1px solid red";
                    overlay.style.SetSize(64, 64);
                    overlay.AttachToDocument();

                   Native.window.onframe +=
                        delegate
                        {
                            e.style.backgroundPosition = x + "px " + y + "px";

                            overlay.style.SetLocation(
                                // how does this work with the background compiler?
                                // once browser clicks save, visual studio asks if
                                // to accept, and bacground compiler
                                // starts a new compilation
                                // so, the running app could first be able
                                // to inspect, whats new?
                                // and if only the same constant was changed,
                                // it can be discarded. same with comments.
                                x + 67.ToInteractiveInt32Form(),
                                y + 2.ToInteractiveInt32Form()
                            );

                        };

                    e.onmousemove +=
                        delegate(IEvent i)
                        {


                            #region where is the cursor?
                            if (Native.Document.pointerLockElement == e)
                            {
                                x += i.movementX;
                                y += i.movementY;
                            }
                            else
                            {
                                x = i.CursorX;
                                y = i.CursorY;
                            }

                            if (x < -img.width / 2)
                                x += Native.window.Width;

                            if (y < -img.height / 2)
                                y += Native.window.Height;

                            x = x % Native.window.Width;
                            y = y % Native.window.Height;
                            #endregion



                        };

                    e.onclick +=
                        delegate
                        {
                            e.requestPointerLock();
                        };
                });

        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:101,代码来源:Butterfly.cs


注:本文中的IHTMLElement.requestPointerLock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。