Beispiel #1
0
        public MainViewModel(IUserService userService, InteractionRequests interactionRequests)
            : base(userService)
        {
            this.OpenFileInteractionRequest       = interactionRequests.OpenFileInteractionRequest;
            this.DisplayMessageInteractionRequest = interactionRequests.DisplayMessageInteractionRequest;
            this.ConfirmationInteractionRequest   = interactionRequests.ConfirmationInteractionRequest;
            this.EditDurationInteractionRequest   = interactionRequests.EditDurationInteractionRequest;
            this.EditDateTimeInteractionRequest   = interactionRequests.EditDateTimeInteractionRequest;
            this.EditCGItemsInteractionRequest    = interactionRequests.EditCGItemsInteractionRequest;
            this.SaveFileInteractionRequest       = interactionRequests.SaveFileInteractionRequest;
            this.LoadPlaybillInteractionRequest   = interactionRequests.LoadPlaybillInteractionRequest;

            //_timer = timer;

            //_playItemCollection = new ObservableCollection<IPlayItem>();
            //_playItemsView = new CollectionView(_playItemCollection);



            //_playbill = new Playbill();
            //_playbill.PlayItemsChanged += Playbill_PlayItemsChanged;

            _collectGarbageCommand = new DelegateCommand(ExecuteCollectGarbage);

            _editMediaItemInteractionRequest = new InteractionRequest <EditMediaItemConfirmation>();
        }
        //private readonly DelegateCommand _createPlaybillCommand;

        public PlaybillViewModel(IEventAggregator eventAggregator,
                                 IMediaFileImageResolver imageResolver, IMediaFilePathResolver filePathResolver, InteractionRequests interactionRequests,
                                 IPlayoutConfiguration playoutConfig, IUserService userService)
        {
            _playoutConfig       = playoutConfig;
            _interactionRequests = interactionRequests;
            _userService         = userService;
            _playItemCollection  = new PlayItemCollection(filePathResolver, this);

            this.ImageResolver = imageResolver;

            _savePlaybillCommand = new DelegateCommand(SavePlaybill, CanSavePlaybill);
            _loadPlaybillCommand = new DelegateCommand(LoadPlaybill, CanLoadPlaybill);

            this.Playlist = new Playlist(_playItemCollection);
            this.Playlist.EditCompleted += Playlist_EditCompleted;

            _listAdapter = new WrappedItemListAdapter <BindablePlayItem, IPlayItem>(_playItemCollection,
                                                                                    (i) => _playItemCollection.CreateBindablePlayItem(i));


            _deletePlayItemCommand = new DelegateCommand(DeletePlayItem, CanDeletePlayItem);

            _editDurationCommand    = new DelegateCommand(EditDuration, CanEditDuration);
            _changeStartTimeCommand = new DelegateCommand(ChangeStartTime, CanChangeStartTime);

            _changeToAutoModeCommand   = new DelegateCommand(ChangeToAutoMode, CanChangeToAutoMode);
            _changeToBreakModeCommand  = new DelegateCommand(ChangeToBreakMode, CanChangeToBreakMode);
            _changeToTimingModeCommand = new DelegateCommand(ChangeToTimingMode, CanChangeToTimingMode);

            _moveUpCommand   = new DelegateCommand(MoveUp, CanMoveUp);
            _moveDownCommand = new DelegateCommand(MoveDown, CanMoveDown);

            //
            _saveXmlCommand = new DelegateCommand(SaveXml, CanSaveXml);
            _openXmlCommand = new DelegateCommand(OpenXml);

            _clearCommand       = new DelegateCommand(Clear, CanClear);
            _editCGItemsCommand = new DelegateCommand(EditCGItems, CanEditCGItems);

            _previewCommand = new DelegateCommand <IPlayableItem>(Preview);

            _changeSourceCommand            = new DelegateCommand(ChangeSource, CanChangeSource);
            _changeSourceAndDurationCommand = new DelegateCommand(ChangeSourceAndDuration, CanChangeSourceAndDuration);

            _eventAggregator = eventAggregator;
            _eventAggregator.GetEvent <PubSubEvent <AddPlayItemPayload> >().Subscribe(AddPlayItem);

            _eventAggregator.GetEvent <PubSubEvent <MediaItem?> >().Subscribe((i) => this.SelectedMediaItem = i);
        }