Protogame.Canvas.SetChild C# (CSharp) Méthode

SetChild() public méthode

public SetChild ( IContainer child ) : void
child IContainer
Résultat void
        public void SetChild(IContainer child)
        {
            if (child == null)
            {
                throw new ArgumentNullException(nameof(child));
            }

            if (child.Parent != null)
            {
                throw new InvalidOperationException();
            }

            _child = child;
            _child.Parent = this;
        }
        

Usage Example

        public MenuWorld(ISkin skin, IWorldFactory worldFactory, IAssetManagerProvider assetManagerProvider, I2DRenderUtilities twodRenderUtilities)
        {
            this.m_2DRenderUtilities = twodRenderUtilities;

            this.m_LogoTexture = assetManagerProvider.GetAssetManager().Get<TextureAsset>("texture.Logo");

            this.m_WorldFactory = worldFactory;

            this.Entities = new List<IEntity>();

            var startServer = new Button();
            startServer.Text = "Start Server";
            startServer.Click += (sender, e) =>
            {
                this.m_LastGameContext.SwitchWorld<IWorldFactory>(
                    x => x.CreateLobbyWorld(false, IPAddress.Any));
            };

            var ipAddressTextBox = new TextBox();

            var joinGame = new Button();
            joinGame.Text = "Join Game";
            joinGame.Click += (sender, e) =>
            {
                this.m_LastGameContext.SwitchWorld<IWorldFactory>(
                    x => x.CreateLobbyWorld(true, IPAddress.Parse(ipAddressTextBox.Text)));
            };

            var exitGame = new Button();
            exitGame.Text = "Exit Game";
            exitGame.Click += (sender, e) =>
            {
                this.m_LastGameContext.Game.Exit();
            };

            var vertical = new VerticalContainer();
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(new Label { Text = "Perspective" }, "25");
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(startServer, "25");
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(new Label { Text = "Server IP address:" }, "20");
            vertical.AddChild(ipAddressTextBox, "20");
            vertical.AddChild(joinGame, "25");
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(exitGame, "25");
            vertical.AddChild(new EmptyContainer(), "*");

            var horizontal = new HorizontalContainer();
            horizontal.AddChild(new EmptyContainer(), "*");
            horizontal.AddChild(vertical, "250");
            horizontal.AddChild(new EmptyContainer(), "*");

            var canvas = new Canvas();
            canvas.SetChild(horizontal);

            this.Entities.Add(new CanvasEntity(skin, canvas));
        }
All Usage Examples Of Protogame.Canvas::SetChild