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


C# GuiWidget.TransformRectangleToScreenSpace方法代码示例

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


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

示例1: ValidateEnterAndLeaveInOverlapArea

        public void ValidateEnterAndLeaveInOverlapArea()
        {
            GuiWidget container = new GuiWidget();
            container.Name = "container";
            container.LocalBounds = new RectangleDouble(0, 0, 200, 200);

            GuiWidget bottomWidget = new GuiWidget();
            bottomWidget.Name = "bottom";
            bottomWidget.BoundsRelativeToParent = new RectangleDouble(10, 10, 190, 190);

            int bottomGotEnter = 0;
            int bottomGotLeave = 0;
            bottomWidget.MouseEnter += (sender, e) => { if (bottomWidget.UnderMouseState == UnderMouseState.NotUnderMouse) throw new Exception("It must be under the mouse."); bottomGotEnter++; };
            bottomWidget.MouseLeave += (sender, e) => { if (bottomWidget.UnderMouseState == UnderMouseState.FirstUnderMouse) throw new Exception("It must not be the first under the mouse."); bottomGotLeave++; };
            int bottomGotEnterBounds = 0;
            int bottomGotLeaveBounds = 0;
            bottomWidget.MouseEnterBounds += (sender, e) => { if (bottomWidget.UnderMouseState == UnderMouseState.NotUnderMouse) throw new Exception("It must be under the mouse."); bottomGotEnterBounds++; };
            bottomWidget.MouseLeaveBounds += (sender, e) => { if (bottomWidget.UnderMouseState != UnderMouseState.NotUnderMouse) throw new Exception("It must not be under the mouse."); bottomGotLeaveBounds++; };
            container.AddChild(bottomWidget);

            GuiWidget topWidget = new GuiWidget();
            topWidget.Name = "top";
            topWidget.BoundsRelativeToParent = new RectangleDouble(5, 20, 190, 190);
            int topGotEnter = 0;
            int topGotLeave = 0;
            topWidget.MouseEnter += (sender, e) => { if (topWidget.UnderMouseState == UnderMouseState.NotUnderMouse) throw new Exception("It must be under the mouse."); topGotEnter++; };
            topWidget.MouseLeave += (sender, e) => { if (topWidget.UnderMouseState == UnderMouseState.FirstUnderMouse) throw new Exception("It must not be the first under the mouse."); topGotLeave++; };
            int topGotEnterBounds = 0;
            int topGotLeaveBounds = 0;
            topWidget.MouseEnterBounds += (sender, e) => { if (topWidget.UnderMouseState == UnderMouseState.NotUnderMouse) throw new Exception("It must be under the mouse."); topGotEnterBounds++; };
            topWidget.MouseLeaveBounds += (sender, e) => { if (topWidget.UnderMouseState != UnderMouseState.NotUnderMouse) throw new Exception("It must not be under the mouse."); topGotLeaveBounds++; };
            container.AddChild(topWidget);

            Assert.IsTrue(topGotEnter == 0);
            Assert.IsTrue(topGotLeave == 0);
            Assert.IsTrue(topGotEnterBounds == 0);
            Assert.IsTrue(topGotLeaveBounds == 0);

            // move into the bottom widget only
            container.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 1, 1, 15, 0));
            container.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 1, 15, 15, 0));
            Assert.IsTrue(bottomGotLeave == 0);  
            Assert.IsTrue(bottomGotEnter == 1);
            Assert.IsTrue(bottomGotLeaveBounds == 0);
            Assert.IsTrue(bottomGotEnterBounds == 1);
            Assert.IsTrue(topGotLeave == 0);
            Assert.IsTrue(topGotEnter == 0);
            Assert.IsTrue(topGotLeaveBounds == 0);
            Assert.IsTrue(topGotEnterBounds == 0);

            // clear our states
            bottomGotEnter = bottomGotLeave = bottomGotEnterBounds = bottomGotLeaveBounds = 0;
            topGotEnter = topGotLeave = topGotEnterBounds = topGotLeaveBounds = 0;
            // move out of the bottom widget only
            container.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 1, 1, 15, 0));
            Assert.IsTrue(bottomGotLeave == 1);
            Assert.IsTrue(bottomGotEnter == 0);
            Assert.IsTrue(bottomGotLeaveBounds == 1);
            Assert.IsTrue(bottomGotEnterBounds == 0);
            Assert.IsTrue(topGotLeave == 0);
            Assert.IsTrue(topGotEnter == 0);
            Assert.IsTrue(topGotLeaveBounds == 0);
            Assert.IsTrue(topGotEnterBounds == 0);

            // move to just outside both widgets
            container.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 1, 1, 25, 0));
            Assert.IsTrue(bottomWidget.TransformRectangleToScreenSpace(bottomWidget.LocalBounds).Contains(1, 25) == false);
            Assert.IsTrue(topWidget.TransformRectangleToScreenSpace(topWidget.LocalBounds).Contains(1, 25) == false);
            // clear our states
            bottomGotEnter = bottomGotLeave = bottomGotEnterBounds = bottomGotLeaveBounds = 0;
            topGotEnter = topGotLeave = topGotEnterBounds = topGotLeaveBounds = 0;
            // move over the top widget when it is over the bottom widget (only the top should see this)
            container.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 1, 15, 25, 0));
            Assert.IsTrue(bottomGotEnter == 0);
            Assert.IsTrue(bottomGotLeave == 0);
            Assert.IsTrue(bottomGotEnterBounds == 1);
            Assert.IsTrue(bottomGotLeaveBounds == 0);
            Assert.IsTrue(topGotEnter == 1);
            Assert.IsTrue(topGotLeave == 0);
            Assert.IsTrue(topGotEnterBounds == 1);
            Assert.IsTrue(topGotLeaveBounds == 0);

            // clear our states
            bottomGotEnter = bottomGotLeave = bottomGotEnterBounds = bottomGotLeaveBounds = 0;
            topGotEnter = topGotLeave = topGotEnterBounds = topGotLeaveBounds = 0;
            // move out of the top widget into the bottom
            container.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 1, 15, 15, 0));
            Assert.IsTrue(bottomGotEnter == 1);
            Assert.IsTrue(bottomGotLeave == 0);
            Assert.IsTrue(bottomGotEnterBounds == 0);
            Assert.IsTrue(bottomGotLeaveBounds == 0);
            Assert.IsTrue(topGotEnter == 0);
            Assert.IsTrue(topGotLeave == 1);
            Assert.IsTrue(topGotEnterBounds == 0);
            Assert.IsTrue(topGotLeaveBounds == 1);

            // clear our states
            bottomGotEnter = bottomGotLeave = bottomGotEnterBounds = bottomGotLeaveBounds = 0;
            topGotEnter = topGotLeave = topGotEnterBounds = topGotLeaveBounds = 0;
            // move back up into the top and make sure we see the leave in the bottom
//.........这里部分代码省略.........
开发者ID:jeske,项目名称:agg-sharp,代码行数:101,代码来源:MouseInteractionTests.cs


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