private async void RemoteMultimediaOpsBus_EventBroadcasted(BusEvent e)
        {
            var dsp = Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher;

            if (!dsp.HasThreadAccess)
            {
                await dsp.RunAsync(CoreDispatcherPriority.Normal, () => RemoteMultimediaOpsBus_EventBroadcasted(e));

                return;
            }

            var remoteEvt = e.DataAs <RemoteEvent>();

            if (remoteEvt.Type == RemoteEventType.MultimediaControlSelectionChanged)
            {
                var payload = remoteEvt.Payload as SelectionChangedPayload;
                var vm      = ViewModelMapper.GetViewModel(payload.Context);

                if (vm == ViewModel)
                {
                    _allowSelectionChanged = false;
                    SelectedIndex          = payload.SelectedIndex;
                    _allowSelectionChanged = true;
                }
            }
        }
Exemple #2
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);
                }
            }
        }
        public HostedLayoutViewModel(ContentItem model)
            : base(model)
        {
            AddPage    = new RelayCommand(OnAddPage);
            RemovePage = new RelayCommand(OnRemovePage, CanExecuteRemovePage);


            var hostedLayout = ModelAs <HostedLayout>();
            var lst          = new List <HostedLayoutPageViewModel>();

            foreach (var x in hostedLayout.Pages)
            {
                var vm = (HostedLayoutPageViewModel)ViewModelMapper.GetViewModel(x);
                if (vm == null)
                {
                    vm = new HostedLayoutPageViewModel(x);
                }

                vm.Parent = this;
                lst.Add(vm);
            }

            foreach (var x in lst)
            {
                x.RelinkBrokenPageReferences(lst);
            }

            _pages = new ViewModelCollection <HostedLayoutPageViewModel, HostedLayoutPage>(hostedLayout.Pages, lst);
        }
Exemple #4
0
        private void OnWindowClosed(RemoteEvent obj)
        {
            var vm = ViewModelMapper.GetViewModel(obj.Payload);

            _remoteWindowOperationsBus.Publish(new RemoteWindowOperationEvent()
            {
                RemoteEvent = obj, ViewModel = vm
            }, this);
        }
Exemple #5
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());
        }
Exemple #6
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;
            }
        }
Exemple #7
0
        private void OnMenuItemSelected(RemoteEvent obj)
        {
            var vm = ViewModelMapper.GetViewModel(obj.Payload);

            _selectedMenuItemBus.Publish("remote", vm, obj);
        }