Exemplo n.º 1
0
        public HostedLayoutPageViewModel(HostedLayoutPage model)
            : base(model)
        {
            RemoveItem = new RelayCommand(OnRemoveItem, CanExecuteRemoveItem);
            var lst = new List <HostedLayoutItemViewModel>();

            foreach (var x in model.Items)
            {
                HostedLayoutItemViewModel vm = null;

                vm = (ContentAreaViewModel)ViewModelMapper.GetViewModel(x);
                if (vm == null)
                {
                    if (x is ContentArea)
                    {
                        vm = new ContentAreaViewModel(x);
                    }
                    else
                    if (x is ToggleItem)
                    {
                        vm = new ToggleItemViewModel(x);
                    }
                    else
                    if (x is ButtonItem)
                    {
                        vm = new ButtonItemViewModel(x);
                    }
                    else
                    if (x is InteractableItem)
                    {
                        vm = new InteractableItemViewModel(x);
                    }
                }

                if (vm == null)
                {
                    continue;
                }

                vm.Parent = this;

                lst.Add(vm);
            }
            _items = new ViewModelCollection <HostedLayoutItemViewModel, HostedLayoutItem>(model.Items, lst);
            _items.CollectionChanged += items_CollectionChanged;

            ContentAreas = new ObservableCollection <ContentAreaViewModel>(_items.Where(x => x is ContentAreaViewModel).Cast <ContentAreaViewModel>().ToList());
        }
Exemplo n.º 2
0
        public override HostedLayoutItemViewModel Clone()
        {
            var oldContent = ModelAs <InteractableItem>();

            var newContent = new InteractableItem()
            {
                Height               = oldContent.Height,
                Name                 = oldContent.Name,
                Shape                = oldContent.Shape.ToList(),
                Width                = oldContent.Width,
                X                    = oldContent.X,
                Y                    = oldContent.Y,
                Action               = oldContent.Action,
                ContentAreaTarget    = null,
                HighlightColor       = oldContent.HighlightColor,
                IsNonStandardHitArea = oldContent.IsNonStandardHitArea,
                ItemTarget           = oldContent.ItemTarget,
                PageTarget           = oldContent.PageTarget
            };

            var newVm = new InteractableItemViewModel(newContent);

            return(newVm);
        }