예제 #1
0
        /// <summary>
        /// Sets the data for the current song.
        /// </summary>
        public void SetSongData()
        {
            var currentItem = LibraryManagement.CurrentPlaylist[LibraryManagement.CurrentIndex];
            var imagePath   = LibraryManagement.CoverDownload(currentItem, Constants.CoverType.Album).Result;

            Cover.Source = new BitmapImage(new Uri(imagePath));

            NameOfArtist.Text = currentItem.ArtistName;
            NameOfSong.Text   = currentItem.TrackName;
            NameOfAlbum.Text  = currentItem.AlbumName;
            //NameOfAlbum.BBCode = string.Format("[url=/Content/Library/AlbumView.xaml?id={0}]{1}[/url]", currentItem.CoverID, currentItem.AlbumName);
            //NameOfArtist.BBCode = string.Format("[url=/Content/Library/DetailView.xaml?id={0}]{1}[/url]", currentItem.ParentID, currentItem.ArtistName);
            NameOfArtist.MouseUp += delegate(object sender, MouseButtonEventArgs args)
            {
                Constants.MainDisplayedMediaItem   = LibraryManagement.CurrentPlaylist[LibraryManagement.CurrentIndex];
                Constants.WindowMain.ContentSource = new Uri("/Content/Home/AlbumPage.xaml?type=all", UriKind.Relative);
            };

            SelectCurrentSong(currentItem);

            TimeLeft.Content    = currentItem.TrackDuration.ToString("mm':'ss");
            TimePlaying.Content = TimeSpan.FromSeconds(LibraryManagement.Playback.StreamLength).ToString("mm':'ss");
            Slider.Maximum      = LibraryManagement.Playback.StreamLength;
            Slider.Value        = 0;
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AlbumView"/> class.
        /// </summary>
        public AlbumView()
        {
            InitializeComponent();
            //var param = Constants.GetParameter();
            //string id = param.Where(paramater => paramater.Key.ToLower() == "id").FirstOrDefault().Value;

            //_albumData = LibraryManagement.AllAlbums;
            //_albumData = LibraryManagement.AllAlbums;



            _album  = Constants.MainDisplayedMediaItem;
            _tracks = LibraryManagement.GetAlbumTracks(_album);

            var columnName   = new DataGridTextColumn();
            var columnLength = new DataGridTextColumn();

            if (_tracks.Length == 0)
            {
                return;
            }
            Cover.Source = new BitmapImage(new Uri(LibraryManagement.CoverDownload(_album, Constants.CoverType.Album).Result));
            Title.Text   = _tracks[0].AlbumName + " by " + _tracks[0].ArtistName;

            columnName.Header  = "Name";
            columnName.Binding = new Binding("Name");

            columnLength.Header  = "Length";
            columnLength.Binding = new Binding("Length");

            DataGrid.Columns.Add(columnName);
            DataGrid.Columns.Add(columnLength);

            foreach (MediaItem item in _tracks)
            {
                DataGrid.Items.Add(new DataItem
                {
                    Name   = item.TrackName,
                    Length = item.TrackDuration.ToString("mm':'ss"),
                    Rating = null
                });
            }
        }
예제 #3
0
        public static Canvas DrawCover(MediaItem item, WrapPanel targetPanel, string Text, MediaItem tag, Constants.CoverType coverType)
        {
            var displayedCanvas = new Canvas()
            {
                Width  = 250,
                Height = 250,
                Margin = new Thickness(10, 10, 0, 0)
            };

            var imagePath =
                LibraryManagement.CoverDownload(item, coverType).Result;

            var cover = new Image()
            {
                VerticalAlignment   = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Left,
                Stretch             = Stretch.UniformToFill,
                Width  = 250,
                Height = 250,
                Source = new BitmapImage(new Uri(imagePath))
            };



            var label = new TextBlock
            {
                MaxWidth     = 200,
                Text         = Text,
                FontSize     = 15,
                Foreground   = Brushes.White,
                TextWrapping = TextWrapping.Wrap
            };

            var labelOutline1 = new TextBlock {
                MaxWidth = 200, Text = Text, FontSize = 15, Foreground = Brushes.Black, TextWrapping = TextWrapping.Wrap
            };
            var labelOutline2 = new TextBlock {
                MaxWidth = 200, Text = Text, FontSize = 15, Foreground = Brushes.Black, TextWrapping = TextWrapping.Wrap
            };
            var labelOutline3 = new TextBlock {
                MaxWidth = 200, Text = Text, FontSize = 15, Foreground = Brushes.Black, TextWrapping = TextWrapping.Wrap
            };
            var labelOutline4 = new TextBlock {
                MaxWidth = 200, Text = Text, FontSize = 15, Foreground = Brushes.Black, TextWrapping = TextWrapping.Wrap
            };

            const int labelFromTop  = 200;
            const int labelFromLeft = 20;

            // White label
            Canvas.SetLeft(label, labelFromLeft);
            Canvas.SetTop(label, labelFromTop);

            // making the outline
            const int borderWith = 1;


            Canvas.SetTop(labelOutline1, labelFromTop - borderWith);
            Canvas.SetLeft(labelOutline1, labelFromLeft - borderWith);

            Canvas.SetTop(labelOutline2, labelFromTop - borderWith);
            Canvas.SetLeft(labelOutline2, labelFromLeft + borderWith);

            Canvas.SetTop(labelOutline3, labelFromTop + borderWith);
            Canvas.SetLeft(labelOutline3, labelFromLeft - borderWith);

            Canvas.SetTop(labelOutline4, labelFromTop + borderWith);
            Canvas.SetLeft(labelOutline4, labelFromLeft + borderWith);

            displayedCanvas.Children.Add(cover);

            displayedCanvas.Children.Add(labelOutline1);
            displayedCanvas.Children.Add(labelOutline2);
            displayedCanvas.Children.Add(labelOutline3);
            displayedCanvas.Children.Add(labelOutline4);

            displayedCanvas.Children.Add(label);
            displayedCanvas.Tag = tag;

            targetPanel.Children.Add(displayedCanvas);

            return(displayedCanvas);
        }
예제 #4
0
        private void GetArtistCovers()
        {
            if (!Constants.CheckCovers)
            {
                return;
            }


            const string artistCoverDownload = "Downloading artist covers {0} of {1}";
            const string albumCoverDownload  = "Downloading album covers {0} of {1}";

            //! \todo clean this crap.
            int index = 0;

            //.AsParallel().For
            Parallel.ForEach(LibraryManagement.AllArtists,
                             new ParallelOptions {
                MaxDegreeOfParallelism = 4
            },                                                    // limit threads
                             async(artist) =>
            {
                GeneralExtensions.DispatcherHelper(() =>
                                                   LabelStatus.Text = String.Format(artistCoverDownload, index, LibraryManagement.AllArtists.Length));

                MediaItem item = LibraryManagement.AllArtists[index];
                await LibraryManagement.CoverDownload(null, Constants.CoverType.Artist);
                index++;
            });

            index = 0;
            Parallel.ForEach(LibraryManagement.AllAlbums,
                             new ParallelOptions {
                MaxDegreeOfParallelism = 4
            },                                                      // limit threads
                             (artist) =>
            {
                GeneralExtensions.DispatcherHelper(() =>
                                                   LabelStatus.Text = String.Format(albumCoverDownload, index, LibraryManagement.AllAlbums.Length));

                MediaItem item = LibraryManagement.AllAlbums[index];
                LibraryManagement.CoverDownload(null, Constants.CoverType.Album);
                index++;
            });

            //for ( int index = 0; index < LibraryManagement.AllArtists.Length; index++ )
            //{
            //    GeneralExtensions.DispatcherHelper(() =>
            //      LabelStatus.Text = String.Format(coverDownload, index, LibraryManagement.AllArtists.Length)) ;

            //    MediaItem item = LibraryManagement.AllArtists[index];
            //    LibraryManagement.CoverDownload( new Image(), item.Artist, Constants.CoverType.Artist );

            //    // dunno what this was suposed to do but it crashes.
            //    //Application.Current.Dispatcher.Invoke(
            //    //DispatcherPriority.Normal,
            //    //(ThreadStart)delegate
            //    //{
            //    //    LibraryManagement.CoverDownload(new Image(), item.Artist, Constants.CoverType.Artist);
            //    //});
            //    // }
            //}
        }