public FavoritesViewModel(IPresentationManager presentation, IImageManager imageManager, IApiClient apiClient, ISessionManager session, INavigationService nav, IPlaybackManager playback, ILogger logger, double tileWidth, double tileHeight, IServerEvents serverEvents)
            : base(presentation, apiClient)
        {
            _sessionManager  = session;
            _playbackManager = playback;
            _imageManager    = imageManager;
            _navService      = nav;
            _logger          = logger;
            _serverEvents    = serverEvents;

            TileWidth  = tileWidth;
            TileHeight = tileHeight;

            var spotlightTileWidth  = TileWidth * 2 + TilePadding;
            var spotlightTileHeight = spotlightTileWidth * 9 / 16;

            SpotlightViewModel = new ImageViewerViewModel(_imageManager, new List <ImageViewerImage>())
            {
                Height = spotlightTileHeight,
                Width  = spotlightTileWidth,
                CustomCommandAction = i => _navService.NavigateToItem(i.Item, ViewType.Tv)
            };

            LoadViewModels();

            NavigateToFavoriteMoviesCommand = new RelayCommand(o => NavigateToFavorites("Movie"));
        }
Exemple #2
0
 public MainWindow(ImageViewerViewModel imageViewerViewModel, IErrorHandler errorHandler)
 {
     DataContext = imageViewerViewModel;
     imageViewerViewModel.PropertyChanged += ImageViewerViewModel_PropertyChanged;
     InitializeComponent();
     this.errorHandler = errorHandler;
 }
Exemple #3
0
        public static void DisplayImage(BitmapSource bitmap)
        {
            ImageViewer          view      = new ImageViewer();
            ImageViewerViewModel viewModel = new ImageViewerViewModel();

            viewModel.Image  = bitmap;
            view.DataContext = viewModel;
            view.Show();
        }
 private void InitWith(ImageViewerViewModel ivvm, Func <int, Image> getImageByIdFunc, FrameworkElement currentViewControl = null, Action <int> setContextOnViewControl = null, Action <int, bool> showHideOverlay = null)
 {
     this._imageViewerVM           = ivvm;
     this._getImageByIdFunc        = getImageByIdFunc;
     this._currentViewControl      = currentViewControl;
     this._setContextOnViewControl = setContextOnViewControl;
     this._showHideOverlay         = showHideOverlay;
     this.HandlePhotoUpdate(ivvm);
 }
Exemple #5
0
        public ImageViewerPage(IPresentationManager presentation, ImageViewerViewModel viewModel)
        {
            _presentation = presentation;
            InitializeComponent();

            DataContext = viewModel;

            Loaded   += ImageViewerPage_Loaded;
            Unloaded += ImageViewerPage_Unloaded;
        }
        public static void ShowPhotosFromProfile(long userOrGroupId, bool isGroup, int selectedPhotoIndex, List <Photo> photos, bool canLoadMoreProfileListPhotos)
        {
            ImageViewerViewModel   imageViewerViewModel    = new ImageViewerViewModel(userOrGroupId, isGroup, photos, canLoadMoreProfileListPhotos, 0L);
            ImageViewerDecoratorUC decoratorForCurrentPage = ImageViewerDecoratorUC.GetDecoratorForCurrentPage(null);
            ImageViewerViewModel   ivvm = imageViewerViewModel;

            decoratorForCurrentPage.InitWith(ivvm, (Func <int, Image>)(i => null), null, null, null);
            int ind = selectedPhotoIndex;

            decoratorForCurrentPage.Show(ind);
        }
