Exemplo n.º 1
0
        private void refreshView()
        {
            SongName.Content   = track.title;
            ArtistName.Content = track.artist.name;
            Uri uri = new Uri(connecter.getArt(track.id), UriKind.RelativeOrAbsolute);

            AlbumArt.Navigate(uri);
        }
Exemplo n.º 2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            SongName.Content   = track.title;
            ArtistName.Content = track.artist.name;
            Uri uri = new Uri(connecter.getArt(track.id), UriKind.RelativeOrAbsolute);

            AlbumArt.Navigate(uri);
        }
Exemplo n.º 3
0
 private void AddAlbumArtEventHandlers(AlbumArt albumArt)
 {
     if (mAlbumArtsWithListendedEvents.Add(albumArt))
     {
         albumArt.ImageSizeChanged += OnImageSizeChanged;
         albumArt.CoverTypeChanged += OnCoverTypeChanged;
     }
 }
Exemplo n.º 4
0
 private void ReSort(AlbumArt albumArt)
 {
     if (Items.PassesFilter(albumArt))             // If it isn't filtered-in, then it doesn't need re-sorting
     {
         var editableCollectionView = (IEditableCollectionView)Items;
         editableCollectionView.EditItem(albumArt);
         editableCollectionView.CommitEdit();
     }
 }
Exemplo n.º 5
0
 public static AlbumArtResponse ToAlbumArtResponse(this AlbumArt albumArt)
 {
     return(new AlbumArtResponse
     {
         Id = albumArt.Id,
         Width = albumArt.Width,
         Height = albumArt.Height
     });
 }
        private async Task DownloadAsync(Uri uri, string songfilename, string title, string artist, string album, string artUrl, string artfilename)
        {
            AlbumArt objArt = null;

            using (var httpClient = new HttpClient())
            {
                using (var request = new HttpRequestMessage(HttpMethod.Get, uri))
                {
                    using (
                        Stream contentStream = await(await httpClient.SendAsync(request)).Content.ReadAsStreamAsync(),
                        stream = new FileStream(songfilename, FileMode.Create, FileAccess.Write, FileShare.None, 10000000, true))
                    {
                        await contentStream.CopyToAsync(stream);

                        _logger.LogInformation("Successfully Downloaded {0}", songfilename);
                    }
                }

                try
                {
                    using (var request = new HttpRequestMessage(HttpMethod.Get, new Uri(artUrl)))
                    {
                        using (
                            Stream contentStream = await(await httpClient.SendAsync(request)).Content.ReadAsStreamAsync(),
                            stream = new FileStream(artfilename, FileMode.Create, FileAccess.Write, FileShare.None, 100000, true))
                        {
                            await contentStream.CopyToAsync(stream);
                        }
                    }

                    using (var stream = new FileStream(artfilename, FileMode.Open, FileAccess.ReadWrite))
                    {
                        objArt = new AlbumArt(stream);
                    }
                }

                catch
                {
                    _logger.LogInformation("Failed to download artwork", songfilename);
                }

                using (var stream = new FileStream(songfilename, FileMode.Open, FileAccess.ReadWrite))
                {
                    using (var tagFile = TagLib.File.Create(new StreamFileAbstraction(songfilename, stream, stream)))
                    {
                        tagFile.Tag.Title      = title;
                        tagFile.Tag.Performers = new[] { artist };
                        tagFile.Tag.Album      = album;
                        if (objArt != null)
                        {
                            tagFile.Tag.Pictures = new IPicture[] { objArt };
                        }
                        tagFile.Save();
                    }
                }
            }
        }
Exemplo n.º 7
0
        private void OnCoverTypeChagned(object sender, EventArgs e)
        {
            AlbumArt albumArt = (AlbumArt)sender;

            if (AllowedCoverTypes != AllowedCoverType.Any || Grouping == Grouping.Type || SortDescription.PropertyName == "CoverType")
            {
                //As this panel's cover type has changed, it must be removed and re-added, so the list re-filters and re-sorts it
                ReFilterAndSort(albumArt);
            }
        }
Exemplo n.º 8
0
        private void OnImageSizeChanged(object sender, EventArgs e)
        {
            AlbumArt albumArt = (AlbumArt)sender;

            if (UseMaximumImageSize || UseMinimumImageSize || Grouping == Grouping.Size || SortDescription.PropertyName.StartsWith("Image"))             //Covers ImageWidth and ImageArea (and ImageHeight, although that shouldn't ever be set)
            {
                //As this panel's size has changed, it must be removed and re-added, so the list re-filters and re-sorts it
                ReFilterAndSort(albumArt);
            }
        }
Exemplo n.º 9
0
 private void InitializeModels()
 {
     _albumArtModel            = _appSettings.AlbumArt;
     _albumArtPopupModel       = _appSettings.AlbumArtPopup;
     _audioBandModel           = _appSettings.AudioBand;
     _customLabelsModel        = _appSettings.CustomLabels;
     _nextButtonModel          = _appSettings.NextButton;
     _playPauseButtonModel     = _appSettings.PlayPauseButton;
     _previousButtonModel      = _appSettings.PreviousButton;
     _progressBarModel         = _appSettings.ProgressBar;
     _audioSourceSettingsModel = _appSettings.AudioSourceSettings;
     _trackModel = new Track();
 }
