Exemple #1
0
        protected async override void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);
            try
            {
                var continueArgs = args as FileOpenPickerContinuationEventArgs;
                if (continueArgs != null && continueArgs.Files.Any())
                {
                    switch (OpenFilePickerReason)
                    {
                    case OpenFilePickerReason.OnOpeningVideo:
                        if (Window.Current.Content == null)
                        {
                            await LaunchTheApp();
                        }
                        await Locator.MediaPlaybackViewModel.OpenFile(continueArgs.Files[0]);

                        break;

                    case OpenFilePickerReason.OnOpeningSubtitle:
                    {
                        string mru = StorageApplicationPermissions.FutureAccessList.Add(continueArgs.Files[0]);
                        string mrl = "winrt://" + mru;
                        Locator.MediaPlaybackViewModel.OpenSubtitle(mrl);
                    }
                    break;

                    case OpenFilePickerReason.OnPickingAlbumArt:
                        if (continueArgs.Files == null)
                        {
                            return;
                        }
                        var file = continueArgs.Files.First();
                        if (file == null)
                        {
                            return;
                        }
                        var byteArray = await ConvertImage.ConvertImagetoByte(file);

                        await App.MusicMetaService.SaveAlbumImageAsync(SelectedAlbumItem, byteArray);

                        await Locator.MusicLibraryVM._albumDatabase.Update(SelectedAlbumItem);

                        SelectedAlbumItem = null;
                        break;
                    }
                }
                OpenFilePickerReason = OpenFilePickerReason.Null;
            }
            catch (Exception e)
            {
                ExceptionHelper.CreateMemorizedException("App.cs.OnActivated", e);
            }
        }
Exemple #2
0
        public async override void Execute(object parameter)
        {
            var album = parameter as AlbumItem;

            if (album == null)
            {
                var args = parameter as ItemClickEventArgs;
                if (args != null)
                {
                    album = args.ClickedItem as AlbumItem;
                }
            }

            var openPicker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.PicturesLibrary
            };

            openPicker.FileTypeFilter.Add(".jpg");
            openPicker.FileTypeFilter.Add(".jpeg");
            openPicker.FileTypeFilter.Add(".png");
            openPicker.FileTypeFilter.Add(".gif");
            // Windows Phone launches the picker, then freezes the app. We need
            // to pick it up again on OnActivated.
#if WINDOWS_PHONE_APP
            App.OpenFilePickerReason = OpenFilePickerReason.OnPickingAlbumArt;
            App.SelectedAlbumItem    = album;
            openPicker.PickSingleFileAndContinue();
#else
            var file = await openPicker.PickSingleFileAsync();

            if (file == null)
            {
                return;
            }
            var byteArray = await ConvertImage.ConvertImagetoByte(file);

            await App.MusicMetaService.SaveAlbumImageAsync(album, byteArray);

            await Locator.MusicLibraryVM._albumDatabase.Update(album);
#endif
        }
Exemple #3
0
        private async void ChangeBackground_OnClicked(object sender, RoutedEventArgs e)
        {
            var openPicker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.PicturesLibrary
            };

            openPicker.FileTypeFilter.Add(".jpg");
            openPicker.FileTypeFilter.Add(".jpeg");
            openPicker.FileTypeFilter.Add(".png");
            openPicker.FileTypeFilter.Add(".gif");
            StorageFile file = await openPicker.PickSingleFileAsync();

            if (file == null)
            {
                return;
            }
            try
            {
                IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read);

                BitmapImage bitmapImage = new BitmapImage();
                ImageBrush  brush       = new ImageBrush();
                await bitmapImage.SetSourceAsync(stream);

                brush.ImageSource        = bitmapImage;
                brush.Stretch            = Stretch.None;
                App.RootFrame.Background = brush;
                var img = await ConvertImage.ConvertImagetoByte(file);

                await ImageTools.SaveWallpaper(img);
            }
            catch (Exception ex)
            {
                var msgDlg = new MessageDialog("Something went wrong settings the background. :-(.");
                msgDlg.ShowAsync();
            }
        }
        public async override void Execute(object parameter)
        {
            var album = parameter as AlbumItem;

            if (album == null)
            {
                var args = parameter as ItemClickEventArgs;
                if (args != null)
                {
                    album = args.ClickedItem as AlbumItem;
                }
            }

            var openPicker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.PicturesLibrary
            };

            openPicker.FileTypeFilter.Add(".jpg");
            openPicker.FileTypeFilter.Add(".jpeg");
            openPicker.FileTypeFilter.Add(".png");
            openPicker.FileTypeFilter.Add(".gif");
            // Windows Phone launches the picker, then freezes the app. We need
            // to pick it up again on OnActivated.
            var file = await openPicker.PickSingleFileAsync();

            if (file == null)
            {
                return;
            }
            var byteArray = await ConvertImage.ConvertImagetoByte(file);

            await Locator.MusicMetaService.SaveAlbumImageAsync(album, byteArray);

            await Locator.MediaLibrary.Update(album);
        }