Example #1
0
 /// <summary>
 /// Called after a child control is removed from this control. The default behavior is to call InvalidateAutoSize().
 /// </summary>
 protected virtual void OnChildRemoved(int index, Control child)
 {
     InvalidateAutoSize();
 }
Example #2
0
        /// <summary>
        /// Remove the given control from this control's list of children.
        /// </summary>
        public void RemoveChild(Control child)
        {
            if(child.Parent != this)
                throw new InvalidOperationException();

            RemoveChildAt(children.IndexOf(child));
        }
Example #3
0
 public void AddChild(Control child)
 {
     if (child.Parent != null)
     {
         child.Parent.RemoveChild(child);
     }
     AddChild(child, ChildCount);
 }
Example #4
0
 public void AddChild(Control child, int index)
 {
     if (child.Parent != null)
     {
         child.Parent.RemoveChild(child);
     }
     child.Parent = this;
     if (children == null)
     {
         children = new List<Control>();
     }
     children.Insert(index, child);
     OnChildAdded(index, child);
 }
Example #5
0
 // Call this method once per frame on the root of your control heirarchy to draw all the controls.
 // See ControlScreen for an example.
 public static void BatchDraw(Control control, GraphicsDevice device, SpriteBatch spriteBatch, Vector2 offset, GameTime gameTime)
 {
     if (control != null && control.Visible)
     {
         spriteBatch.Begin();
         control.Draw(new DrawContext
         {
             Device = device,
             SpriteBatch = spriteBatch,
             DrawOffset = offset + control.Position,
             GameTime = gameTime
         });
         spriteBatch.End();
     }
 }