コード例 #1
0
ファイル: InterfaceClasses.cs プロジェクト: ltj/rentit
 public PublisherAccount(string userName, string fullName, string email, string hashedPassword, string publisherName, MediaItems publishedItems)
     : base(userName, fullName, email, hashedPassword)
 {
     PublisherName = publisherName;
     PublishedItems = publishedItems;
 }
コード例 #2
0
ファイル: PagedDetailedMediaList.cs プロジェクト: ltj/rentit
        /// <summary>
        /// Updates the ListView with the submitted data.
        /// When this method is called, all data previously added to the list 
        /// will be disregarded, and the contents of the ListView will match
        /// the media items passed in the parameter.
        /// </summary>
        /// <param name="mediaItems">
        /// The media items to be loaded into the list.
        /// </param>
        internal void UpdateListContents(MediaItems mediaItems)
        {
            this.BeginUpdate();

            this.CurrentItems = new List<ListViewItem>();

            foreach (var song in mediaItems.Songs)
            {
                var listItem = new ListViewItem(song.Title);
                listItem.SubItems.Add(song.Artist);
                listItem.SubItems.Add(song.Genre);
                listItem.SubItems.Add(song.ReleaseDate.ToShortDateString());
                listItem.SubItems.Add(song.Price.ToString());
                listItem.Group = this.songListViewGroup;
                listItem.Tag = song;

                this.CurrentItems.Add(listItem);
            }

            foreach (var album in mediaItems.Albums)
            {
                var listItem = new ListViewItem(album.Title);
                listItem.SubItems.Add(album.AlbumArtist);
                listItem.SubItems.Add(album.Genre);
                listItem.SubItems.Add(album.ReleaseDate.ToShortDateString());
                listItem.SubItems.Add(album.Price.ToString());
                listItem.Group = this.albumListViewGroup;
                listItem.Tag = album;

                this.CurrentItems.Add(listItem);
            }

            foreach (var movie in mediaItems.Movies)
            {
                var listItem = new ListViewItem(movie.Title);
                listItem.SubItems.Add(movie.Director);
                listItem.SubItems.Add(movie.Genre);
                listItem.SubItems.Add(movie.ReleaseDate.ToShortDateString());
                listItem.SubItems.Add(movie.Price.ToString());
                listItem.Group = this.movieListViewGroup;
                listItem.Tag = movie;

                this.CurrentItems.Add(listItem);
            }

            foreach (var book in mediaItems.Books)
            {
                var listItem = new ListViewItem(book.Title);
                listItem.SubItems.Add(book.Author);
                listItem.SubItems.Add(book.Genre);
                listItem.SubItems.Add(book.ReleaseDate.ToShortDateString());
                listItem.SubItems.Add(book.Price.ToString());
                listItem.Group = this.bookListViewGroup;
                listItem.Tag = book;

                this.CurrentItems.Add(listItem);
            }

            this.RePopulateList();
            this.EndUpdate();
        }
コード例 #3
0
ファイル: MediaGrid.cs プロジェクト: ltj/rentit
        /// <summary>
        /// Helper method for populating the contents of the MediaGrid
        /// with the items given in the parameter.
        /// </summary>
        /// <param name="items"></param>
        private void PopulateGrid(MediaItems items)
        {
            ListViewGrid.Items.Clear();
            var listItemCollection = new List<ListViewItem>();

            // Initialize the thumbnail list.
            var imageList = new ImageList();
            var imageSize = new Size(70, 70);
            imageList.ImageSize = imageSize;
            ListViewGrid.LargeImageList = imageList;

            switch (mediaCriteria.Type)
            {
                case MediaType.Album:
                    int iAlbum = 0;
                    foreach (AlbumInfo album in items.Albums)
                    {
                        ListViewGrid.LargeImageList.Images.Add(
                            BinaryCommuncator.GetThumbnail(album.Id));
                        var item = new ListViewItem(album.Title, iAlbum++);
                        item.SubItems.Add(album.AlbumArtist);
                        item.SubItems.Add(album.Price.ToString());
                        item.Tag = album;

                        listItemCollection.Add(item);
                    }
                    break;
                case MediaType.Book:
                    int iBook = 0;
                    foreach (BookInfo book in items.Books)
                    {
                        ListViewGrid.LargeImageList.Images.Add(
                            BinaryCommuncator.GetThumbnail(book.Id));
                        var item = new ListViewItem(book.Title, iBook++);
                        item.SubItems.Add(book.Author);
                        item.SubItems.Add(book.Price.ToString());
                        item.Tag = book;

                        listItemCollection.Add(item);
                    }
                    break;
                case MediaType.Song:
                    int iSong = 0;
                    foreach (SongInfo song in items.Songs)
                    {
                        ListViewGrid.LargeImageList.Images.Add(
                            BinaryCommuncator.GetThumbnail(song.Id));
                        var item = new ListViewItem(song.Title, iSong++);
                        item.SubItems.Add(song.Artist);
                        item.SubItems.Add(song.Price.ToString());
                        item.Tag = song;

                        listItemCollection.Add(item);
                    }
                    break;
                case MediaType.Movie:
                    int iMovie = 0;
                    foreach (MovieInfo movie in items.Movies)
                    {
                        ListViewGrid.LargeImageList.Images.Add(
                            BinaryCommuncator.GetThumbnail(movie.Id));
                        var item = new ListViewItem(movie.Title, iMovie++);
                        item.SubItems.Add(movie.Director);
                        item.SubItems.Add(movie.Price.ToString());
                        item.Tag = movie;

                        listItemCollection.Add(item);
                    }
                    break;
            }

            // Add all the created ListViewItems to the MediaGrid at once.
            ListViewGrid.Items.AddRange(listItemCollection.ToArray());
        }
コード例 #4
0
ファイル: SearchResultsControl.cs プロジェクト: ltj/rentit
        /// <summary>
        /// Filters the search results based on price range selected.
        /// This is a local filtering.
        /// </summary>
        /// <param name="items">The media items to filter.</param>
        /// <returns>A filtered collection of media.</returns>
        private MediaItems FilterByPrice(MediaItems items)
        {
            var p = (PriceRange)priceFilter.SelectedItem;

            if (p.MinimumPrice == int.MinValue && p.MaximumPrice == int.MaxValue)
                return items; // no price filtering

            IEnumerable<AlbumInfo> albums = items.Albums.Where(m => m.Price >= p.MinimumPrice && m.Price <= p.MaximumPrice);
            IEnumerable<MovieInfo> movies = items.Movies.Where(m => m.Price >= p.MinimumPrice && m.Price <= p.MaximumPrice);
            IEnumerable<BookInfo> books = items.Books.Where(m => m.Price >= p.MinimumPrice && m.Price <= p.MaximumPrice);
            IEnumerable<SongInfo> songs = items.Songs.Where(m => m.Price >= p.MinimumPrice && m.Price <= p.MaximumPrice);

            return new MediaItems
            {
                Albums = albums.ToArray(),
                Movies = movies.ToArray(),
                Books = books.ToArray(),
                Songs = songs.ToArray()
            };
        }