/// <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() { // lineHeight = spriteFont.MeasureString("T").Y; base.LoadContent(); this.UpdateDrawSizeByConfig(); this.UpdateDrawPositionByConfigAndParent(); this.UpdateDrawSourceRectangleByConfig(); const int VerticalScrollBarWidth = 24; this.State.Width = this.Config.Width - VerticalScrollBarWidth; // Load the scrollbar with the new position! this.scrollBarVertical = new ScrollBarVertical(this.Name + "-ScrollBarVertical") { Config = { PositionX = this.State.Width, PositionY = 0, Width = VerticalScrollBarWidth, Height = this.State.Height } }; this.AddControl(this.scrollBarVertical); this.scrollBarVertical.ConfigDebugLayout = false; this.scrollBarVertical.EventScrolling += this.OnScrollBarVerticalScroll; this.Manager.ImageCompositor.CreateSpriteFont(this.Theme.FontName); // set my appearance values this.CurrentTextureName = this.Manager.ImageCompositor.CreateRectangleTexture(this.Name + "-background", (int)this.State.Width, (int)this.State.Height, 1, this.Theme.ContainerFillColor, this.Theme.BorderColor); this.UpdateVisibility(); }
public override void DrawChildren() { if (FormChildren != null) { for (int i = 0; i < FormChildren.Count(); i++) { if (FormChildren[i] != null) { FormChildren[i].Draw(); } } } if (HasScrollbar) { if (ScrollBarHorizontal.Active) { ScrollBarHorizontal.Draw(); } if (ScrollBarVertical.Active) { ScrollBarVertical.Draw(); } } }