WaveEngine.Components.UI.WrapPanel.Add C# (CSharp) Method

Add() public method

Adds the specified UI.
UI component is null.
public Add ( UIBase ui ) : void
ui UIBase The UI.
return void
        public void Add(UIBase ui)
        {
            if (ui == null)
            {
                throw new ArgumentNullException("UI component is null.");
            }

            this.entity.AddChild(ui.Entity);
        }

Usage Example

Esempio n. 1
0
        protected override void CreateScene()
        {
            FixedCamera2D camera2d = new FixedCamera2D("camera");
            camera2d.BackgroundColor = Color.Gray;
            EntityManager.Add(camera2d);

            // Panel
            wrapPanel = new WrapPanel()
            {
                Width = 400,
                Height = 220,
                Orientation = Orientation.Horizontal,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
            };
            EntityManager.Add(wrapPanel.Entity);

            // Elements
            Button button;
            for (int i = 0; i < 5; i++)
            {
                button = new Button()
                {
                    Text = i.ToString(),
                    Width = 100,
                    Height = 100,
                    Foreground = Color.Yellow,
                    BackgroundColor = Color.Red,
                };
                wrapPanel.Add(button);
            }

            // Set Orientation
            Button button1 = new Button()
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Bottom,
                Text = "Change Orientation",
                Width = 200,
                Margin = new Thickness(20),
                Foreground = Color.LightPink,
                BackgroundColor = Color.Purple,
                BorderColor = Color.LightPink,
            };
            button1.Click += b_Click;
            EntityManager.Add(button1.Entity);

            // Debug
            this.CreateDebugMode();
        }