示例#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();
 }
示例#2
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);
 }
示例#3
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));
        }
示例#4
0
 public void AddChild(Control child)
 {
     if (child.Parent != null)
     {
         child.Parent.RemoveChild(child);
     }
     AddChild(child, ChildCount);
 }
示例#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();
     }
 }
示例#6
0
        private void PopulateWithFakeData()
        {
            PanelControl newList = new PanelControl();
            Random rng = new Random();
            for (int i = 0; i < 50; i++)
            {
                long score = 10000 - i * 10;
                TimeSpan time = TimeSpan.FromSeconds(rng.Next(60, 3600));
                newList.AddChild(CreateLeaderboardEntryControl("player" + i.ToString(), score, time));
            }
            newList.LayoutColumn(0, 0, 0);

            if (resultListControl != null)
            {
                RemoveChild(resultListControl);
            }
            resultListControl = newList;
            AddChild(resultListControl);
            LayoutColumn(0, 0, 0);
        }
示例#7
0
 protected override void OnChildRemoved(int index, Control child)
 {
     tracker.PageWidthList.RemoveAt(index);
 }
示例#8
0
 protected override void OnChildAdded(int index, Control child)
 {
     tracker.PageWidthList.Insert(index, (int)child.Size.X);
 }