/// <summary>
        /// Initializes a new instance of the TrailerViewModel class.
        /// </summary>
        public TrailerViewModel(INavigationService navigation, IExtendedApiClient apiClient)
        {
            _navigationService = navigation;
            _apiClient = apiClient;

            if (IsInDesignMode)
            {
                SelectedTrailer = new BaseItemDto
                {
                    Name = "Jurassic Park 3D",
                    Overview =
                        "Universal Pictures will release Steven Spielberg\u2019s groundbreaking masterpiece JURASSIC PARK in 3D on April 5, 2013.  With his remastering of the epic into a state-of-the-art 3D format, Spielberg introduces the three-time Academy Award\u00AE-winning blockbuster to a new generation of moviegoers and allows longtime fans to experience the world he envisioned in a way that was unimaginable during the film\u2019s original release.  Starring Sam Neill, Laura Dern, Jeff Goldblum, Samuel L. Jackson and Richard Attenborough, the film based on the novel by Michael Crichton is produced by Kathleen Kennedy and Gerald R. Molen.",
                    PremiereDate = DateTime.Parse("2013-04-05T00:00:00.0000000"),
                    Id = "4aed3d79a0c4c2a0ac9c91fb7a641f1a",
                    ProductionYear = 2013,
                    People = new[]
                    {
                        new BaseItemPerson {Name = "Steven Spielberg", Type = "Director"},
                        new BaseItemPerson {Name = "Sam Neill", Type = "Actor"},
                        new BaseItemPerson {Name = "Richard Attenborough", Type = "Actor"},
                        new BaseItemPerson {Name = "Laura Dern", Type = "Actor"}
                    }
                };
                CastAndCrew = Utils.GroupCastAndCrew(SelectedTrailer.People);
            }
            else
            {
                WireCommands();
            }
        }
        /// <summary>
        /// Initializes a new instance of the MovieViewModel class.
        /// </summary>
        public MovieViewModel(INavigationService navService, IExtendedApiClient apiClient)
        {
            _navService = navService;
            _apiClient = apiClient;

            CanUpdateFavourites = true;
            if (IsInDesignMode)
            {
                SelectedMovie = new BaseItemDto
                {
                    Id = "6536a66e10417d69105bae71d41a6e6f",
                    Name = "Jurassic Park",
                    SortName = "Jurassic Park",
                    Overview = "Lots of dinosaurs eating people!",
                    People = new[]
                    {
                        new BaseItemPerson {Name = "Steven Spielberg", Type = "Director"},
                        new BaseItemPerson {Name = "Sam Neill", Type = "Actor"},
                        new BaseItemPerson {Name = "Richard Attenborough", Type = "Actor"},
                        new BaseItemPerson {Name = "Laura Dern", Type = "Actor"}
                    }
                };
            }
            else
            {
                WireCommands();
            }
        }
        /// <summary>
        /// Initializes a new instance of the ActorViewModel class.
        /// </summary>
        public ActorViewModel(IExtendedApiClient apiClient, INavigationService navigationService)
        {
            _apiClient = apiClient;
            _navigationService = navigationService;

            if (IsInDesignMode)
            {
                SelectedPerson = new BaseItemPerson {Name = "Jeff Goldblum"};
                var list = new List<BaseItemDto>
                {
                    new BaseItemDto
                    {
                        Id = "6536a66e10417d69105bae71d41a6e6f",
                        Name = "Jurassic Park",
                        SortName = "Jurassic Park",
                        Overview = "Lots of dinosaurs eating people!",
                        People = new[]
                        {
                            new BaseItemPerson {Name = "Steven Spielberg", Type = "Director"},
                            new BaseItemPerson {Name = "Sam Neill", Type = "Actor"},
                            new BaseItemPerson {Name = "Richard Attenborough", Type = "Actor"},
                            new BaseItemPerson {Name = "Laura Dern", Type = "Actor"}
                        }
                    }
                };

                Films = Utils.GroupItemsByName(list).Result;
            }
        
        }
        /// <summary>
        /// Initializes a new instance of the SearchViewModel class.
        /// </summary>
        public SearchViewModel(IExtendedApiClient apiClient, INavigationService navigationService)
        {
            _apiClient = apiClient;
            _navigationService = navigationService;

            SearchResults = new List<Group<SearchHint>>();

            if (IsInDesignMode)
            {
                var data = new List<SearchHint>
                {
                    new SearchHint
                    {
                        Name = "Jurassic Park",
                        Type = "Movie"
                    },
                    new SearchHint
                    {
                        Name = "1x01 - Pilot",
                        Type = "Episode"
                    }
                };
                GroupSearchResults(data);
            }
        }
        /// <summary>
        /// Initializes a new instance of the PushViewModel class.
        /// </summary>
        public SettingsViewModel(IExtendedApiClient apiClient, INavigationService navigationService, IApplicationSettingsService applicationSettings)
        {
            _apiClient = apiClient;
            _navigationService = navigationService;
            _applicationSettings = applicationSettings;

            if (IsInDesignMode)
            {
                IsRegistered = UseNotifications = true;
                RegisteredText = "Device registered";
                ServerPluginInstalled = false;

#if WP8
                FoundServers = new ObservableCollection<Server>
                {
                    new Server {IpAddress = "192.168.0.2", PortNo = "8096"},
                    new Server {IpAddress = "192.168.0.4", PortNo = "8096"}
                };
#endif
            }
            else
            {
                LoadingFromSettings = true;
                SendTileUpdates = SendToastUpdates = true;
                RegisteredText = AppResources.DeviceNotRegistered;
                LoadingFromSettings = false;
                ServerPluginInstalled = false;
            }
        }
        /// <summary>
        /// Initializes a new instance of the ChooseProfileViewModel class.
        /// </summary>
        public ChooseProfileViewModel(IExtendedApiClient apiClient, INavigationService navigationService, IApplicationSettingsService applicationSettings)
        {
            _apiClient = apiClient;
            _navigationService = navigationService;

            Profiles = new ObservableCollection<UserDto>();
            if (IsInDesignMode)
            {
                Profiles = new ObservableCollection<UserDto>
                {
                    new UserDto
                    {
                        Id = new Guid("dd425709431649698e92d86b1f2b00fa").ToString(),
                        Name = "ScottIsAFool"
                    },
                    new UserDto
                    {
                        Id = new Guid("dab28e40cfbc43658082f55a44cf139a").ToString(),
                        Name = "Redshirt",
                        LastLoginDate = DateTime.Now.AddHours(-1)
                    }
                };
            }
            else
            {
                WireCommands();
            }
        }
        public void Start(IExtendedApiClient apiClient, ILogger logger)
        {
            _apiClient = apiClient;
            _logger = logger;
            _settingsService = new ApplicationSettingsService();

            CheckIfUserSignedIn();
        }
        /// <summary>
        /// Initializes a new instance of the MovieCollectionViewModel class.
        /// </summary>
        public MovieCollectionViewModel(INavigationService navigationService, IExtendedApiClient apiClient)
        {
            _apiClient = apiClient;
            _navigationService = navigationService;

            if (IsInDesignMode)
            {
                UnseenHeader = new BaseItemDto
                {
                    Id = "6536a66e10417d69105bae71d41a6e6f",
                    Name = "Jurassic Park",
                    SortName = "Jurassic Park",
                    Overview = "Lots of dinosaurs eating people!",
                    People = new[]
                    {
                        new BaseItemPerson {Name = "Steven Spielberg", Type = "Director"},
                        new BaseItemPerson {Name = "Sam Neill", Type = "Actor"},
                        new BaseItemPerson {Name = "Richard Attenborough", Type = "Actor"},
                        new BaseItemPerson {Name = "Laura Dern", Type = "Actor"}
                    }
                };

                LatestUnwatched = new List<BaseItemDto>
                {
                    new BaseItemDto
                    {
                        Id = "6536a66e10417d69105bae71d41a6e6f",
                        Name = "Jurassic Park",
                        SortName = "Jurassic Park",
                        Overview = "Lots of dinosaurs eating people!",
                        People = new[]
                        {
                            new BaseItemPerson {Name = "Steven Spielberg", Type = "Director"},
                            new BaseItemPerson {Name = "Sam Neill", Type = "Actor"},
                            new BaseItemPerson {Name = "Richard Attenborough", Type = "Actor"},
                            new BaseItemPerson {Name = "Laura Dern", Type = "Actor"}
                        }
                    },
                    new BaseItemDto
                    {
                        Id = "6536a66e10417d69105bae71d41a6e6f",
                        Name = "Jurassic Park",
                        SortName = "Jurassic Park",
                        Overview = "Lots of dinosaurs eating people!",
                        People = new[]
                        {
                            new BaseItemPerson {Name = "Steven Spielberg", Type = "Director"},
                            new BaseItemPerson {Name = "Sam Neill", Type = "Actor"},
                            new BaseItemPerson {Name = "Richard Attenborough", Type = "Actor"},
                            new BaseItemPerson {Name = "Laura Dern", Type = "Actor"}
                        }
                    }
                };

                Movies = Utils.GroupItemsByName(LatestUnwatched).Result;
            }
        }
        /// <summary>
        /// Initializes a new instance of the MusicCollectionViewModel class.
        /// </summary>
        public MusicCollectionViewModel(INavigationService navigationService, IExtendedApiClient apiClient)
        {
            _navigationService = navigationService;
            _apiClient = apiClient;
            SelectedTracks = new List<BaseItemDto>();

            if (IsInDesignMode)
            {
                var artists = new List<BaseItemDto> {new BaseItemDto {Name = "John Williams"}, new BaseItemDto {Name = "Hans Zimmer"}};
                Artists = Utils.GroupItemsByName(artists).Result;
            }
        }
        /// <summary>
        /// Initializes a new instance of the RemoteViewModel class.
        /// </summary>
        public RemoteViewModel(INavigationService navigationService, IExtendedApiClient apiClient)
        {
            _navigationService = navigationService;
            _apiClient = apiClient;

            if (IsInDesignMode)
            {
                Clients = new List<SessionInfoDto>
                {
                    new SessionInfoDto
                    {
                        Client = "Dashboard"
                    }
                };
            }
        }
        /// <summary>
        /// Initializes a new instance of the MusicCollectionViewModel class.
        /// </summary>
        public MusicCollectionViewModel(INavigationService navigationService, IExtendedApiClient apiClient)
        {
            _navigationService = navigationService;
            _apiClient         = apiClient;
            SelectedTracks     = new List <BaseItemDto>();

            if (IsInDesignMode)
            {
                var artists = new List <BaseItemDto> {
                    new BaseItemDto {
                        Name = "John Williams"
                    }, new BaseItemDto {
                        Name = "Hans Zimmer"
                    }
                };
                Artists = Utils.GroupItemsByName(artists).Result;
            }
        }
