Example #1
0
        /// <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="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);
        }
Example #3
0
        /// <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);
        }