/// <summary> /// /// </summary> /// <param name="widget"></param> public WidgetEventArgs( Widget widget ) { Widget = widget; }
/// <summary> /// Removes a widget from its tray. Same as moving it to the null tray. /// </summary> /// <param name="widget"></param> public void RemoveWidgetFromTray( Widget widget ) { MoveWidgetToTray( widget, TrayLocation.None ); }
/// <summary> /// Adds a widget to a specified tray. /// </summary> /// <param name="widget"></param> /// <param name="trayLoc"></param> /// <param name="place"></param> 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 = this.mWidgets[ (int)widget.TrayLocation ]; if ( wList == null ) { wList = new WidgetList(); this.mWidgets[ (int)widget.TrayLocation ] = wList; } if ( wList.Contains( widget ) ) { wList.Remove( widget ); this.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 > this.mWidgets[ (int)trayLoc ].Count ) { place = this.mWidgets[ (int)trayLoc ].Count; } this.mWidgets[ (int)trayLoc ].Insert( place, widget ); // mWidgets[ (int)trayLoc ].Add( widget ); this.mTrays[ (int)trayLoc ].AddChild( widget.OverlayElement ); widget.OverlayElement.HorizontalAlignment = this.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); }
/// <summary> /// Adds a widget to a specified tray. /// </summary> /// <param name="widget"></param> /// <param name="trayLoc"></param> public void MoveWidgetToTray( Widget widget, TrayLocation trayLoc ) { MoveWidgetToTray( widget, trayLoc, -1 ); }
/// <summary> /// Destroys a widget. /// </summary> /// <param name="widget"></param> public void DestroyWidget( Widget widget ) { if ( widget == null ) { new AxiomException( "Widget does not exist,TrayManager.DestroyWidget" ); } // in case special widgets are destroyed manually, set them to 0 if ( widget == this.Logo ) { this.Logo = null; } else if ( widget == this.StatsPanel ) { this.StatsPanel = null; } else if ( widget == this.mFpsLabel ) { this.mFpsLabel = null; } this.mTrays[ (int)widget.TrayLocation ].RemoveChild( widget.Name ); WidgetList wList = this.mWidgets[ (int)widget.TrayLocation ]; wList.Remove( widget ); if ( widget == ExpandedMenu ) { ExpandedMenu = null; } widget.Cleanup(); this.mWidgetDeathRow.Add( widget ); AdjustTrays(); }
/// <summary> /// Gets a widget's position in its tray. /// </summary> /// <param name="widget"></param> /// <returns></returns> public int LocateWidgetInTray( Widget widget ) { for ( int i = 0; i < this.mWidgets[ (int)widget.TrayLocation ].Count; i++ ) { if ( this.mWidgets[ (int)widget.TrayLocation ][ i ] == widget ) { return i; } } return -1; }