Пример #12
0
        /// <summary>
        /// Initializes a new instance of the FolderViewModel class.
        /// </summary>
        public FolderViewModel(INavigationService navigationService, IExtendedApiClient apiClient)
        {
            RecentItems = new ObservableCollection <BaseItemDto>();
            RandomItems = new ObservableCollection <BaseItemDto>();

            _apiClient         = apiClient;
            _navigationService = navigationService;

            if (IsInDesignMode)
            {
                SelectedFolder = new BaseItemDto
                {
                    Name = "Movies"
                };
                RecentItems.Add(new BaseItemDto
                {
                    Id       = "6536a66e10417d69105bae71d41a6e6f",
                    Name     = "Jurassic Park",
                    SortName = "Jurassic Park",
                    Overview = "Lots of dinosaurs eating people!",
                    People   = new[]
                    {
                        new BaseItemPerson {
                            Name = "Steven Spielberg", Type = "Director"
                        },
                        new BaseItemPerson {
                            Name = "Sam Neill", Type = "Actor"
                        },
                        new BaseItemPerson {
                            Name = "Richard Attenborough", Type = "Actor"
                        },
                        new BaseItemPerson {
                            Name = "Laura Dern", Type = "Actor"
                        }
                    }
                });
            }
            else
            {
                WireCommands();
                GroupBy = GroupBy.Name;
            }
        }
        /// <summary>
        /// Initializes a new instance of the TvCollectionViewModel class.
        /// </summary>
        public TvCollectionViewModel(INavigationService navigationService, IExtendedApiClient apiClient)
        {
            _navigationService = navigationService;
            _apiClient         = apiClient;

            if (IsInDesignMode)
            {
                NextUpList = new List <BaseItemDto>
                {
                    new BaseItemDto
                    {
                        Id       = "e252ea3059d140a0274282bc8cd194cc",
                        Name     = "1x01 - Pilot",
                        Overview =
                            "A Kindergarten teacher starts speaking gibberish and passed out in front of her class. What looks like a possible brain tumor does not respond to treatment and provides many more questions than answers for House and his team as they engage in a risky trial-and-error approach to her case. When the young teacher refuses any additional variations of treatment and her life starts slipping away, House must act against his code of conduct and make a personal visit to his patient to convince her to trust him one last time.",
                        SeriesName = "House M.D."
                    }
                };
            }
        }
        /// <summary>
        /// Initializes a new instance of the TvCollectionViewModel class.
        /// </summary>
        public TvCollectionViewModel(INavigationService navigationService, IExtendedApiClient apiClient)
        {
            _navigationService = navigationService;
            _apiClient = apiClient;

            if (IsInDesignMode)
            {
                NextUpList = new List<BaseItemDto>
                {
                    new BaseItemDto
                    {
                        Id = "e252ea3059d140a0274282bc8cd194cc",
                        Name = "1x01 - Pilot",
                        Overview =
                            "A Kindergarten teacher starts speaking gibberish and passed out in front of her class. What looks like a possible brain tumor does not respond to treatment and provides many more questions than answers for House and his team as they engage in a risky trial-and-error approach to her case. When the young teacher refuses any additional variations of treatment and her life starts slipping away, House must act against his code of conduct and make a personal visit to his patient to convince her to trust him one last time.",
                        SeriesName = "House M.D."
                    }
                };
            }
        }
        internal static PlaylistItem ToPlaylistItem(this BaseItemDto item, IExtendedApiClient apiClient)
        {
            var streamUrl = apiClient.GetAudioStreamUrl(new StreamOptions
            {
                AudioBitRate        = 128,
                AudioCodec          = AudioCodecs.Mp3,
                ItemId              = item.Id,
                OutputFileExtension = "mp3",
            });

            return(new PlaylistItem
            {
                Album = item.Album,
                Artist = item.Artists.Any() ? item.Artists[0] : "",
                TrackName = item.Name,
                TrackUrl = streamUrl,
                MediaBrowserId = item.Id,
                IsJustAdded = true,
                ImageUrl = (string)new Converters.ImageUrlConverter().Convert(item, typeof(string), null, null),
            });
        }
        /// <summary>
        /// Initializes a new instance of the MusicViewModel class.
        /// </summary>
        public MusicViewModel(IExtendedApiClient apiClient, INavigationService navigationService)
        {
            _navigationService = navigationService;
            _apiClient = apiClient;

            SelectedTracks = new List<BaseItemDto>();
            CanUpdateFavourites = true;
            if (IsInDesignMode)
            {
                SelectedArtist = new BaseItemDto
                {
                    Name = "Hans Zimmer",
                    Id = "179d32421632781047c73c9bd501adea"
                };
                SelectedAlbum = new BaseItemDto
                {
                    Name = "The Dark Knight Rises",
                    Id = "f8d5c8cbcbd39bc75c2ba7ada65d4319",
                };
                Albums = new ObservableCollection<BaseItemDto>
                {
                    new BaseItemDto {Name = "The Dark Knight Rises", Id = "f8d5c8cbcbd39bc75c2ba7ada65d4319", ProductionYear = 2012},
                    new BaseItemDto {Name = "Batman Begins", Id = "03b6dbb15e4abcca6ee336a2edd79ba6", ProductionYear = 2005},
                    new BaseItemDto {Name = "Sherlock Holmes", Id = "6e2d519b958d440d034c3ba6eca008a4", ProductionYear = 2010}
                };
                AlbumTracks = new List<BaseItemDto>
                {
                    new BaseItemDto {Name = "Bombers Over Ibiza (Junkie XL Remix)", IndexNumber = 1, ParentIndexNumber = 2, RunTimeTicks = 3487920000, Id = "7589bfbe8b10d0191e305d92f127bd01"},
                    new BaseItemDto {Name = "A Storm Is Coming", Id = "1ea1fd991c70b33c596611dadf24defc", IndexNumber = 1, ParentIndexNumber = 1, RunTimeTicks = 369630000},
                    new BaseItemDto {Name = "On Thin Ice", Id = "2696da6a01f254fbd7e199a191bd5c4f", IndexNumber = 2, ParentIndexNumber = 1, RunTimeTicks = 1745500000},
                }.OrderBy(x => x.ParentIndexNumber)
                    .ThenBy(x => x.IndexNumber).ToList();

                SortedTracks = Utils.GroupItemsByName(AlbumTracks).Result;
            }
            else
            {
                WireCommands();
            }
        }
        /// <summary>
        /// Initializes a new instance of the ActorViewModel class.
        /// </summary>
        public ActorViewModel(IExtendedApiClient apiClient, INavigationService navigationService)
        {
            _apiClient         = apiClient;
            _navigationService = navigationService;

            if (IsInDesignMode)
            {
                SelectedPerson = new BaseItemPerson {
                    Name = "Jeff Goldblum"
                };
                var list = new List <BaseItemDto>
                {
                    new BaseItemDto
                    {
                        Id       = "6536a66e10417d69105bae71d41a6e6f",
                        Name     = "Jurassic Park",
                        SortName = "Jurassic Park",
                        Overview = "Lots of dinosaurs eating people!",
                        People   = new[]
                        {
                            new BaseItemPerson {
                                Name = "Steven Spielberg", Type = "Director"
                            },
                            new BaseItemPerson {
                                Name = "Sam Neill", Type = "Actor"
                            },
                            new BaseItemPerson {
                                Name = "Richard Attenborough", Type = "Actor"
                            },
                            new BaseItemPerson {
                                Name = "Laura Dern", Type = "Actor"
                            }
                        }
                    }
                };

                Films = Utils.GroupItemsByName(list).Result;
            }
        }
