示例#1
0
 public RestartMenuCommand( /*IPlaybackManager playbackManager*/)
 {
     ExecuteCommand = new RelayCommand(arg => {
         //playbackManager.StopAllPlayback();
         Process.Start("shutdown", "/r /t 0");
     });
 }
示例#2
0
 public OpenSideMenuMenuCommand(INavigator navigator, ISessionManager sessionManager,IImageManager imageManager, IApiClient apiClient)
 {
     _sessionManager = sessionManager;
     _imageManager = imageManager;
     _apiClient = apiClient;
     ExecuteCommand = new RelayCommand(arg => navigator.Navigate(Go.To.SideMenu()));
 }
示例#3
0
 public SleepMenuCommand( /*IPlaybackManager playbackManager*/)
 {
     ExecuteCommand = new RelayCommand(arg => {
         //playbackManager.StopAllPlayback();
         Application.SetSuspendState(PowerState.Suspend, false, false);
     });
 }
示例#4
0
        public ItemSpotlightViewModel(IImageManager imageManager, IApiClient apiClient)
        {
            _apiClient = apiClient;
            _urlsToItems = new Dictionary<string, BaseItemDto>();
            Images = new ImageSlideshowViewModel(imageManager, Enumerable.Empty<string>()) {
                ImageStretch = Stretch.UniformToFill
            };

            Images.PropertyChanged += (s, e) => {
                if (e.PropertyName == "CurrentImageUrl") {
                    BaseItemDto item = CurrentItem;
                    CurrentCaption = item != null ? item.Name : null;
                    OnPropertyChanged("CurrentItem");
                }
            };

            ItemSelectedCommand = new RelayCommand(o => {
                BaseItemDto item = CurrentItem;
                Action<BaseItemDto> action = ItemSelectedAction;

                if (action != null && item != null) {
                    action(item);
                }
            });
        }
示例#5
0
        public PersonListItemViewModel(BaseItemPerson person, IApiClient apiClient, IImageManager imageManager, ISessionManager sessionManager, INavigator navigator)
        {
            _person = person;
            _apiClient = apiClient;
            _imageManager = imageManager;
            _sessionManager = sessionManager;
            _navigator = navigator;

            NavigateCommand = new RelayCommand(arg => NavigateToPerson());
        }
示例#6
0
        public ImageViewerViewModel(IImageManager imageManager, IEnumerable<ImageViewerImage> initialImages)
        {
            ImageStretch = Stretch.UniformToFill;

            _images.AddRange(initialImages);

            _dispatcher = Dispatcher.CurrentDispatcher;
            _imageManager = imageManager;

            CustomCommand = new RelayCommand(o => {
                ImageViewerImage img = _currentIndex == -1 ? null : Images[_currentIndex];

                if (img != null) {
                    CustomCommandAction(img);
                }
            });
        }
示例#7
0
        public MovieSpotlightViewModel(Task<MoviesView> moviesViewTask, IImageManager imageManager, INavigator navigator, IApiClient apiClient, IServerEvents serverEvents,
                                       IPlaybackManager playbackManager, ISessionManager sessionManager, ILogManager logManager)
        {
            _imageManager = imageManager;
            _navigator = navigator;
            _apiClient = apiClient;
            _serverEvents = serverEvents;
            _playbackManager = playbackManager;
            _sessionManager = sessionManager;
            _logger = logManager.GetLogger("Movies Spotlight");
            SpotlightHeight = HomeViewModel.TileHeight*2 + HomeViewModel.TileMargin*2;
            SpotlightWidth = 16*(SpotlightHeight/9) + 100;
            _miniSpotlightWidth = HomeViewModel.TileWidth + (HomeViewModel.TileMargin/4) - 1;

            LowerSpotlightWidth = SpotlightWidth/2 - HomeViewModel.TileMargin;
            LowerSpotlightHeight = HomeViewModel.TileHeight;

            BrowseMoviesCommand = new RelayCommand(arg => {
                var itemParams = new ItemListParameters { 
                    Items = GetMovies(),
                    Title = "Browse Movies"
                };

                navigator.Navigate(Go.To.ItemList(itemParams));

                //await navigator.Navigate(Go.To.Item(await _apiClient.GetPersonAsync("Chris Pine", sessionManager.CurrentUser.Id)));
            });

            SpotlightViewModel = new ItemSpotlightViewModel(imageManager, apiClient) {
                ImageType = ImageType.Backdrop,
                ItemSelectedAction = i => navigator.Navigate(Go.To.Item(i))
            };

            AllMoviesImagesViewModel = new ImageSlideshowViewModel(imageManager, Enumerable.Empty<string>()) {
                ImageStretch = Stretch.UniformToFill
            };

            MiniSpotlightItems = new RangeObservableCollection<ItemTileViewModel> {
                CreateMiniSpotlightItem(),
                CreateMiniSpotlightItem(),
                CreateMiniSpotlightItem(),
            };

            LoadViewModels(moviesViewTask);
        }
示例#8
0
        public UserLoginViewModel(UserDto user, IApiClient apiClient, IImageManager imageManager, ISessionManager sessionManager, ILogManager logManager)
        {
            _user = user;
            _apiClient = apiClient;
            _imageManager = imageManager;

            ILogger logger = logManager.GetLogger("Login");

            LoginCommand = new RelayCommand(async arg => {
                try {
                    IsInvalidLoginDetails = false;
                    await sessionManager.Login(Username, Password, RememberLogin);
                } catch (UnauthorizedAccessException) {
                    IsInvalidLoginDetails = true;
                } catch (Exception e) {
                    logger.ErrorException("Error while attempting to login", e);
                }
            });
        }