Exemple #7
0
        public TvViewModel(IPresentationManager presentation, IImageManager imageManager, IApiClient apiClient, ISessionManager session, INavigationService nav, IPlaybackManager playback, ILogger logger, double tileWidth, double tileHeight, IServerEvents serverEvents, string parentId)
            : base(presentation, apiClient)
        {
            _sessionManager  = session;
            _playbackManager = playback;
            _imageManager    = imageManager;
            _navService      = nav;
            _logger          = logger;
            _serverEvents    = serverEvents;
            ParentId         = parentId;

            TileWidth  = tileWidth;
            TileHeight = tileHeight;

            var spotlightTileHeight = TileHeight * 2 + TileMargin * 2;
            var spotlightTileWidth  = 16 * (spotlightTileHeight / 9) + 100;

            var lowerSpotlightWidth = spotlightTileWidth / 3 - (TileMargin * 1.5);

            SpotlightViewModel = new ImageViewerViewModel(_imageManager, new List <ImageViewerImage>())
            {
                Height = spotlightTileHeight,
                Width  = spotlightTileWidth,
                CustomCommandAction  = i => _navService.NavigateToItem(i.Item, ViewType.Tv),
                ImageStretch         = Stretch.UniformToFill,
                FocusedCommandAction = () => GalleryItemFocused()
            };

            GenresViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight        = TileHeight,
                GalleryWidth         = lowerSpotlightWidth,
                CustomCommandAction  = () => NavigateWithLoading(NavigateToGenresInternal),
                FocusedCommandAction = () => GalleryItemFocused()
            };

            AllShowsViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight        = TileHeight,
                GalleryWidth         = lowerSpotlightWidth,
                CustomCommandAction  = () => NavigateWithLoading(NavigateToAllShows),
                FocusedCommandAction = () => GalleryItemFocused()
            };

            UpcomingViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight        = TileHeight,
                GalleryWidth         = lowerSpotlightWidth,
                CustomCommandAction  = () => NavigateWithLoading(NavigateToAllShows),
                FocusedCommandAction = () => GalleryItemFocused()
            };

            LoadViewModels();
        }
        public void Setup()
        {
            _tmpfolder = new TemporaryFolder("projectTest");

            var image     = new Bitmap(100, 200);
            var imageFile = _tmpfolder.Combine("junk.jpg");

            image.Save(imageFile, System.Drawing.Imaging.ImageFormat.Jpeg);

            _model = new ImageViewerViewModel(imageFile, new[] { 5, 10, 15, 20 });
        }
 private void OpenImageViewer()
 {
     if (ImageViewer == null)
     {
         ImageViewer = new ImageViewerViewModel(StateService, DownloadVideoFileManager, true)
         {
             DialogDetails = this
         };
         NotifyOfPropertyChange(() => ImageViewer);
     }
     BeginOnUIThread(() => ImageViewer.OpenViewer());
 }
        public static void ShowPhotosFromAlbum(string aid, int albumType, long userOrGroupId, bool isGroup, int photosCount, int selectedPhotoIndex, List <Photo> photos, Func <int, Image> getImageByIdFunc)
        {
            ImageViewerViewModel   imageViewerViewModel    = new ImageViewerViewModel(aid, (AlbumType)albumType, userOrGroupId, isGroup, photosCount, photos);
            ImageViewerDecoratorUC decoratorForCurrentPage = ImageViewerDecoratorUC.GetDecoratorForCurrentPage(null);
            ImageViewerViewModel   ivvm = imageViewerViewModel;
            Func <int, Image>      getImageByIdFunc1 = getImageByIdFunc;

            decoratorForCurrentPage.InitWith(ivvm, getImageByIdFunc1, null, null, null);
            int ind = selectedPhotoIndex;

            decoratorForCurrentPage.Show(ind);
        }