Пример #18
0
        /// <summary>
        /// Initializes a new instance of the TrailerViewModel class.
        /// </summary>
        public TrailerViewModel(INavigationService navigation, IExtendedApiClient apiClient)
        {
            _navigationService = navigation;
            _apiClient         = apiClient;

            if (IsInDesignMode)
            {
                SelectedTrailer = new BaseItemDto
                {
                    Name     = "Jurassic Park 3D",
                    Overview =
                        "Universal Pictures will release Steven Spielberg\u2019s groundbreaking masterpiece JURASSIC PARK in 3D on April 5, 2013.  With his remastering of the epic into a state-of-the-art 3D format, Spielberg introduces the three-time Academy Award\u00AE-winning blockbuster to a new generation of moviegoers and allows longtime fans to experience the world he envisioned in a way that was unimaginable during the film\u2019s original release.  Starring Sam Neill, Laura Dern, Jeff Goldblum, Samuel L. Jackson and Richard Attenborough, the film based on the novel by Michael Crichton is produced by Kathleen Kennedy and Gerald R. Molen.",
                    PremiereDate   = DateTime.Parse("2013-04-05T00:00:00.0000000"),
                    Id             = "4aed3d79a0c4c2a0ac9c91fb7a641f1a",
                    ProductionYear = 2013,
                    People         = new[]
                    {
                        new BaseItemPerson {
                            Name = "Steven Spielberg", Type = "Director"
                        },
                        new BaseItemPerson {
                            Name = "Sam Neill", Type = "Actor"
                        },
                        new BaseItemPerson {
                            Name = "Richard Attenborough", Type = "Actor"
                        },
                        new BaseItemPerson {
                            Name = "Laura Dern", Type = "Actor"
                        }
                    }
                };
                CastAndCrew = Utils.GroupCastAndCrew(SelectedTrailer.People);
            }
            else
            {
                WireCommands();
            }
        }
        /// <summary>
        /// Initializes a new instance of the TvViewModel class.
        /// </summary>
        public TvViewModel(INavigationService navService, IExtendedApiClient apiClient)
        {
            _navService = navService;
            _apiClient = apiClient;

            RecentItems = new ObservableCollection<BaseItemDto>();
            Episodes = new List<BaseItemDto>();
            CanUpdateFavourites = true;
            if (IsInDesignMode)
            {
                SelectedTvSeries = new BaseItemDto
                {
                    Name = "Scrubs"
                };
                SelectedSeason = new BaseItemDto
                {
                    Name = "Season 1"
                };
                Episodes = new[]
                {
                    new BaseItemDto
                    {
                        Id = "e252ea3059d140a0274282bc8cd194cc",
                        Name = "1x01 - Pilot",
                        Overview =
                            "A Kindergarten teacher starts speaking gibberish and passed out in front of her class. What looks like a possible brain tumor does not respond to treatment and provides many more questions than answers for House and his team as they engage in a risky trial-and-error approach to her case. When the young teacher refuses any additional variations of treatment and her life starts slipping away, House must act against his code of conduct and make a personal visit to his patient to convince her to trust him one last time."
                    }
                }.ToList();
                SelectedEpisode = Episodes[0];

            }
            else
            {
                WireCommands();
            }
        }
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(IExtendedApiClient apiClient, INavigationService navService)
        {
            _apiClient = apiClient;
            _navService = navService;

            Folders = new ObservableCollection<BaseItemDto>();
            RecentItems = new ObservableCollection<BaseItemDto>();
            FavouriteItems = new ObservableCollection<BaseItemDto>();

            if (IsInDesignMode)
            {
                Folders.Add(new BaseItemDto {Id = "78dbff5aa1c2101b98ebaf42b72a988d", Name = "Movies", RecursiveUnplayedItemCount = 6});
                RecentItems.Add(new BaseItemDto {Id = "2fc6f321b5f8bbe842fcd0eed089561d", Name = "A Night To Remember"});
            }
            else
            {
                WireCommands();
                DummyFolder = new BaseItemDto
                {
                    Type = "folder",
                    Name = AppResources.Recent.ToLower()
                };
            }
        }
        /// <summary>
        /// Initializes a new instance of the FolderViewModel class.
        /// </summary>
        public FolderViewModel(INavigationService navigationService, IExtendedApiClient apiClient)
        {
            RecentItems = new ObservableCollection<BaseItemDto>();
            RandomItems = new ObservableCollection<BaseItemDto>();

            _apiClient = apiClient;
            _navigationService = navigationService;

            if (IsInDesignMode)
            {
                SelectedFolder = new BaseItemDto
                {
                    Name = "Movies"
                };
                RecentItems.Add(new BaseItemDto
                {
                    Id = "6536a66e10417d69105bae71d41a6e6f",
                    Name = "Jurassic Park",
                    SortName = "Jurassic Park",
                    Overview = "Lots of dinosaurs eating people!",
                    People = new[]
                    {
                        new BaseItemPerson {Name = "Steven Spielberg", Type = "Director"},
                        new BaseItemPerson {Name = "Sam Neill", Type = "Actor"},
                        new BaseItemPerson {Name = "Richard Attenborough", Type = "Actor"},
                        new BaseItemPerson {Name = "Laura Dern", Type = "Actor"}
                    }

                });
            }
            else
            {
                WireCommands();
                GroupBy = GroupBy.Name;
            }
        }
