public AbstractWidgetViewModel(LayoutWidgetType type, IDocumentEventing docEventing, ICommandProcessor cmdProcessor, TModel model) : base(cmdProcessor)
        {
            _docEventing = docEventing;
            _model       = model;
            Id           = model.Id;
            Type         = type;

            MouseDownCommand = new DelegateCommand(Canvas_MouseDown);
        }
Exemplo n.º 2
0
        public void InsertWidget(int insertRow, LayoutWidgetType widgetType)
        {
            AbstractWidget widgetModel = null;

            switch (widgetType)
            {
            case LayoutWidgetType.Label:
                widgetModel = new LabelWidget {
                    Id = Guid.NewGuid()
                };
                break;

            case LayoutWidgetType.Text:
                widgetModel = new TextWidget {
                    Id = Guid.NewGuid()
                };
                break;

            case LayoutWidgetType.Container:
                widgetModel = new ContainerWidget {
                    Id = Guid.NewGuid(), Items = new List <ContainerItem>()
                };
                break;

            default:
                throw new ArgumentException($"InsertWidget for widget {widgetType} not implemented");
            }

            if (insertRow == -1)
            {
                _model.Items.Add(new ContainerItem
                {
                    Row    = _model.Items.Count + 1,
                    Widget = widgetModel
                });
            }
            else
            {
                foreach (var item in _model.Items.Where(o => o.Row >= insertRow))
                {
                    item.Row = item.Row + 1;
                }
                _model.Items.Insert(insertRow, new ContainerItem
                {
                    Row    = insertRow,
                    Widget = widgetModel
                });
            }

            UpdateViewModels();
        }
Exemplo n.º 3
0
        private void AddToolboxItem(Visual documentBaseVisual, LayoutWidgetType type, string svgIcon, string caption)
        {
            var item = new LayoutingToolboxItemViewModel
            {
                Type               = type,
                SvgIcon            = svgIcon,
                Name               = caption,
                DocumentBaseVisual = documentBaseVisual
            };

            item.LayoutingItemDragStart += Item_LayoutingItemDragStart;
            item.LayoutingItemDragStop  += Item_LayoutingItemDragStop;
            ToolboxItems.Add(item);
        }