Exemplo n.º 10
0
        public override object GroupNameFromItem(object item, int level, System.Globalization.CultureInfo culture)
        {
            System.Diagnostics.Debug.Assert(level == 0, "Multiple levels are not supported");
            AlbumArt albumArt = item as AlbumArt;

            if (albumArt == null)
            {
                System.Diagnostics.Debug.Fail("Expecting to be grouping album art");
                return(null);
            }

            return((albumArt.IsSourceLocal ? "Local" : "Online") + " results");
        }
Exemplo n.º 11
0
 private void ReFilterAndSort(AlbumArt albumArt)
 {
     if (ItemsSource is IList)
     {
         IList itemsSource = (IList)ItemsSource;
         itemsSource.Remove(albumArt);
         itemsSource.Add(albumArt);
     }
     else if (ItemsSource == null)             //If there is no items source, then Items might be directly assigned
     {
         Items.Remove(albumArt);
         Items.Add(albumArt);
     }
     else
     {
         System.Diagnostics.Debug.Fail("Can't re-add the album art for re-sorting and filtering, as ItemsSource is not an IList");
     }
 }
Exemplo n.º 12
0
        private void saveImgLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var sfd = new SaveFileDialog
            {
                SupportMultiDottedExtensions = true,
                FileName = string.Format("{0} (Album Art).{1}", Info.FileName, Info.ID3Tags.AlbumArtTag.GetPictureExt()),
                Filter   = string.Format("Image File (*.{0})|*.{0}", Info.ID3Tags.AlbumArtTag.GetPictureExt())
            };

            if (sfd.ShowDialog() == DialogResult.OK && sfd.FileName.Length > 0)
            {
                try
                {
                    AlbumArt.Save(sfd.FileName, AlbumArt.RawFormat);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error in Saving Image", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 13
0
        public override object GroupNameFromItem(object item, int level, System.Globalization.CultureInfo culture)
        {
            System.Diagnostics.Debug.Assert(level == 0, "Multiple levels are not supported");
            AlbumArt albumArt = item as AlbumArt;

            if (albumArt == null)
            {
                System.Diagnostics.Debug.Fail("Expecting to be grouping album art");
                return(null);
            }

            double smallerDimension = Math.Min(albumArt.ImageWidth, albumArt.ImageHeight);

            for (int i = 0; i < sSizeGroupings.Length; i++)
            {
                if (smallerDimension > sSizeGroupings[i])
                {
                    return(sSizeGroups[i]);
                }
            }
            return(sSizeGroups[sSizeGroupings.Length]);
        }
Exemplo n.º 14
0
        private void OnCoverTypeChanged(object sender, EventArgs e)
        {
            if (!NoAutoReSort)
            {
                AlbumArt albumArt = (AlbumArt)sender;

                if (!DisableFilters && AllowedCoverTypes != AllowedCoverType.Any)
                {
                    if (ReFilter(albumArt))
                    {
                        //Item was removed and readded, so no need to re-sort
                        return;
                    }
                }

                if (Grouping == Grouping.Type || SortDescription.PropertyName == "CoverType")
                {
                    //As this panel's cover type has changed, it must be removed and re-added, so the list re-filters and re-sorts it
                    ReSort(albumArt);
                }
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Loads the embedded album art from the item with the given path.
        /// MPD usually implements this by reading embedded pictures from binary tags (e.g. ID3v2’s APIC tag).
        /// Uses <see cref="Commands.Database.ReadPicture"/> recursively under the hood to get the full image and returns the image content as a byte array.
        /// Returns null if the file can't be found or contains no image.
        /// </summary>
        /// <param name="path">path to an item</param>
        /// <returns>AlbumArt with byte[] image or null</returns>
        public async Task <IAlbumArt> LoadEmbeddedAlbumArt(string path)
        {
            var       completed = false;
            var       offset    = 0;
            var       array     = new byte[0];
            IAlbumArt art       = null;

            while (!completed)
            {
                var result = await SendAsync(new Commands.Database.ReadPicture(path, offset));

                if (result.Result != null && !result.Status.HasError)
                {
                    if (result.Result.ChunkLength == 0)
                    {
                        completed = true;
                        art       = new AlbumArt
                        {
                            Bytes    = array,
                            ItemPath = path,
                            MimeType = result.Result.MimeType
                        };
                    }
                    else
                    {
                        offset += result.Result.ChunkLength;
                        array   = ByteExtensions.Combine(array, result.Result.Binary);
                    }
                }
                else
                {
                    completed = true;
                }
            }

            return(art.HasContent ? art : null);
        }
Exemplo n.º 16
0
        public override void LoadContent(ContentManager content)
        {
            /**** Load Assets ****/
            // Load Song
            song = content.Load <Song>("Music/" + songname);

            // Load Album Art
            if (albumname != "n/a")
            {
                try
                {
                    txtAlbumArt = content.Load <Texture2D>("Textures/Album Art/" + albumname);
                }
                catch
                {
                    txtAlbumArt = content.Load <Texture2D>("Textures/Album Art/defaultalbumart");
                }
            }
            else
            {
                txtAlbumArt = content.Load <Texture2D>("Textures/Album Art/defaultalbumart");
            }
            albumart = new AlbumArt(txtAlbumArt, 10, 10);

            // Load SFX
            hitsound = content.Load <SoundEffect>("sfx/normal-hitclap");

            // Load Fonts
            fontJetset = content.Load <SpriteFont>("Fonts/JetSet");

            // Load Textures
            txtNote    = content.Load <Texture2D>("TestNote");
            txtOverlay = content.Load <Texture2D>("TestOverlay2");
            txtNoteHit = content.Load <Texture2D>("Textures/NoteHit");


            /**** Further Initialization of game objects ****/
            overlay = new Overlay(game, this, txtOverlay);

            listbutton.Add(new WidgetButton(game, this,
                                            content.Load <Texture2D>("Textures/Overlay/Button1"),
                                            content.Load <Texture2D>("Textures/Overlay/Button1On"),
                                            555, 920, 164, 84, Microsoft.Xna.Framework.Input.Keys.S));
            listbutton.Add(new WidgetButton(game, this,
                                            content.Load <Texture2D>("Textures/Overlay/Button2"),
                                            content.Load <Texture2D>("Textures/Overlay/Button2On"),
                                            700, 920, 137, 84, Microsoft.Xna.Framework.Input.Keys.D));
            listbutton.Add(new WidgetButton(game, this,
                                            content.Load <Texture2D>("Textures/Overlay/Button3"),
                                            content.Load <Texture2D>("Textures/Overlay/Button3On"),
                                            835, 920, 117, 84, Microsoft.Xna.Framework.Input.Keys.F));
            listbutton.Add(new WidgetButton(game, this,
                                            content.Load <Texture2D>("Textures/Overlay/Button4"),
                                            content.Load <Texture2D>("Textures/Overlay/Button4On"),
                                            967, 920, 117, 84, Microsoft.Xna.Framework.Input.Keys.J));
            listbutton.Add(new WidgetButton(game, this,
                                            content.Load <Texture2D>("Textures/Overlay/Button5"),
                                            content.Load <Texture2D>("Textures/Overlay/Button5On"),
                                            1082, 920, 137, 84, Microsoft.Xna.Framework.Input.Keys.K));
            listbutton.Add(new WidgetButton(game, this,
                                            content.Load <Texture2D>("Textures/Overlay/Button6"),
                                            content.Load <Texture2D>("Textures/Overlay/Button6On"),
                                            1200, 920, 164, 84, Microsoft.Xna.Framework.Input.Keys.L));


            ReadFile();

            MediaPlayer.Play(song);
        }
Exemplo n.º 17
0
 public abstract void DoDisplay(AlbumArt albumArt);
Exemplo n.º 18
0
        public RhythmGameResults(GraphicsDevice graphicsDevice, Game g, RhythmGame rg, AlbumArt art) : base(graphicsDevice, g)
        {
            this.graphicsDevice = graphicsDevice;
            game       = g;
            rhythmgame = rg;

            // Bring in Album Artwork to display
            albumart = art;
            albumart.Bounds.Width  *= 2;
            albumart.Bounds.Height *= 2;
            albumart.Bounds.X       = (g.graphics.PreferredBackBufferWidth / 2) - (albumart.Bounds.Width / 2);
            albumart.Bounds.Y       = (g.graphics.PreferredBackBufferHeight / 2) - (albumart.Bounds.Height / 2);

            countPerfect      = rhythmgame.countPerfect;
            countGood         = rhythmgame.countGood;
            countBreak        = rhythmgame.countBreak;
            maxChain          = rhythmgame.maxChain;
            accuracy          = (rhythmgame.hitNoteCount / rhythmgame.totalNoteCount) * 100.0f;
            accuracyFormatted = Convert.ToSingle(decimal.Round((decimal)accuracy, 2, MidpointRounding.AwayFromZero));

            posPerfect = new Vector2(450, 185);
            posGood    = new Vector2(450, 330);
            posBreak   = new Vector2(450, 475);
            posMax     = new Vector2(450, 630);
            posAccu    = new Vector2(450, 770);

            previousKeyboardState = Keyboard.GetState();
        }
Exemplo n.º 19
0
 public SynchronousFullSizeImageStream(AlbumArt albumArt)
 {
     mAlbumArt = albumArt;
     mAlbumArt.RetrieveFullSizeImage(mWaitForImage);
 }
Exemplo n.º 20
0
 public override void DoDisplay(AlbumArt albumArt)
 {
 }
Exemplo n.º 21
0
 private void RemoveAlbumArtEventHandlers(AlbumArt albumArt)
 {
     albumArt.ImageSizeChanged -= OnImageSizeChanged;
     albumArt.CoverTypeChanged -= OnCoverTypeChanged;
     mAlbumArtsWithListendedEvents.Remove(albumArt);
 }