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


C# Control.GetScreenRectangle方法代码示例

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


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

示例1: UpdateBarControlValue

            void UpdateBarControlValue( Control control, float value )
            {
                Rect screenRectangle = control.GetScreenRectangle();
                Vec2 rectSize = screenRectangle.Size;
                float width = rectSize.X / 2 * Math.Abs( value );
                Rect rect;
                if( value > 0 )
                {
                    float left = screenRectangle.Left + rectSize.X / 2;
                    rect = new Rect( left, screenRectangle.Top, left + width, screenRectangle.Bottom );
                }
                else
                {
                    float right = screenRectangle.Left + rectSize.X / 2;
                    rect = new Rect( right - width, screenRectangle.Top, right, screenRectangle.Bottom );
                }

                Control barControl = control.Controls[ "Bar" ];
                barControl.SetScreenClipRectangle( rect );
            }
开发者ID:Eneth,项目名称:GAO,代码行数:20,代码来源:EngineProfilerWindow.cs

示例2: Minimap_RenderUI

        //Draw minimap
        private void Minimap_RenderUI(Control sender, GuiRenderer renderer)
        {
            Rect screenMapRect = sender.GetScreenRectangle();

            Bounds initialBounds = Map.Instance.InitialCollisionBounds;
            Rect mapRect = new Rect(initialBounds.Minimum.ToVec2(), initialBounds.Maximum.ToVec2());

            Vec2 mapSizeInv = new Vec2(1, 1) / mapRect.Size;

            //draw units
            Vec2 screenPixel = new Vec2(1, 1) / new Vec2(EngineApp.Instance.VideoMode.ToVec2());

            foreach (Entity entity in Map.Instance.Children)
            {
                RTSUnit unit = entity as RTSUnit;
                if (unit == null)
                    continue;

                Rect rect = new Rect(unit.MapBounds.Minimum.ToVec2(), unit.MapBounds.Maximum.ToVec2());

                rect -= mapRect.Minimum;
                rect.Minimum *= mapSizeInv;
                rect.Maximum *= mapSizeInv;
                rect.Minimum = new Vec2(rect.Minimum.X, 1.0f - rect.Minimum.Y);
                rect.Maximum = new Vec2(rect.Maximum.X, 1.0f - rect.Maximum.Y);
                rect.Minimum *= screenMapRect.Size;
                rect.Maximum *= screenMapRect.Size;
                rect += screenMapRect.Minimum;

                //increase 1 pixel
                rect.Maximum += new Vec2(screenPixel.X, -screenPixel.Y);

                ColorValue color;

                if (playerFaction == null || unit.Intellect == null || unit.Intellect.Faction == null)
                    color = new ColorValue(1, 1, 0);
                else if (playerFaction == unit.Intellect.Faction)
                    color = new ColorValue(0, 1, 0);
                else
                    color = new ColorValue(1, 0, 0);

                renderer.AddQuad(rect, color);
            }

            //Draw camera borders
            {
                Camera camera = RendererWorld.Instance.DefaultCamera;

                if (camera.Position.Z > 0)
                {
                    Plane groundPlane = new Plane(0, 0, 1, 0);

                    Vec2[] points = new Vec2[4];

                    for (int n = 0; n < 4; n++)
                    {
                        Vec2 p = Vec2.Zero;

                        switch (n)
                        {
                            case 0: p = new Vec2(0, 0); break;
                            case 1: p = new Vec2(1, 0); break;
                            case 2: p = new Vec2(1, 1); break;
                            case 3: p = new Vec2(0, 1); break;
                        }

                        Ray ray = camera.GetCameraToViewportRay(p);

                        float scale;
                        groundPlane.RayIntersection(ray, out scale);

                        Vec3 pos = ray.GetPointOnRay(scale);
                        if (ray.Direction.Z > 0)
                            pos = ray.Origin + ray.Direction.GetNormalize() * 10000;

                        Vec2 point = pos.ToVec2();

                        point -= mapRect.Minimum;
                        point *= mapSizeInv;
                        point = new Vec2(point.X, 1.0f - point.Y);
                        point *= screenMapRect.Size;
                        point += screenMapRect.Minimum;

                        points[n] = point;
                    }

                    renderer.PushClipRectangle(screenMapRect);
                    for (int n = 0; n < 4; n++)
                        renderer.AddLine(points[n], points[(n + 1) % 4], new ColorValue(1, 1, 1));
                    renderer.PopClipRectangle();
                }
            }
        }
