/// <summary> /// Called to add a new widget to the collection, note that we may have to add a new row or column /// to the display in order that the widget can be displayed /// </summary> /// <param name="widget"></param> public bool Add(DefaultWidget widget) { // we have a free space in the grid so add this widget into the grid _listWidgets.Add(widget); this.Controls.Add(widget); layoutManager.SetIncludeInLayout(widget, true); // Re-Layout the widgets if (_listWidgets.Count == 4) { LayoutWidgets(); } return(true); }
/// <summary> /// Remove a widget from the display /// </summary> /// <param name="widgetName"></param> /// <returns></returns> public bool RemoveWidget(string widgetName) { DefaultWidget widget = GetWidget(widgetName); if (widget == null) { return(false); } // OK so this is a valid widget - however is it already displayed? // If so then we should remove it if (IsWidgetDisplayed(widgetName)) { _widgetView.Remove(widget); } return(true); }
/// <summary> /// Add a widget to the display /// </summary> /// <param name="widgetName"></param> /// <returns></returns> public bool DisplayWidget(string widgetName) { DefaultWidget widget = GetWidget(widgetName); if (widget == null) { return(false); } // OK so this is a valid widget - however is it already displayed? // If not then we should add it if (!IsWidgetDisplayed(widgetName)) { _widgetView.Add(widget); } return(true); }
/// <summary> /// Called to remove a widget from the collection, note that we may have to delete rows/columns /// from the display to clean up after this widget is removed /// </summary> /// <param name="widget"></param> public bool Remove(DefaultWidget widgetToRemove) { // Remove the control from the form this.Controls.Remove(widgetToRemove); // ...and from our internal list _listWidgets.Remove(widgetToRemove); // We have lost one item - if the column count is greater than the row count then reduce the columns // otherwise reduce the row to keep our required shape. if (columnCount > rowCount) { columnCount--; } else { rowCount--; } // Re-Layout the widgets LayoutWidgets(); return(true); }