Exemple #1
0
        public MainViewModel(IMediator mediator,
                             IHomeViewModel homeViewModel,
                             IFilmListViewModel filmListViewModel,
                             IActorListViewModel actorListViewModel,
                             IDirectorListViewModel directorListViewModel,
                             IFilmDetailViewModel filmDetailViewModel,
                             IActorDetailViewModel actorDetailViewModel,
                             IDirectorDetailViewModel directorDetailViewModel)
        {
            HomeViewModel           = homeViewModel;
            FilmListViewModel       = filmListViewModel;
            ActorListViewModel      = actorListViewModel;
            DirectorListViewModel   = directorListViewModel;
            FilmDetailViewModel     = filmDetailViewModel;
            ActorDetailViewModel    = actorDetailViewModel;
            DirectorDetailViewModel = directorDetailViewModel;

            HomeButtonCommand      = new RelayCommand(OnHomeButtonCommandExecute);
            FilmsButtonCommand     = new RelayCommand(OnFilmsButtonCommandExecute);
            ActorsButtonCommand    = new RelayCommand(OnActorsButtonCommandExecute);
            DirectorsButtonCommand = new RelayCommand(OnDirectorsButtonCommandExecute);

            mediator.Register <DetailButtonPushedMessage <FilmWrappedModel> >(OnFilmDetailExecute);
            mediator.Register <DetailButtonPushedMessage <ActorWrappedModel> >(OnActorDetailExecute);
            mediator.Register <DetailButtonPushedMessage <DirectorWrappedModel> >(OnDirectorDetailExecute);

            mediator.Register <NewMessage <FilmWrappedModel> >(AddNewFilm);
            mediator.Register <NewMessage <ActorWrappedModel> >(AddNewActor);
            mediator.Register <NewMessage <DirectorWrappedModel> >(AddNewDirector);

            mediator.Register <MoveToDetailMessage <FilmActorWrappedModel> >(MoveToFilmFromActor);
            mediator.Register <MoveToDetailMessage <FilmDirectorWrappedModel> >(MoveToFilmFromDirector);

            mediator.Register <MoveToDetailMessage <ActorWrappedModel> >(MoveToActorFromFilm);
            mediator.Register <MoveToDetailMessage <DirectorWrappedModel> >(MoveToDirectorFromFilm);
            mediator.Register <MoveToDetailMessage <FilmWrappedModel> >(MoveToFilm);

            selectedView = HomeViewModel;
        }
Exemple #2
0
        public MainViewModel(
            IMediator mediator,
            IFilmListViewModel filmListViewModel,
            IPersonListViewModel personListViewModel,
            ISearchViewModel searchViewModel,
            IFactory <IFilmDetailViewModel> filmDetailViewModelFactory,
            IFactory <IPersonDetailViewModel> personDetailViewModelFactory)
        {
            _mediator = mediator;

            FilmListViewModel   = filmListViewModel;
            PersonListViewModel = personListViewModel;
            SearchViewModel     = searchViewModel;

            _filmDetailViewModelFactory   = filmDetailViewModelFactory;
            _personDetailViewModelFactory = personDetailViewModelFactory;

            FilmDetailViewModel   = _filmDetailViewModelFactory.Create();
            PersonDetailViewModel = _personDetailViewModelFactory.Create();

            CloseFilmDetailTabCommand              = new RelayCommand(OnCloseFilmDetailTabExecute);
            ClosePersonDetailTabCommand            = new RelayCommand(OnClosePersonDetailTabExecute);
            FilmDetailTabSelectionChangedCommand   = new RelayCommand <FilmDetailViewModel>(FilmDetailTabChanged);
            PersonDetailTabSelectionChangedCommand = new RelayCommand <PersonDetailViewModel>(PersonDetailTabChanged);

            mediator.Register <NewMessage <FilmWrapper> >(OnFilmNewMessage);
            mediator.Register <NewMessage <PersonWrapper> >(OnPersonNewMessage);

            mediator.Register <SelectedMessage <FilmWrapper> >(OnFilmSelected);
            mediator.Register <SelectedMessage <PersonWrapper> >(OnPersonSelected);

            mediator.Register <UpdateMessage <FilmWrapper> >(OnFilmUpdated);
            mediator.Register <UpdateMessage <PersonWrapper> >(OnPersonUpdated);

            mediator.Register <DeleteMessage <FilmWrapper> >(OnFilmDeleted);
            mediator.Register <DeleteMessage <PersonWrapper> >(OnPersonDeleted);
        }