public override void Load(string filePath, ContentManager content)
        {
            base.Load(filePath, content);

            var newWidgets = new Dictionary<string, IWidget>();

            foreach (var value in this.GetWidgets())
            {
                if (value.GetType() == typeof(Button))
                {
                    var editorButton = new EditorButton(value as Button);
                    newWidgets.Add(value.Name, editorButton);
                }
            }

            this.ClearWidgets();

            foreach (var entry in newWidgets)
            {
                this.AddWidget(entry.Value);
            }
        }
Example #2
0
        private void guiDisplay_MouseClick(object sender, MouseEventArgs e)
        {
            if (lstControls.SelectedItem == null)
            {
            }
            else if (_guiHandler != null)
            {
                if (lstControls.SelectedItem.ToString() == "Button")
                {
                    var buttonTexture = this.guiDisplay.Content.Load<Texture2D>("defaultButton");
                    buttonTexture.Name = "defaultButton";
                    var button = new EditorButton(buttonTexture, this.guiDisplay.Content.Load<SpriteFont>("menufont"));
                    button.Text = "Text";
                    button.Position = new Vector2(e.X, e.Y);
                    button.Name = "button" + (_guiHandler.GetWidgets().Length - 1);

                    PropertyDescriptor descriptor = TypeDescriptor.GetProperties(button.GetType())["SpouseName"];

                    _guiHandler.AddWidget(button);

                    this.widgetPropertyGrid.SelectedObject = _guiHandler.GetWidget<Dominus_Core.Graphics.GUI.Widgets.Button>(button.Name);

                    lstControls.SelectedItem = null;
                }
            }
        }