Exemple #11
0
        public ImageViewer(StartViewerApplicationRequest startRequest)
        {
            InitializeComponent();
            ViewModel = new ImageViewerViewModel
            {
                IsLoading = true
            };

            DataContext = ViewModel;

            if (ApplicationContext.Current != null)
            {
                ApplicationContext.Initialize();
                if (ApplicationContext.Current == null)
                {
                    throw new Exception();
                }
            }

            EventMediator = new ServerEventMediator();
            EventMediator.Initialize(ApplicationContext.Current.Parameters);

            EventMediator.CriticalError += ErrorHandler_OnCriticalError;

            EventMediator.RegisterEventHandler(typeof(ApplicationStartedEvent), ApplicationStarted);
            EventMediator.RegisterEventHandler(typeof(SessionUpdatedEvent), OnSessionUpdated);
            EventMediator.RegisterEventHandler(typeof(MessageBoxShownEvent), OnMessageBox);
            EventMediator.ServerApplicationStopped += OnServerApplicationStopped;

            _studyView = new StudyView(EventMediator);
            StudyViewContainer.Children.Add(_studyView);
            MouseHelper.SetBackgroundElement(LayoutRoot);

            if (startRequest == null)
            {
                //TODO: replace this with the custom dialog. For some reason, it doesn't work here.
                System.Windows.MessageBox.Show(ErrorMessages.MissingParameters);
            }
            else
            {
                ToolstripViewComponent.EventDispatcher = EventMediator;

                LayoutRoot.MouseLeftButtonDown  += ToolstripViewComponent.OnLoseFocus;
                LayoutRoot.MouseRightButtonDown += ToolstripViewComponent.OnLoseFocus;

                EventMediator.StartApplication(startRequest);

                TileView.ApplicationRootVisual = _studyView.StudyViewCanvas;

                LayoutRoot.KeyUp += OnKeyUp;
            }
        }
        public ActionResult ShowImage(string id)
        {
            // use this for container that has access type set to Blob
            // Uri imageUri = _imageStoreService.GetResourceUri(id);

            var viewModel = new ImageViewerViewModel()
            {
                Uri        = _imageStoreService.GetResourceUriWithSas(id),
                ResourceId = id
            };

            return(View(viewModel));
        }
 public ImageViewerWindow()
 {
     InitializeComponent();
     this.Top    = Properties.Settings.Default.Top;
     this.Left   = Properties.Settings.Default.Left;
     this.Height = Properties.Settings.Default.Height;
     this.Width  = Properties.Settings.Default.Width;
     if (Properties.Settings.Default.Maximized)
     {
         WindowState = WindowState.Maximized;
     }
     m_ImageViewerViewModel = new ImageViewerViewModel();
     this.DataContext       = m_ImageViewerViewModel;
 }
        public ImageViewerViewModelTests()
        {
            _galleryManager            = Substitute.For <IGalleryManager>();
            _directoryPathProviderMock = Substitute.For <IDirectoryPathProvider>();
            _errorHandlerMock          = Substitute.For <IErrorHandler>();
            _confirmationServiceMock   = Substitute.For <IConfirmationService>();
            _newImageDataProvider      = Substitute.For <INewImageDataProvider>();

            _viewModel = Substitute.ForPartsOf <ImageViewerViewModel>(
                _galleryManager,
                _directoryPathProviderMock,
                _errorHandlerMock,
                _confirmationServiceMock,
                _newImageDataProvider);
        }
        public static void ShowPhotosOrGifsById(int selectedPhotoIndex, List <PhotoOrDocument> photoOrDocList, bool fromDialog = false, bool friendsOnly = false, Func <int, Image> getImageByIdFunc = null, PageBase page = null, bool hideActions = false, FrameworkElement currentViewControl = null, Action <int> setContextOnCurrentViewControl = null, Action <int, bool> showHideOverlay = null, bool shareButtonOnly = false)
        {
            ImageViewerViewModel   ivvm = new ImageViewerViewModel(photoOrDocList);
            ImageViewerDecoratorUC decoratorForCurrentPage = ImageViewerDecoratorUC.GetDecoratorForCurrentPage(page);

            decoratorForCurrentPage.InitWith(ivvm, getImageByIdFunc, currentViewControl, setContextOnCurrentViewControl, showHideOverlay);
            decoratorForCurrentPage._fromDialog  = fromDialog;
            decoratorForCurrentPage._friendsOnly = friendsOnly;
            decoratorForCurrentPage._hideActions = hideActions;
            if (hideActions)
            {
                decoratorForCurrentPage.gridBottom.Visibility = Visibility.Collapsed;
            }
            decoratorForCurrentPage.Show(selectedPhotoIndex);
        }
        public static void ShowPhotosById(int photosCount, int initialOffset, int selectedPhotoIndex, List <long> photoIds, List <long> ownerIds, List <string> accessKeys, List <Photo> photos, bool fromDialog = false, bool friendsOnly = false, Func <int, Image> getImageByIdFunc = null, PageBase page = null, bool hideActions = false)
        {
            ViewerMode             mode = ViewerMode.PhotosByIds;
            ImageViewerViewModel   ivvm = new ImageViewerViewModel(photosCount, initialOffset, photoIds, ownerIds, accessKeys, photos, mode);
            ImageViewerDecoratorUC decoratorForCurrentPage = ImageViewerDecoratorUC.GetDecoratorForCurrentPage(page);

            decoratorForCurrentPage.InitWith(ivvm, getImageByIdFunc, null, null, null);
            decoratorForCurrentPage._fromDialog  = fromDialog;
            decoratorForCurrentPage._friendsOnly = friendsOnly;
            decoratorForCurrentPage._hideActions = hideActions;
            if (hideActions)
            {
                decoratorForCurrentPage.gridBottom.Visibility = Visibility.Collapsed;
            }
            decoratorForCurrentPage.Show(selectedPhotoIndex);
        }
        public static void ShowPhotosFromFeed(long userOrGroupId, bool isGroup, string aid, int photosCount, int selectedPhotoIndex, int date, List <Photo> photos, string mode, Func <int, Image> getImageByIdFunc)
        {
            ViewerMode             mode1 = (ViewerMode)Enum.Parse(typeof(ViewerMode), mode);
            ImageViewerViewModel   ivvm  = new ImageViewerViewModel(userOrGroupId, isGroup, aid, photosCount, date, photos, mode1);
            ImageViewerDecoratorUC dec   = ImageViewerDecoratorUC.GetDecoratorForCurrentPage(null);

            dec.InitWith(ivvm, getImageByIdFunc, null, null, null);
            ivvm.LoadPhotosFromFeed((Action <bool>)(res =>
            {
                if (!res)
                {
                    return;
                }
                Execute.ExecuteOnUIThread((Action)(() => dec.HandlePhotoUpdate(ivvm)));
            }));
            dec.Show(selectedPhotoIndex);
        }
        private async void OpenImageViewer(object commandParameter)
        {
            var image = (GalleryImageViewModel)commandParameter;

            var isBackdrop = image.ImageUrl.IndexOf("backdrop", StringComparison.OrdinalIgnoreCase) != -1;

            var images = GetImages(Item, _apiClient, Convert.ToInt32(SystemParameters.VirtualScreenWidth), null, !isBackdrop);

            var selectedIndex = ListCollectionView.IndexOf(image);

            images = images.Skip(selectedIndex).Concat(images.Take(selectedIndex)).ToList();

            var initialImages = images.Select(i => new ImageViewerImage {
                Url = i, Caption = Item.Name
            });

            var vm = new ImageViewerViewModel(_imageManager, initialImages);

            await _navigation.NavigateToImageViewer(vm);
        }