开发者ID:AKNightHawk,项目名称:AssaultKnights2,代码行数:94,代码来源:RTSGameWindow.cs

示例3: DrawArea_RenderUI

        private void DrawArea_RenderUI(Control sender, GuiRenderer renderer)
        {
            Rect rectangle = sender.GetScreenRectangle();
            bool clipRectangle = true;
            ColorValue[] colors = new ColorValue[]{
				new ColorValue( 1 ,0, 0 ),
				new ColorValue( 0, 1, 0 ),
				new ColorValue( 0, 0, 1 ),
				new ColorValue( 1, 1, 0 ),
				new ColorValue( 1, 1, 1 )};

            if (clipRectangle)
                renderer.PushClipRectangle(rectangle);

            //draw triangles
            if (GetDrawAreaMode() == DrawAreaModes.Triangles)
            {
                float distance = rectangle.GetSize().X / 2;

                List<GuiRenderer.TriangleVertex> triangles = new List<GuiRenderer.TriangleVertex>(256);

                Radian angle = -EngineApp.Instance.Time;

                const int steps = 30;
                Vec2 lastPosition = Vec2.Zero;
                for (int step = 0; step < steps + 1; step++)
                {
                    Vec2 localPos = new Vec2(MathFunctions.Cos(angle), MathFunctions.Sin(angle)) * distance;
                    Vec2 pos = rectangle.GetCenter() + new Vec2(localPos.X, localPos.Y * renderer.AspectRatio);

                    if (step != 0)
                    {
                        ColorValue color = colors[step % colors.Length];
                        ColorValue color2 = color;
                        color2.Alpha = 0;
                        triangles.Add(new GuiRenderer.TriangleVertex(rectangle.GetCenter(), color));
                        triangles.Add(new GuiRenderer.TriangleVertex(lastPosition, color2));
                        triangles.Add(new GuiRenderer.TriangleVertex(pos, color2));
                    }

                    angle += (MathFunctions.PI * 2) / steps;
                    lastPosition = pos;
                }

                renderer.AddTriangles(triangles);
            }

            //draw quads
            if (GetDrawAreaMode() == DrawAreaModes.Quads)
            {
                //draw background
                {
                    Texture texture = TextureManager.Instance.Load("GUI\\Textures\\NeoAxisLogo.png");
                    renderer.AddQuad(rectangle, new Rect(0, -.3f, 1, 1.4f), texture,
                        new ColorValue(1, 1, 1), true);
                }

                //draw bars
                {
                    float time = EngineApp.Instance.Time;

                    EngineRandom random = new EngineRandom(0);

                    int count = 15;
                    float stepOffset = rectangle.GetSize().X / count;
                    float size = stepOffset * .9f;
                    for (int n = 0; n < count; n++)
                    {
                        float v = MathFunctions.Cos(time * random.NextFloat());
                        float v2 = (v + 1) / 2;

                        ColorValue color = colors[n % colors.Length];
                        Rect rect = new Rect(
                            rectangle.Left + stepOffset * n, rectangle.Bottom - rectangle.GetSize().Y * v2,
                            rectangle.Left + stepOffset * n + size, rectangle.Bottom);
                        renderer.AddQuad(rect, color);
                    }
                }
            }

            //draw lines
            if (GetDrawAreaMode() == DrawAreaModes.Lines)
            {
                float maxDistance;
                {
                    Vec2 s = rectangle.GetSize() / 2;
                    maxDistance = MathFunctions.Sqrt(s.X * s.X + s.Y * s.Y);
                }

                int step = 0;
                float distance = 0;
                Radian angle = -EngineApp.Instance.Time;
                Vec2 lastPosition = Vec2.Zero;

                while (distance < maxDistance)
                {
                    Vec2 localPos = new Vec2(MathFunctions.Cos(angle), MathFunctions.Sin(angle)) * distance;
                    Vec2 pos = rectangle.GetCenter() + new Vec2(localPos.X, localPos.Y * renderer.AspectRatio);

                    if (step != 0)
//.........这里部分代码省略.........
开发者ID:AKNightHawk,项目名称:AssaultKnights2,代码行数:101,代码来源:GUISamples1Window.cs

示例4: DrawArea_RenderUI

        void DrawArea_RenderUI( Control sender, GuiRenderer renderer )
        {
            Rect rectangle = sender.GetScreenRectangle();
            bool clipRectangle = true;
            ColorValue[] colors = new ColorValue[]{
                new ColorValue( 1 ,0, 0 ),
                new ColorValue( 0, 1, 0 ),
                new ColorValue( 0, 0, 1 ),
                new ColorValue( 1, 1, 0 ),
                new ColorValue( 1, 1, 1 )};

            if( clipRectangle )
                renderer.PushClipRectangle( rectangle );

            //draw triangles
            if( GetDrawAreaMode() == DrawAreaModes.Triangles )
            {
                float distance = rectangle.GetSize().X / 2;

                List<GuiRenderer.TriangleVertex> triangles = new List<GuiRenderer.TriangleVertex>( 256 );

                Radian angle = -EngineApp.Instance.Time;

                const int steps = 30;
                Vec2 lastPosition = Vec2.Zero;
                for( int step = 0; step < steps + 1; step++ )
                {
                    Vec2 localPos = new Vec2( MathFunctions.Cos( angle ), MathFunctions.Sin( angle ) ) * distance;
                    Vec2 pos = rectangle.GetCenter() + new Vec2( localPos.X, localPos.Y * renderer.AspectRatio );

                    if( step != 0 )
                    {
                        ColorValue color = colors[ step % colors.Length ];
                        ColorValue color2 = color;
                        color2.Alpha = 0;
                        triangles.Add( new GuiRenderer.TriangleVertex( rectangle.GetCenter(), color ) );
                        triangles.Add( new GuiRenderer.TriangleVertex( lastPosition, color2 ) );
                        triangles.Add( new GuiRenderer.TriangleVertex( pos, color2 ) );
                    }

                    angle += ( MathFunctions.PI * 2 ) / steps;
                    lastPosition = pos;
                }

                renderer.AddTriangles( triangles );
            }

            //draw quads
            if( GetDrawAreaMode() == DrawAreaModes.Quads )
            {
                //draw background
                {
                    Texture texture = TextureManager.Instance.Load( "Gui\\Various\\Logo.png" );
                    renderer.AddQuad( rectangle, new Rect( 0, -.3f, 1, 1.4f ), texture,
                        new ColorValue( 1, 1, 1 ), true );
                }

                //draw bars
                {
                    float time = EngineApp.Instance.Time;

                    EngineRandom random = new EngineRandom( 0 );

                    int count = 15;
                    float stepOffset = rectangle.GetSize().X / count;
                    float size = stepOffset * .9f;
                    for( int n = 0; n < count; n++ )
                    {
                        float v = MathFunctions.Cos( time * random.NextFloat() );
                        float v2 = ( v + 1 ) / 2;

                        ColorValue color = colors[ n % colors.Length ];
                        Rect rect = new Rect(
                            rectangle.Left + stepOffset * n, rectangle.Bottom - rectangle.GetSize().Y * v2,
                            rectangle.Left + stepOffset * n + size, rectangle.Bottom );
                        renderer.AddQuad( rect, color );
                    }
                }
            }

            //draw lines
            if( GetDrawAreaMode() == DrawAreaModes.Lines )
            {
                float maxDistance;
                {
                    Vec2 s = rectangle.GetSize() / 2;
                    maxDistance = MathFunctions.Sqrt( s.X * s.X + s.Y * s.Y );
                }

                int step = 0;
                float distance = 0;
                Radian angle = -EngineApp.Instance.Time;
                Vec2 lastPosition = Vec2.Zero;

                while( distance < maxDistance )
                {
                    Vec2 localPos = new Vec2( MathFunctions.Cos( angle ), MathFunctions.Sin( angle ) ) * distance;
                    Vec2 pos = rectangle.GetCenter() + new Vec2( localPos.X, localPos.Y * renderer.AspectRatio );

                    if( step != 0 )
//.........这里部分代码省略.........
开发者ID:Eneth,项目名称:GAO,代码行数:101,代码来源:GuiTestWindow.cs

示例5: OnAttach

        protected override void OnAttach()
        {
            if (GameMap.Instance.GameType != GameMap.GameTypes.AssaultKnights)
            {
                return;
            }

            base.OnAttach();

            if (EntitySystemWorld.Instance.IsClientOnly())//&& !EntitySystemWorld.Instance.IsEditor())
            {
                GameNetworkClient.Instance.CustomMessagesService.ReceiveMessage += new CustomMessagesClientNetworkService.ReceiveMessageDelegate(Client_CustomMessagesService_ReceiveMessage);
            }

            window = ControlDeclarationManager.Instance.CreateControl("Gui\\PlayerSpawnWindow.gui");
            Controls.Add(window);

            spawnPoints = window.Controls["spawnPoints"];

            if (Map.Instance == null)
                return;

            //Need to Get Control Manager layers from map
            //Get Basemap value

            //layers
            //{
            //    item
            //    {
            //        name = base
            //        baseMap = "Assault Knights\\AKMaps\\AriFlats\\Textures\\flatsCM.png"
            //        baseScale = 10000
            //        detailMap = "Assault Knights\\Maps\\Map Textures\\Terrain\\DetailTextures\\64d0b218.png"
            //        detailScale = 20
            //        detailNormalMap = "Assault Knights\\Maps\\Map Textures\\Terrain\\DetailTextures\\cracked_ground_normal.tga_converted.dds"
            //    }

            //Incin -- better way each file is Assault Knights\\AKMaps\\"MapName"\\Textures\\overview.png
            //each file is 1024 x 1024 .png file
            string mapvirtualpath = Map.Instance.GetVirtualFileDirectory().ToString();
            Texture backtexture = TextureManager.Instance.Load(mapvirtualpath + "\\Textures\\overview.png");

            if (backtexture != null)
                spawnPoints.BackTexture = backtexture;
            else
                Log.Info("Invalid Path or filename of spawnPoints.BackTexture window: {0}, verify location of file or file exists!", backtexture);

            Rect screenMapRect = spawnPoints.GetScreenRectangle();
            Bounds initialBounds = Map.Instance.InitialCollisionBounds;
            Rect mapRect = new Rect(initialBounds.Minimum.ToVec2(), initialBounds.Maximum.ToVec2());

            foreach (Entity entity in Map.Instance.Children)
            {
                if (GameMap.Instance.GameType == GameMap.GameTypes.AssaultKnights)
                {
                    SpawnPoint sp = entity as SpawnPoint;
                    if (sp != null)
                    {
                        btn = ControlDeclarationManager.Instance.CreateControl(
                            "Gui\\Controls\\AKDefaultBaseButton.gui") as Button;

                        txt = new TextBox();
                        txt.AutoSize = true;
                        txt.Text = sp.Text;

                        PossibleSpawnPoint psp = new PossibleSpawnPoint();
                        psp.btn = btn;
                        psp.sp = sp;
                        psp.spid = sp.SpawnID.ToString(); //set spawnid of spawnpoint -- needed network passing
                        psp.text = txt;
                        btn.UserData = psp;
                        btn.Click += new Button.ClickDelegate(btn_Click);
                        float x = 0.5f + sp.Position.X / mapRect.Size.X;
                        float y = 0.5f + sp.Position.Y / mapRect.Size.Y;

                        btn.Position = new ScaleValue(ScaleType.Parent, new Vec2(x, y));
                        txt.Position = new ScaleValue(ScaleType.Parent, new Vec2(x + 0.05f, y));
                        spawnPoints.Controls.Add(btn);
                        spawnPoints.Controls.Add(txt);
                        possibleSpawnPoints.Add(psp);
                    }
                }
            }

            done = window.Controls["Done"] as Button;
            done.Click += new Button.ClickDelegate(done_Click);

            suicide = window.Controls["Sucide"] as Button;
            suicide.Click += new Button.ClickDelegate(suicide_Click);
            AKB = window.Controls["AK"] as Button;
            AKB.Click += new Button.ClickDelegate(AKB_Click);
            OmniB = window.Controls["Omni"] as Button;
            OmniB.Click += new Button.ClickDelegate(OmniB_Click);

            AKB.Active = true;
        }
开发者ID:AKNightHawk,项目名称:AssaultKnights2,代码行数:96,代码来源:PlayerSpawnWindow.cs


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