Exemplo n.º 1
0
        public InteractableItemViewModel(HostedLayoutItem model)
            : base(model)
        {
            _clearContentCommand = new RelayCommand(OnClearContent);
            _importStringCommand = new RelayCommand(OnImportString);

            var ii = ModelAs <InteractableItem>();

            if (ii.ContentAreaTarget != null)
            {
                _contentAreaTarget = (ContentAreaViewModel)ViewModelMapper.GetViewModel(ii.ContentAreaTarget);
                if (_contentAreaTarget == null)
                {
                    _contentAreaTarget = new ContentAreaViewModel(ii.ContentAreaTarget);
                }
            }

            if (ii.ItemTarget != null)
            {
                _itemTarget = (ContentItemViewModel)ViewModelMapper.GetViewModel(ii.ItemTarget);
                if (_itemTarget == null)
                {
                    _itemTarget = ContentItemViewModel.CreateItem(ii.ItemTarget);
                }
            }

            if (ii.PageTarget != null)
            {
                _pageTarget = (HostedLayoutPageViewModel)ViewModelMapper.GetViewModel(ii.PageTarget);
                if (_pageTarget == null)
                {
                    _pageTarget = new HostedLayoutPageViewModel(ii.PageTarget);
                }
            }
        }
Exemplo n.º 2
0
        public ContentAreaViewModel(HostedLayoutItem model)
            : base(model)
        {
            _clearContentCommand = new RelayCommand(OnClearContent);

            var contentArea = ModelAs <ContentArea>();

            if (contentArea.HasContent)
            {
                var contentVm = ViewModelMapper.GetViewModel(contentArea.Content);
                if (contentVm == null)
                {
                    contentVm = ContentItemViewModel.CreateItem(contentArea.Content);
                }

                Content = (ContentItemViewModel)contentVm;
            }
        }
Exemplo n.º 3
0
        private void Visit(List <ContentItemViewModel> target, ContentItemViewModel item)
        {
            if (item.Children == null || item.Children.Count == 0)
            {
                target.Add(item);
                return;
            }

            foreach (var contentItemViewModel in item.Children)
            {
                Visit(target, contentItemViewModel);
            }

            if (item is HostedLayoutViewModel)
            {
                target.Add(item);
            }
        }