Exemple #19
0
        public GalleryImageSelectorTests()
        {
            _galleryManager            = Substitute.For <IGalleryManager>();
            _directoryPathProviderMock = Substitute.For <IDirectoryPathProvider>();
            _errorHandlerMock          = Substitute.For <IErrorHandler>();
            _confirmationServiceMock   = Substitute.For <IConfirmationService>();
            _newImageDataProvider      = Substitute.For <INewImageDataProvider>();

            _viewModel = new ImageViewerViewModel(
                _galleryManager,
                _directoryPathProviderMock,
                _errorHandlerMock,
                _confirmationServiceMock,
                _newImageDataProvider);

            _testGallery = new ImageGallery("Test name", new List <GalleryImageInfo>
            {
                new GalleryImageInfo("fullname\\name.jpg", true, new CreditsEntry
                {
                    PhotoUrl = "url",
                    UserName = "******",
                    UserUrl  = "userurl",
                }),
                new GalleryImageInfo("fullname\\name1.jpg", true, new CreditsEntry
                {
                    PhotoUrl = "url1",
                    UserName = "******",
                    UserUrl  = "userurl1",
                }),
                new GalleryImageInfo("fullname\\name2.jpg", true, new CreditsEntry
                {
                    PhotoUrl = "url2",
                    UserName = "******",
                    UserUrl  = "userurl2",
                }),
            });

            _galleryManager.OpenGallery(Arg.Any <string>()).Returns(_testGallery);
            _viewModel.OpenGallery();
        }
 private void HandlePhotoUpdate(ImageViewerViewModel ivvm)
 {
     if (this._imageViewerVM != ivvm)
     {
         return;
     }
     this.imageViewer.Initialize(ivvm.PhotosCollection.Count, (Func <int, ImageInfo>)(ind =>
     {
         Func <int, Image> getImageByIdFunc = this._getImageByIdFunc;
         Image image1;
         if (getImageByIdFunc == null)
         {
             image1 = null;
         }
         else
         {
             int num = ind;
             image1  = getImageByIdFunc(num);
         }
         Image image2        = image1;
         ImageInfo imageInfo = new ImageInfo();
         if (ind == this.imageViewer.CurrentInd && this.imageViewer.CurrentImage.Source is BitmapImage)
         {
             BitmapImage source = this.imageViewer.CurrentImage.Source as BitmapImage;
             imageInfo.Width    = (double)((BitmapSource)source).PixelWidth;
             imageInfo.Height   = (double)((BitmapSource)source).PixelHeight;
         }
         if ((image2 != null ? image2.Source : null) is BitmapImage)
         {
             BitmapImage source = (BitmapImage)image2.Source;
             imageInfo.Width    = (double)((BitmapSource)source).PixelWidth;
             imageInfo.Height   = (double)((BitmapSource)source).PixelHeight;
         }
         if (ind < 0 || ind >= ivvm.PhotosCollection.Count)
         {
             return(null);
         }
         PhotoViewModel photos = ivvm.PhotosCollection[ind];
         if (imageInfo.Width == 0.0)
         {
             imageInfo.Width = (double)photos.Photo.width;
         }
         if (imageInfo.Height == 0.0)
         {
             imageInfo.Height = (double)photos.Photo.height;
         }
         imageInfo.Uri = photos.ImageSrc;
         return(imageInfo);
     }), this._getImageByIdFunc, (Action <int, bool>)((ind, show) =>
     {
         Func <int, Image> getImageByIdFunc = this._getImageByIdFunc;
         Image image1;
         if (getImageByIdFunc == null)
         {
             image1 = null;
         }
         else
         {
             int num = ind;
             image1  = getImageByIdFunc(num);
         }
         Image image2 = image1;
         if (image2 != null)
         {
             image2.Opacity = (show ? 1.0 : 0.0);
         }
         Action <int, bool> showHideOverlay = this._showHideOverlay;
         if (showHideOverlay == null)
         {
             return;
         }
         int num1 = ind;
         int num2 = show ? 1 : 0;
         showHideOverlay(num1, num2 != 0);
     }), this._currentViewControl, this._setContextOnViewControl);
 }
 public ImageViewerPage(ImageViewerViewModel viewModel, INavigationStackManager navigationStackManager)
     : base(viewModel, navigationStackManager)
 {
     _viewModel = viewModel;
     BuildControls();
 }
