public void MoveWidgetToTray( Widget widget, TrayLocation trayLoc, int place )
{
if ( widget == null )
throw new ArgumentNullException( "widget", "Widget deos not exist." );
// remove widget from old tray
WidgetList wList = mWidgets[ (int)widget.TrayLocation ];
if ( wList == null )
{
wList = new WidgetList();
mWidgets[ (int)widget.TrayLocation ] = wList;
}
if ( wList.Contains( widget ) )
{
wList.Remove( widget );
mTrays[ (int)widget.TrayLocation ].RemoveChild( widget.Name );
}
// insert widget into new tray at given position, or at the end if unspecified or invalid
if ( place == -1 || place > mWidgets[ (int)trayLoc ].Count )
place = mWidgets[ (int)trayLoc ].Count;
mWidgets[ (int)trayLoc ].Insert( place, widget );
// mWidgets[ (int)trayLoc ].Add( widget );
mTrays[ (int)trayLoc ].AddChild( widget.OverlayElement );
widget.OverlayElement.HorizontalAlignment = trayWidgetAlign[ (int)trayLoc ];
// adjust trays if necessary
if ( widget.TrayLocation != TrayLocation.None || trayLoc != TrayLocation.None )
{
AdjustTrays();
}
widget.AssigendTray = trayLoc;
//widget.Show();
//mTraysLayer.AddElement( (OverlayElementContainer)widget.OverlayElement);
}