Пример #22
0
        /// <summary>
        /// Initializes a new instance of the MovieViewModel class.
        /// </summary>
        public MovieViewModel(INavigationService navService, IExtendedApiClient apiClient)
        {
            _navService = navService;
            _apiClient  = apiClient;

            CanUpdateFavourites = true;
            if (IsInDesignMode)
            {
                SelectedMovie = new BaseItemDto
                {
                    Id       = "6536a66e10417d69105bae71d41a6e6f",
                    Name     = "Jurassic Park",
                    SortName = "Jurassic Park",
                    Overview = "Lots of dinosaurs eating people!",
                    People   = new[]
                    {
                        new BaseItemPerson {
                            Name = "Steven Spielberg", Type = "Director"
                        },
                        new BaseItemPerson {
                            Name = "Sam Neill", Type = "Actor"
                        },
                        new BaseItemPerson {
                            Name = "Richard Attenborough", Type = "Actor"
                        },
                        new BaseItemPerson {
                            Name = "Laura Dern", Type = "Actor"
                        }
                    }
                };
            }
            else
            {
                WireCommands();
            }
        }
 /// <summary>
 /// Initializes a new instance of the NotificationsViewModel class.
 /// </summary>
 public NotificationsViewModel(IExtendedApiClient apiClient, INavigationService navigationService)
 {
     _apiClient = apiClient;
     _navigationService = navigationService;
     Notifications = new ObservableCollection<Notification>();
 }
 /// <summary>
 /// Initializes a new instance of the SplashscreenViewModel class.
 /// </summary>
 public SplashscreenViewModel(IExtendedApiClient apiClient, INavigationService navigationService, IApplicationSettingsService applicationSettings)
 {
     _apiClient = apiClient;
     _navigationService = navigationService;
     _applicationSettings = applicationSettings;
 }
 /// <summary>
 /// Initializes a new instance of the NotificationsViewModel class.
 /// </summary>
 public NotificationsViewModel(IExtendedApiClient apiClient, INavigationService navigationService)
 {
     _apiClient         = apiClient;
     _navigationService = navigationService;
     Notifications      = new ObservableCollection <Notification>();
 }
 /// <summary>
 /// Initializes a new instance of the VideoPlayerViewModel class.
 /// </summary>
 public VideoPlayerViewModel(IExtendedApiClient apiClient, INavigationService navigationService)
 {
     _apiClient         = apiClient;
     _navigationService = navigationService;
 }
 /// <summary>
 /// Initializes a new instance of the GenericItemViewModel class.
 /// </summary>
 public GenericItemViewModel(INavigationService navigationService, IExtendedApiClient apiClient)
 {
     _navigationService = navigationService;
     _apiClient         = apiClient;
 }
 /// <summary>
 /// Initializes a new instance of the SplashscreenViewModel class.
 /// </summary>
 public SplashscreenViewModel(IExtendedApiClient apiClient, INavigationService navigationService, IApplicationSettingsService applicationSettings)
 {
     _apiClient           = apiClient;
     _navigationService   = navigationService;
     _applicationSettings = applicationSettings;
 }
 /// <summary>
 /// Initializes a new instance of the GenericItemViewModel class.
 /// </summary>
 public GenericItemViewModel(INavigationService navigationService, IExtendedApiClient apiClient)
 {
     _navigationService = navigationService;
     _apiClient = apiClient;
 }
 /// <summary>
 /// Initializes a new instance of the VideoPlayerViewModel class.
 /// </summary>
 public VideoPlayerViewModel(IExtendedApiClient apiClient, INavigationService navigationService)
 {
     _apiClient = apiClient;
     _navigationService = navigationService;
 }
        private static object GetDtoImage(BaseItemDto item, string imageType, IExtendedApiClient apiClient)
        {
            if (item.ImageTags.IsNullOrEmpty())
            {
                return("");
            }

            var imageOptions = new ImageOptions
            {
                Quality = 90,
#if WP8
                MaxHeight = 336,
#else
                MaxHeight = 173,
#endif
                ImageType = ImageType.Primary
            };

            if (imageType.Equals("logo", StringComparison.OrdinalIgnoreCase))
            {
                imageOptions.ImageType = ImageType.Logo;
            }
            else if (imageType.Equals("backdrop"))
            {
                imageOptions.MaxHeight = 800;
                imageOptions.ImageType = ImageType.Backdrop;

                var images = apiClient.GetBackdropImageUrls(item, imageOptions);
                if (!images.IsNullOrEmpty())
                {
                    return(images.FirstOrDefault());
                }
            }
            else if (imageType.Equals("primaryorbackdrop"))
            {
                if (!item.HasPrimaryImage)
                {
                    imageOptions.MaxHeight = 800;
                    imageOptions.ImageType = ImageType.Backdrop;

                    var images = apiClient.GetBackdropImageUrls(item, imageOptions);
                    if (!images.IsNullOrEmpty())
                    {
                        return(images.FirstOrDefault());
                    }
                }
            }
            else if (imageType.Equals("backdropsmall", StringComparison.OrdinalIgnoreCase))
            {
#if WP8
                imageOptions.MaxHeight = 336;
#else
                imageOptions.MaxHeight = 173;
#endif
                imageOptions.ImageType = ImageType.Backdrop;

                var images = apiClient.GetBackdropImageUrls(item, imageOptions);
                if (!images.IsNullOrEmpty())
                {
                    return(images.FirstOrDefault());
                }
            }
            else if (imageType.Equals("banner", StringComparison.OrdinalIgnoreCase))
            {
                imageOptions.MaxHeight = 140;
                imageOptions.ImageType = ImageType.Banner;
            }
            else if (imageType.Equals("art", StringComparison.OrdinalIgnoreCase))
            {
                imageOptions.ImageType = ImageType.Art;
            }
            else if (imageType.Equals("thumbnail", StringComparison.OrdinalIgnoreCase))
            {
                imageOptions.ImageType = ImageType.Thumb;
            }
            else if (imageType.Equals("icon", StringComparison.OrdinalIgnoreCase))
            {
#if WP8
                imageOptions.MaxHeight = 159;
#else
                imageOptions.MaxHeight = 90;
#endif
            }
            else if (imageType.Equals("poster", StringComparison.OrdinalIgnoreCase))
            {
#if WP8
                imageOptions.MaxHeight = 675;
#else
                imageOptions.MaxHeight = 450;
#endif
            }
            else if (imageType.Equals("episode", StringComparison.OrdinalIgnoreCase))
            {
#if WP8
                imageOptions.MaxHeight = 382;
#else
                imageOptions.MaxHeight = 255;
#endif
            }
            else
            {
#if WP8
                imageOptions.MaxHeight = 300;
#else
                imageOptions.MaxHeight = 200;
#endif
            }
            try
            {
                string url = item.Type == "Series" ? apiClient.GetImageUrl(item.Id, imageOptions) : apiClient.GetImageUrl(item, imageOptions);
                return(url);
            }
            catch
            {
                return("");
            }
        }
