/// <summary> /// Called when graphics resources need to be loaded. /// Use this for the usage of : /// - creation of the internal embedded controls. /// - setting of the variables and resources in this control /// - to load any game-specific graphics resources /// - take over the config width and height and use it into State /// - overriding how this item looks like , by settings its texture or theme /// Call base.LoadContent before you do your override code, this will cause : /// - State.SourceRectangle to be reset to the Config.Size /// </summary> public override void LoadContent() { // float textXOffset = Padding; this.UpdateDrawPositionByConfigAndParent(); this.UpdateDrawSizeByConfig(); this.UpdateDrawSourceRectangleByConfig(); // add a image-item if image name is set if (this.ImagePath != null) { this.imageControlBoxForValue = new ImageControl(this.Name + "-" + this.ImagePath) { Config = { PositionX = this.Theme.ControlSmallSpacing, PositionY = this.Theme.ControlSmallSpacing, Width = (int)(this.State.Width - (2 * this.Theme.ControlSmallSpacing)), Height = (int)(this.State.Height - (2 * this.Theme.ControlSmallSpacing)), }, ImagePath = this.ImagePath, Manager = this.Manager }; this.imageControlBoxForValue.Initialize(); this.Children.Add(this.imageControlBoxForValue); // textXOffset += _imageBoxForValue.State.DrawPosition.X + _imageBoxForValue.State.Width; } // add a text-box this.textValue = new Label(this.Name + "-TextBox") { ConfigText = this.Text, ConfigHorizontalAlignment = HorizontalAlignment.Left, ConfigVerticalAlignment = VerticalAlignment.Center, Config = { Width = this.Config.Width - this.Config.Height, Height = this.Config.Height, }, ConfigDebugLayout = false }; this.textValue.Initialize(); this.AddControl(this.textValue); // add the drop-down button this.dropDownButton = new ToggleButton(this.Name + "-DropDownButton") { ConfigText = string.Empty, Config = { Width = this.Config.Height, Height = this.Config.Height } }; this.dropDownButton.Config.PositionX = this.Config.Width - this.dropDownButton.Config.Width; this.AddControl(this.dropDownButton); this.dropDownButton.OnToggle += this.OnToggleDropDown; // add the drop down list this.DropDownList = new ListBox(this.Name + "-FlapOut") { Config = { Width = this.Config.Width, Height = this.Config.Width, Visible = false, PositionY = this.Config.PositionY + this.Config.Height } }; this.AddControl(this.DropDownList); this.DropDownList.OnItemSelect += this.OnItemSelect; this.CurrentTextureName = this.Manager.ImageCompositor.CreateRectangleTexture(this.Name + "-Background", (int)this.Config.Width, (int)this.Config.Height, this.Theme.BorderWidth, this.Theme.ContainerFillColor, this.Theme.BorderColor); this.dropDownListShown = false; base.LoadContent(); }