public bool InsertWidget(WidgetsListControlItemViewModel widgetModel, int atIndex) { // The widget must not be null and must implement IWidgetItemModel if (widgetModel.WidgetItemModel is not IWidgetItemModel widgetItemModel) { return(false); } // Don't add existing ones! if (!CanAddWidget(widgetItemModel.WidgetName)) { return(false); } if (atIndex > Widgets.Count) { Widgets.Add(widgetModel); } else { Widgets.Insert(atIndex, widgetModel); } return(true); }
public void ReorderWidget(WidgetsListControlItemViewModel widgetModel, int place) { int widgetIndex = Widgets.IndexOf(widgetModel); Widgets.Move(widgetIndex, place); }
public bool AddWidget(WidgetsListControlItemViewModel widgetModel) { return(InsertWidget(widgetModel, Widgets.Count + 1)); }