Exemple #22
0
        public ImageViewer()
        {
            InitializeComponent();

            DataContext = new ImageViewerViewModel();
        }
        public TvViewModel(IPresentationManager presentation, IImageManager imageManager, IApiClient apiClient, ISessionManager session, INavigationService nav, IPlaybackManager playback, ILogger logger, double tileWidth, double tileHeight, IServerEvents serverEvents)
            : base(presentation, apiClient)
        {
            _sessionManager  = session;
            _playbackManager = playback;
            _imageManager    = imageManager;
            _navService      = nav;
            _logger          = logger;
            _serverEvents    = serverEvents;

            TileWidth  = tileWidth;
            TileHeight = tileHeight;

            NextUpViewModel = new ItemListViewModel(GetNextUpAsync, presentation, imageManager, apiClient, nav, playback, logger, _serverEvents)
            {
                ImageDisplayWidth             = TileWidth,
                ImageDisplayHeightGenerator   = v => TileHeight,
                DisplayNameGenerator          = HomePageViewModel.GetDisplayName,
                EnableBackdropsForCurrentItem = false
            };

            LatestEpisodesViewModel = new ItemListViewModel(GetLatestEpisodes, presentation, imageManager, apiClient, nav, playback, logger, _serverEvents)
            {
                ImageDisplayWidth             = TileWidth,
                ImageDisplayHeightGenerator   = v => TileHeight,
                DisplayNameGenerator          = HomePageViewModel.GetDisplayName,
                EnableBackdropsForCurrentItem = false
            };

            ResumeViewModel = new ItemListViewModel(GetResumeablesAsync, presentation, imageManager, apiClient, nav, playback, logger, _serverEvents)
            {
                ImageDisplayWidth             = TileWidth,
                ImageDisplayHeightGenerator   = v => TileHeight,
                DisplayNameGenerator          = HomePageViewModel.GetDisplayName,
                EnableBackdropsForCurrentItem = false
            };
            ResumeViewModel.PropertyChanged += ResumeViewModel_PropertyChanged;

            const double tileScaleFactor = 13;

            ActorsViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight       = TileHeight,
                GalleryWidth        = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToActorsInternal)
            };

            GenresViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight       = TileHeight,
                GalleryWidth        = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToGenresInternal)
            };

            AllShowsViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight       = TileHeight,
                GalleryWidth        = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToAllShowsInternal)
            };

            RomanticSeriesViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight       = TileHeight,
                GalleryWidth        = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToRomanticTvInternal)
            };

            ComedyItemsViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight       = TileHeight,
                GalleryWidth        = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToComedySeriesInternal)
            };

            var spotlightTileWidth  = TileWidth * 2 + TilePadding;
            var spotlightTileHeight = spotlightTileWidth * 9 / 16;

            SpotlightViewModel = new ImageViewerViewModel(_imageManager, new List <ImageViewerImage>())
            {
                Height = spotlightTileHeight,
                Width  = spotlightTileWidth,
                CustomCommandAction = i => _navService.NavigateToItem(i.Item, ViewType.Tv),
                ImageStretch        = Stretch.UniformToFill
            };

            LoadViewModels();
        }