Пример #32
0
        internal static List <PlaylistItem> ToPlayListItems(this List <BaseItemDto> list, IExtendedApiClient apiClient)
        {
            var newList = new List <PlaylistItem>();

            list.ForEach(item =>
            {
                var playlistItem = item.ToPlaylistItem(apiClient);
                newList.Add(playlistItem);
            });

            return(newList);
        }
 public void Start()
 {
     _apiClient = SimpleIoc.Default.GetInstance<IExtendedApiClient>(); 
     _serviceStarted = true;
 }
        private static object GetDtoImage(BaseItemDto item, string imageType, IExtendedApiClient apiClient)
        {
            if (item.ImageTags.IsNullOrEmpty())
            {
                return "";
            }

            var imageOptions = new ImageOptions
            {
                Quality = 90,
#if WP8
                MaxHeight = 336,
#else
                                               MaxHeight = 173,
#endif
                ImageType = ImageType.Primary
            };
            if (imageType.Equals("logo", StringComparison.OrdinalIgnoreCase))
            {
                imageOptions.ImageType = ImageType.Logo;
            }
            else if (imageType.Equals("backdrop"))
            {
                imageOptions.MaxHeight = 800;
                imageOptions.ImageType = ImageType.Backdrop;

                var images = apiClient.GetBackdropImageUrls(item, imageOptions);
                if (!images.IsNullOrEmpty())
                {
                    return images.FirstOrDefault();
                }
            }
            else if (imageType.Equals("primaryorbackdrop"))
            {
                if (!item.HasPrimaryImage)
                {
                    imageOptions.MaxHeight = 800;
                    imageOptions.ImageType = ImageType.Backdrop;

                    var images = apiClient.GetBackdropImageUrls(item, imageOptions);
                    if (!images.IsNullOrEmpty())
                    {
                        return images.FirstOrDefault();
                    }
                }
            }
            else if (imageType.Equals("backdropsmall", StringComparison.OrdinalIgnoreCase))
            {
#if WP8
                imageOptions.MaxHeight = 336;
#else
                        imageOptions.MaxHeight = 173;
#endif
                imageOptions.ImageType = ImageType.Backdrop;

                var images = apiClient.GetBackdropImageUrls(item, imageOptions);
                if (!images.IsNullOrEmpty())
                {
                    return images.FirstOrDefault();
                }
            }
            else if (imageType.Equals("banner", StringComparison.OrdinalIgnoreCase))
            {
                imageOptions.MaxHeight = 140;
                imageOptions.ImageType = ImageType.Banner;
            }
            else if (imageType.Equals("art", StringComparison.OrdinalIgnoreCase))
            {
                imageOptions.ImageType = ImageType.Art;
            }
            else if (imageType.Equals("thumbnail", StringComparison.OrdinalIgnoreCase))
            {
                imageOptions.ImageType = ImageType.Thumb;
            }
            else if (imageType.Equals("icon", StringComparison.OrdinalIgnoreCase))
            {
#if WP8
                imageOptions.MaxHeight = 159;
#else
                        imageOptions.MaxHeight = 90;
#endif
            }
            else if (imageType.Equals("poster", StringComparison.OrdinalIgnoreCase))
            {
#if WP8
                imageOptions.MaxHeight = 675;
#else
                        imageOptions.MaxHeight = 450;
#endif
            }
            else if (imageType.Equals("episode", StringComparison.OrdinalIgnoreCase))
            {
#if WP8
                imageOptions.MaxHeight = 382;
#else
                        imageOptions.MaxHeight = 255;
#endif
            }
            else
            {
#if WP8
                imageOptions.MaxHeight = 300;
#else
                        imageOptions.MaxHeight = 200;
#endif
            }
            try
            {
                string url = item.Type == "Series" ? apiClient.GetImageUrl(item.Id, imageOptions) : apiClient.GetImageUrl(item, imageOptions);
                return url;
            }
            catch
            {
                return "";
            }
        }
        /// <summary>
        /// Initializes a new instance of the MovieCollectionViewModel class.
        /// </summary>
        public MovieCollectionViewModel(INavigationService navigationService, IExtendedApiClient apiClient)
        {
            _apiClient         = apiClient;
            _navigationService = navigationService;

            if (IsInDesignMode)
            {
                UnseenHeader = new BaseItemDto
                {
                    Id       = "6536a66e10417d69105bae71d41a6e6f",
                    Name     = "Jurassic Park",
                    SortName = "Jurassic Park",
                    Overview = "Lots of dinosaurs eating people!",
                    People   = new[]
                    {
                        new BaseItemPerson {
                            Name = "Steven Spielberg", Type = "Director"
                        },
                        new BaseItemPerson {
                            Name = "Sam Neill", Type = "Actor"
                        },
                        new BaseItemPerson {
                            Name = "Richard Attenborough", Type = "Actor"
                        },
                        new BaseItemPerson {
                            Name = "Laura Dern", Type = "Actor"
                        }
                    }
                };

                LatestUnwatched = new List <BaseItemDto>
                {
                    new BaseItemDto
                    {
                        Id       = "6536a66e10417d69105bae71d41a6e6f",
                        Name     = "Jurassic Park",
                        SortName = "Jurassic Park",
                        Overview = "Lots of dinosaurs eating people!",
                        People   = new[]
                        {
                            new BaseItemPerson {
                                Name = "Steven Spielberg", Type = "Director"
                            },
                            new BaseItemPerson {
                                Name = "Sam Neill", Type = "Actor"
                            },
                            new BaseItemPerson {
                                Name = "Richard Attenborough", Type = "Actor"
                            },
                            new BaseItemPerson {
                                Name = "Laura Dern", Type = "Actor"
                            }
                        }
                    },
                    new BaseItemDto
                    {
                        Id       = "6536a66e10417d69105bae71d41a6e6f",
                        Name     = "Jurassic Park",
                        SortName = "Jurassic Park",
                        Overview = "Lots of dinosaurs eating people!",
                        People   = new[]
                        {
                            new BaseItemPerson {
                                Name = "Steven Spielberg", Type = "Director"
                            },
                            new BaseItemPerson {
                                Name = "Sam Neill", Type = "Actor"
                            },
                            new BaseItemPerson {
                                Name = "Richard Attenborough", Type = "Actor"
                            },
                            new BaseItemPerson {
                                Name = "Laura Dern", Type = "Actor"
                            }
                        }
                    }
                };

                Movies = Utils.GroupItemsByName(LatestUnwatched).Result;
            }
        }
 public void Start()
 {
     _apiClient      = SimpleIoc.Default.GetInstance <IExtendedApiClient>();
     _serviceStarted = true;
 }