public UIButton InsertButton( int index, String text, MouseButtonEventHandler clickHandler = null ) { float y = ButtonMargin; if ( myButtons.Count != 0 && index != 0 ) y = myButtons[ index - 1 ].Bottom + ButtonSpacing; for ( int i = index; i < myButtons.Count; ++i ) myButtons[ i ].Top += myButtons[ i ].Height + ButtonSpacing; UIButton newButton = new UIButton( new Vector2( InnerWidth - ButtonMargin * 2, ButtonHeight ), new Vector2( ButtonMargin, y ) ) { Text = text, CentreText = true }; myButtons.Insert( index, newButton ); AddChild( newButton ); if ( clickHandler != null ) newButton.Click += clickHandler; return newButton; }
public void RemoveButton( UIButton button ) { RemoveButton( myButtons.IndexOf( button ) ); }