示例#9
0
        public ItemOverviewViewModel(BaseItemDto item, IApiClient apiClient, IImageManager imageManager, IPlaybackManager playbackManager, ISessionManager sessionManager)
        {
            _item = item;

            Artwork = new ItemArtworkViewModel(item, apiClient, imageManager) { DesiredImageHeight = 700 };
            Info = new ItemInfoViewModel(item);

            if (item.Type == "Episode")
                Artwork.PreferredImageTypes = new[] { ImageType.Screenshot, ImageType.Art, ImageType.Primary };

            Artwork.PropertyChanged += (s, e) => {
                if (e.PropertyName == "Size") {
                    OnPropertyChanged("Size");
                }
            };

            PlayCommand = new RelayCommand(o => playbackManager.Play(new PlayOptions(item) { GoFullScreen = true, EnableCustomPlayers = true, Resume = false }));
            ResumeCommand = new RelayCommand(o => playbackManager.Play(new PlayOptions(item) { GoFullScreen = true, EnableCustomPlayers = true, Resume = true }));
            PlayAllCommand = new RelayCommand(async o => {
                var items = await apiClient.GetItemsAsync(new Model.Querying.ItemQuery { ParentId = item.Id, UserId = sessionManager.CurrentUser.Id, Recursive = true, IncludeItemTypes = new[] { "Movie", "Episode", "Track" } });
                await playbackManager.Play(new PlayOptions(items.Items) { EnableCustomPlayers = true, GoFullScreen = true });
            });
        }
示例#10
0
        public OsdViewModel(IPlaybackManager playbackManager, IApiClient apiClient, IImageManager imageManager, IPresenter presentationManager, ILogger logger, INavigator nav, IServerEvents serverEvents, IEventAggregator events)
        {
            Logger = logger;
            PresentationManager = presentationManager;
            ImageManager = imageManager;
            ApiClient = apiClient;
            PlaybackManager = playbackManager;
            NavigationService = nav;
            _serverEvents = serverEvents;

            PauseCommand = new RelayCommand(Pause);
            StopCommand = new RelayCommand(Stop);
            SkipBackwardCommand = new RelayCommand(SkipBackward);
            SkipForwardCommand = new RelayCommand(SkipForward);
            NextChapterCommand = new RelayCommand(NextChapter);
            PreviousChapterCommand = new RelayCommand(PreviousChapter);
            PlayCommand = new RelayCommand(Play);
            PlayPauseCommand = new RelayCommand(PlayPause);

            _playbackStopHandler = args => NavigationService.Back();
            _playbackStartHandler = args => {
                MediaPlayer = args.Player;
                NowPlayingItem = args.Player.CurrentMedia;
            };

            events.Get<PlaybackStopEventArgs>().Subscribe(_playbackStopHandler, true);
            events.Get<PlaybackStartEventArgs>().Subscribe(_playbackStartHandler, true);
           
            MediaPlayer = playbackManager.MediaPlayers.FirstOrDefault(i => i.PlayState != PlayState.Idle);

            PresentationOptions = new RootPresentationOptions {
                IsFullScreenPage = true,
                ShowClock = false,
                ShowCommandBar = false,
                ShowMediaBrowserLogo = false
            };
        }
示例#11
0
        public ItemTileViewModel(IApiClient apiClient, IImageManager imageManager, IServerEvents serverEvents,
                                 INavigator navigator, IPlaybackManager playbackManager, BaseItemDto item)
        {
            _imageManager = imageManager;
            _navigator = navigator;
            _playbackManager = playbackManager;
            _item = item;

            Image = new ItemArtworkViewModel(item, apiClient, imageManager);
            Image.PreferredImageTypes = new[] { ImageType.Primary, ImageType.Thumb, ImageType.Backdrop };
            Image.EnforcePreferredImageAspectRatio = true;
            Image.PropertyChanged += (senger, args) => {
                if (args.PropertyName == "Size") {
                    OnPropertyChanged("Size");
                    OnPropertyChanged("ShowDisplayName");
                }
            };

            DisplayNameGenerator = GetDisplayNameWithAiredSpecial;
            GoToDetailsCommand = new RelayCommand(async o => navigator.Navigate(Go.To.Item(Item)));
            PlayCommand = new RelayCommand(o => _playbackManager.Play(new PlayOptions(Item) { GoFullScreen = true, EnableCustomPlayers = true, Resume = true }));

            serverEvents.UserDataChanged += serverEvents_UserDataChanged;
        }
示例#12
0
 public HomeCommand(INavigator navigator)
 {
     ExecuteCommand = new RelayCommand(arg => navigator.Navigate(Go.To.Home()));
 }
示例#13
0
        public WizardViewModel(IEnumerable<IWizardPage> pages)
        {
            _runs = pages.Select(p => new PageRun(p)).ToList();
            CurrentPage = _runs.First().CurrentPage;

            NextCommand = new RelayCommand(arg => MoveNext());
            PreviousCommand = new RelayCommand(arg => MoveBack());
            CancelCommand = new RelayCommand(arg => Cancel());
        }
示例#14
0
 public LogoutMenuCommand(ISessionManager session, INavigator navigator)
 {
     ExecuteCommand = new RelayCommand(async arg => {
         await session.Logout();
     });
 }
示例#15
0
 public ExitMenuCommand(ITheaterApplicationHost appHost)
 {
     ExecuteCommand = new RelayCommand(arg => appHost.Shutdown());
 }
示例#16
0
 public SearchMenuCommand(INavigator navigator)
 {
     ExecuteCommand = new RelayCommand(arg => navigator.Navigate(Go.To.Search()));
 }