Esempio n. 1
0
        public async void SetContext(Artist artist)
        {
            this.DataContext         = ART = artist;
            this.ART.IsUpdatingImage = false;
            lastFmButton.Visibility  = ApplicationInfo.Current.HasInternetConnection ? Visibility.Visible : Visibility.Collapsed;
            //Color color;

            StorageFile imgFile = null;

            try
            {
                imgFile = await StorageFile.GetFileFromApplicationUriAsync(artist.ImageUri);
            }
            catch
            {
            }

            try
            {
                if (imgFile != null)
                {
                    using (var stream = await imgFile.OpenAsync(FileAccessMode.Read))
                    {
                        //color = await ImageHelper.GetDominantColor(stream);
                        BitmapImage b = new BitmapImage();
                        rootBrush.ImageSource = b;
                        b.SetSource(stream);
                    }

                    ellipse.SetSource(artist.ImageUri);
                }
                else
                {
                    await LastFm.DownloadImage(artist, true);
                }
            }
            catch
            {
            }

            //AnimateBackgroundToColor(color);

            ////ellipseBrush.ImageSource = bmp;
            //ellipse.Source = bmp;
            //bmp.UriSource = new Uri("ms-appdata:///local/Artists/artist_" + StringHelper.RemoveSpecialChar(ART.Name) + ".jpg", UriKind.Absolute);


            //BitmapImage blurbmp = new BitmapImage();
            //blurbmp.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
            //rootBrush.ImageSource = blurbmp;
            //blurbmp.UriSource = new Uri("ms-appdata:///local/Artists/artist_" + StringHelper.RemoveSpecialChar(ART.Name) + ".jpg", UriKind.Absolute);


            title.Text = ART.Name.ToUpper();
            subtitleSeparator.Visibility = subtitle2.Visibility = Visibility.Visible;
        }
 private async void DownloadImage(Artist artist)
 {
     try
     {
         //LastFm lfm = new LastFm();
         //lfm.DownloadCompleted += Lfm_DownloadCompleted;
         await LastFm.DownloadImage(artist);
     }
     catch
     {
     }
 }
Esempio n. 3
0
        private async void DownloadImages(Artist artist)
        {
            string lang = ApplicationInfo.Current.Language;

            //Debug.WriteLine("Preparing to download image: " + artist.Name);

            try
            {
                await LastFm.DownloadImage(artist);
            }
            catch
            {
            }
        }
Esempio n. 4
0
        private void artistImage_Tapped(object sender, TappedRoutedEventArgs e)
        {
            MenuFlyout menu = new MenuFlyout()
            {
                MenuFlyoutPresenterStyle = Application.Current.Resources["MenuFlyoutModernStyle"] as Style,
            };

            MenuFlyoutItem item1 = new MenuFlyoutItem()
            {
                Text  = "Ampliar",
                Tag   = "",
                Style = Application.Current.Resources["ModernMenuFlyoutItem"] as Style,
            };

            MenuFlyoutItem item2 = new MenuFlyoutItem()
            {
                Text  = "Salvar imagem",
                Tag   = "",
                Style = Application.Current.Resources["ModernMenuFlyoutItem"] as Style,
            };

            MenuFlyoutItem item3 = new MenuFlyoutItem()
            {
                Text  = "Compartilhar imagem",
                Tag   = "",
                Style = Application.Current.Resources["ModernMenuFlyoutItem"] as Style,
            };

            MenuFlyoutItem item4 = new MenuFlyoutItem()
            {
                Text  = "Buscar nova imagem",
                Tag   = "",
                Style = Application.Current.Resources["ModernMenuFlyoutItem"] as Style,
            };

            item1.Click += (s, a) =>
            {
                //PageHelper.MainPage.Navigate(typeof(ImagePreview), ART);
            };

            //item2.Click += async (s, a) =>
            //{
            //    try
            //    {
            //        var folder = await ApplicationData.Current.LocalFolder.GetFolderAsync("Artists");
            //        StorageFile imgFile = await folder.GetFileAsync("artist_" + StringHelper.RemoveSpecialChar(ART.Name) + ".jpg");

            //        await imgFile.CopyAsync(KnownFolders.PicturesLibrary);

            //        MessageDialog md = new MessageDialog("Imagem salva em sua biblioteca de imagens", "Imagem salva");
            //        await md.ShowAsync();
            //    }
            //    catch (Exception ex)
            //    {
            //        Debug.WriteLine(ex.Message);
            //    }
            //};

            item3.Click += (s, a) =>
            {
            };

            item4.Click += async(s, a) =>
            {
                if (ApplicationInfo.Current.HasInternetConnection)
                {
                    this.ART.IsUpdatingImage = true;
                    //if (PageHelper.Artists != null)
                    //    PageHelper.Artists.NavigationCacheMode = NavigationCacheMode.Disabled;

                    ellipse.RemoveSource();
                    rootBrush.ImageSource = null;
                    await LastFm.DownloadImage(ART, true);
                }
            };


            menu.Items.Add(item1);
            menu.Items.Add(item2);
            menu.Items.Add(item3);
            menu.Items.Add(item4);
            menu.Placement = FlyoutPlacementMode.Bottom;
            menu.ShowAt(ellipse);
        }