/// <summary> /// Initializes a new instance of the <see cref="SqlCeMovie"/> class. /// </summary> /// <param name="id">The id.</param> internal SqlCeMovie(int id, SqlCeMovieDataSource store) { Id = id; Store = store; Dictionary <string, object> columns = Store.GetRow(Table.Movies, Id); title = columns["title"].ToString(); originalTitle = columns["title_original"].ToString(); year = Store.GetValue <int>(columns["year"]); url = columns["url"].ToString(); country = columns["country"].ToString(); plot = columns["plot"].ToString(); rating = Store.GetValue <double>(columns["rating"]); cover = (columns["cover"] != null && !(columns["cover"] is DBNull)) ? Image.FromStream(new MemoryStream((byte[])columns["cover"])) : null; Directors = new ObservableCollection <IPerson>(); Store.GetReferences(Table.Movies, Table.Directors, Id).ForEach(p => Directors.Add(new SqlCePerson(p, Store, null))); Directors.CollectionChanged += new NotifyCollectionChangedEventHandler(Directors_CollectionChanged); Cast = new ObservableCollection <IPerson>(); Store.GetReferences(Table.Movies, Table.Cast, Id).ForEach(p => Cast.Add(new SqlCePerson(p, Store, this))); Cast.CollectionChanged += new NotifyCollectionChangedEventHandler(Cast_CollectionChanged); Genres = new ObservableCollection <IGenre>(); Store.GetReferences(Table.Movies, Table.Genres, Id).ForEach(g => Genres.Add(new SqlCeGenre(g, Store))); Genres.CollectionChanged += new NotifyCollectionChangedEventHandler(Genres_CollectionChanged); MediaFiles = new ObservableCollection <IMediaFile>(); Store.GetReferences(Table.Movies, Table.MediaFiles, Id).ForEach(m => MediaFiles.Add(new SqlCeMediaFile(m, Store))); MediaFiles.CollectionChanged += new NotifyCollectionChangedEventHandler(MediaFiles_CollectionChanged); }
/// <summary> /// Initializes a new instance of the <see cref="SqlCeGenre"/> class. /// </summary> /// <param name="id">The id.</param> public SqlCeGenre(int id, SqlCeMovieDataSource store) { Id = id; Store = store; Dictionary <string, object> columns = Store.GetRow(Table.Genres, id); Title = columns["title"].ToString(); }
/// <summary> /// Initializes a new instance of the <see cref="SqlCePerson"/> class. /// </summary> /// <param name="id">The id.</param> /// <param name="store">The store.</param> /// <param name="parentMovie">The parent movie.</param> /// <remarks>Documented by CFI, 2009-04-16</remarks> public SqlCePerson(int id, SqlCeMovieDataSource store, IMovie parentMovie) { Id = id; Store = store; Movie = parentMovie; Dictionary <string, object> columns = Store.GetRow(Table.Persons, id); Name = columns["name"].ToString(); picture = (columns["picture"] != null && !(columns["picture"] is DBNull)) ? Image.FromStream(new MemoryStream((byte[])columns["picture"])) : null; }
/// <summary> /// Initializes a new instance of the <see cref="SqlCeUserMovieSettings"/> class. /// </summary> /// <param name="id">The id.</param> public SqlCeUserMovieSettings(int id, SqlCeMovieDataSource store) { Id = id; Store = store; Dictionary <string, object> columns = Store.GetRow(Table.UserMovieSettings, id); Movie = Store.Movies.ToList().Find(m => m.Id == Store.GetValue <int>(columns["movies_id"]).Value); seen = Store.GetValue <bool>(columns["seen"]); rating = Store.GetValue <double>(columns["rating"]); comment = columns["comment"].ToString(); }
/// <summary> /// Initializes a new instance of the <see cref="SqlCeUserProfile"/> class. /// </summary> /// <param name="id">The id.</param> public SqlCeUserProfile(int id, SqlCeMovieDataSource store) { Id = id; Store = store; Dictionary <string, object> columns = Store.GetRow(Table.UserProfiles, id); Name = columns["name"].ToString(); MovieSettings = new ObservableCollection <IUserMovieSettings>(); Store.GetReferences(Table.UserProfiles, Table.UserMovieSettings, Id).ForEach(s => MovieSettings.Add(new SqlCeUserMovieSettings(s, Store))); MovieSettings.CollectionChanged += new NotifyCollectionChangedEventHandler(MovieSettings_CollectionChanged); }
/// <summary> /// Initializes a new instance of the <see cref="SqlCeVideoProperties"/> class. /// </summary> /// <param name="id">The id.</param> /// <param name="store">The store.</param> public SqlCeVideoProperties(int id, SqlCeMovieDataSource store) { Id = id; Store = store; Dictionary <string, object> columns = Store.GetRow(Table.VideoProperties, Id); duration = Store.GetValue <int>(columns["duration"]); width = Store.GetValue <int>(columns["width"]); height = Store.GetValue <int>(columns["height"]); format = columns["format"].ToString(); encoding = columns["encoding"].ToString(); bitrate = Store.GetValue <int>(columns["bitrate"]); }
/// <summary> /// Initializes a new instance of the <see cref="SqlCeAudioProperties"/> class. /// </summary> /// <param name="id">The id.</param> /// <param name="store">The store.</param> public SqlCeAudioProperties(int id, SqlCeMovieDataSource store) { Id = id; Store = store; Dictionary <string, object> columns = Store.GetRow(Table.AudioProperties, Id); format = columns["format"].ToString(); bitrate = Store.GetValue <int>(columns["bitrate"]); channels = Store.GetValue <int>(columns["channels"]); encoding = columns["encoding"].ToString(); string langString = columns["language"].ToString(); language = langString == string.Empty || langString.Length < 1 ? null : langString != "iv" ? new CultureInfo(langString) : null; }
/// <summary> /// Initializes a new instance of the <see cref="SqlCeMediaFile"/> class. /// </summary> /// <param name="id">The id.</param> /// <param name="store">The store.</param> public SqlCeMediaFile(int id, SqlCeMovieDataSource store) { Id = id; Store = store; Dictionary <string, object> columns = Store.GetRow(Table.MediaFiles, Id); Path = columns["path"].ToString(); size = Store.GetValue <long>(columns["size"]); List <int> videoRefs = Store.GetReferences(Table.MediaFiles, Table.VideoProperties, Id); if (videoRefs.Count > 0) { video = new SqlCeVideoProperties(videoRefs[0], Store); } List <int> audioRefs = Store.GetReferences(Table.MediaFiles, Table.AudioProperties, Id); Audio = new ObservableCollection <IAudioProperties>(); audioRefs.ForEach(a => Audio.Add(new SqlCeAudioProperties(a, Store))); Audio.CollectionChanged += new NotifyCollectionChangedEventHandler(Audio_CollectionChanged); }