Exemple #24
0
 public Task NavigateToImageViewer(ImageViewerViewModel viewModel)
 {
     return(Navigate(new ImageViewerPage(_presentationManager, viewModel)));
 }
Exemple #25
0
 public MainWindow()
 {
     InitializeComponent();
     DataContext = new ImageViewerViewModel();
 }
 public ImageViewerWindow(string file)
 {
     InitializeComponent();
     m_ImageViewerViewModel = new ImageViewerViewModel();
     this.DataContext       = m_ImageViewerViewModel;
 }
Exemple #27
0
        public Task EndInit()
        {
            Action <DisplayMessageModel> action = (obj) =>
            {
                if (_core.TryGetUiManager(out IUiManager ui))
                {
                    //ui.Unlock();
                }

                try
                {
                    if (_core.TryGetBilling(out IBillingManager billing))
                    {
                        var userServices = billing.GetActiveUserServices()
                                           .Select(p => p.Plugin)
                                           .Distinct()
                                           .ToList();
                        var serv = obj.Data.Services;
                        if (serv.Count > 0 && serv.All(billing.IsPluginFree))
                        {
                            return;
                        }

                        if (serv.Count >= 0 && _core.UserService.User.Id != null && serv.Any(s => userServices?.Contains(s) == true))
                        {
                            return;
                        }
                    }
                }
                catch
                {
                }

                Application.Current.Dispatcher.Invoke(async() =>
                {
                    switch (obj.Type)
                    {
                    case "notify":
                        var content = new DisplayMessageNotificationViewModel()
                        {
                            Data     = obj.Data,
                            Closable = true
                        };

                        ShowNotification(obj.Data, content);
                        break;

                    case "rtf":
                        var data = await _core.HttpClient.DownloadDataAsync(obj.Data.FileUrl);
                        try
                        {
                            var viewer = new RtfViewerViewModel()
                            {
                                Document = new System.Windows.Documents.FlowDocument()
                            };
                            using (var fStream = new MemoryStream(data))
                            {
                                var range =
                                    new TextRange(viewer.Document.ContentStart,
                                                  viewer.Document.ContentEnd);
                                range.Load(fStream, DataFormats.Rtf);
                                fStream.Close();
                            }
                            ShowMessage(obj.Data, viewer);
                        }
                        catch
                        {
                        }
                        break;

                    case "image":
                        var image = new ImageViewerViewModel()
                        {
                            ImageUrl = obj.Data.FileUrl
                        };
                        ShowMessage(obj.Data, image);
                        break;
                    }
                });
            };

            _core.WebSocket.On <DisplayMessageModel>("alert", (dyn) => action(dyn));
            return(Task.CompletedTask);
        }
