コード例 #1
0
        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);
        }
コード例 #2
0
        public void ReorderWidget(WidgetsListControlItemViewModel widgetModel, int place)
        {
            int widgetIndex = Widgets.IndexOf(widgetModel);

            Widgets.Move(widgetIndex, place);
        }
コード例 #3
0
 public bool AddWidget(WidgetsListControlItemViewModel widgetModel)
 {
     return(InsertWidget(widgetModel, Widgets.Count + 1));
 }