Exemple #28
0
        public MoviesViewModel(IPresentationManager presentation, IImageManager imageManager, IApiClient apiClient, ISessionManager session, INavigationService nav, IPlaybackManager playback, ILogger logger, double tileWidth, double tileHeight, IServerEvents serverEvents)
            : base(presentation, apiClient)
        {
            _sessionManager  = session;
            _imageManager    = imageManager;
            _navService      = nav;
            _playbackManager = playback;
            _logger          = logger;
            _serverEvents    = serverEvents;

            TileWidth  = tileWidth;
            TileHeight = tileHeight;

            var trailerTileHeight = (TileHeight * 1.46) + TilePadding / 2;
            var trailerTileWidth  = trailerTileHeight * 2 / 3;

            LatestTrailersViewModel = new ItemListViewModel(GetLatestTrailersAsync, presentation, imageManager, apiClient, nav, playback, logger, _serverEvents)
            {
                ImageDisplayWidth             = trailerTileWidth,
                ImageDisplayHeightGenerator   = v => trailerTileHeight,
                DisplayNameGenerator          = HomePageViewModel.GetDisplayName,
                PreferredImageTypesGenerator  = vm => new[] { ImageType.Primary },
                EnableBackdropsForCurrentItem = false
            };
            LatestTrailersViewModel.PropertyChanged += TrailersViewModel_PropertyChanged;

            const double tileScaleFactor = 13;

            LatestMoviesViewModel = new ItemListViewModel(GetLatestMoviesAsync, presentation, imageManager, apiClient, nav, playback, logger, _serverEvents)
            {
                ImageDisplayWidth             = trailerTileWidth,
                ImageDisplayHeightGenerator   = v => trailerTileHeight,
                DisplayNameGenerator          = HomePageViewModel.GetDisplayName,
                PreferredImageTypesGenerator  = vm => new[] { ImageType.Primary, ImageType.Backdrop, ImageType.Thumb, },
                EnableBackdropsForCurrentItem = false,
                ListType = "LatestMovies"
            };
            LatestMoviesViewModel.PropertyChanged += LatestMoviesViewModel_PropertyChanged;

            ActorsViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight       = TileHeight,
                GalleryWidth        = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToActorsInternal)
            };

            GenresViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight       = TileHeight,
                GalleryWidth        = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToGenresInternal)
            };

            YearsViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight       = TileHeight,
                GalleryWidth        = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToYearsInternal)
            };

            AllMoviesViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight       = TileHeight,
                GalleryWidth        = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToAllMoviesInternal)
            };

            BoxsetsViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight       = TileHeight,
                GalleryWidth        = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToBoxsetsInternal)
            };

            TrailersViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight       = TileHeight,
                GalleryWidth        = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToTrailersInternal)
            };

            HDMoviesViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight       = TileHeight,
                GalleryWidth        = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToHDMoviesInternal)
            };

            FamilyMoviesViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight       = TileHeight,
                GalleryWidth        = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToFamilyMoviesInternal)
            };

            ThreeDMoviesViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight       = TileHeight,
                GalleryWidth        = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateTo3DMoviesInternal)
            };

            RomanticMoviesViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight       = TileHeight,
                GalleryWidth        = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToRomanticMoviesInternal)
            };

            ComedyItemsViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight       = TileHeight,
                GalleryWidth        = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToComedyMoviesInternal)
            };

            var spotlightTileWidth  = TileWidth * 2 + TilePadding;
            var spotlightTileHeight = spotlightTileWidth * 9 / 16;

            SpotlightViewModel = new ImageViewerViewModel(_imageManager, new List <ImageViewerImage>())
            {
                Height = spotlightTileHeight,
                Width  = spotlightTileWidth,
                CustomCommandAction = i => _navService.NavigateToItem(i.Item, ViewType.Movies),
                ImageStretch        = Stretch.UniformToFill
            };

            LoadViewModels();
        }
        public GamesViewModel(IPresentationManager presentation, IImageManager imageManager, IApiClient apiClient, ISessionManager session, INavigationService nav, IPlaybackManager playback, ILogger logger, double tileWidth, double tileHeight, IServerEvents serverEvents)
            : base(presentation, apiClient)
        {
            _sessionManager  = session;
            _playbackManager = playback;
            _imageManager    = imageManager;
            _navService      = nav;
            _logger          = logger;
            _serverEvents    = serverEvents;

            TileWidth  = tileWidth;
            TileHeight = tileHeight;

            var spotlightTileWidth  = TileWidth * 2 + TilePadding;
            var spotlightTileHeight = spotlightTileWidth * 9 / 16;

            SpotlightViewModel = new ImageViewerViewModel(_imageManager, new List <ImageViewerImage>())
            {
                Height = spotlightTileHeight,
                Width  = spotlightTileWidth,
                CustomCommandAction = i => _navService.NavigateToItem(i.Item, ViewType.Games),
                ImageStretch        = Stretch.UniformToFill
            };

            GameSystemsViewModel = new ItemListViewModel(GetGameSystems, presentation, imageManager, apiClient, nav, playback, logger, _serverEvents)
            {
                ImageDisplayWidth             = TileWidth,
                ImageDisplayHeightGenerator   = v => TileHeight,
                DisplayNameGenerator          = HomePageViewModel.GetDisplayName,
                EnableBackdropsForCurrentItem = false,
                Context = ViewType.Games
            };

            const int tileScaleFactor = 13;

            RecentlyPlayedViewModel = new ItemListViewModel(GetRecentlyPlayedAsync, presentation, imageManager, apiClient, nav, playback, logger, _serverEvents)
            {
                ImageDisplayWidth             = TileWidth * tileScaleFactor / 16,
                ImageDisplayHeightGenerator   = v => TileHeight,
                DisplayNameGenerator          = HomePageViewModel.GetDisplayName,
                EnableBackdropsForCurrentItem = false,
                ImageStretch = Stretch.UniformToFill,
                Context      = ViewType.Games
            };

            GenresViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight       = TileHeight,
                GalleryWidth        = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToGenresInternal)
            };

            YearsViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight       = TileHeight,
                GalleryWidth        = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToYearsInternal)
            };

            MultiPlayerViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight       = TileHeight,
                GalleryWidth        = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToMultiPlayerGamesInternal)
            };

            LoadViewModels();
        }
 public ImageViewerNavigationItem(ImageViewerViewModel imageViewerViewModel)
 {
     MainViewModel = imageViewerViewModel;
     Name          = "Image Viewer";
 }