Automatically copy multiple images and display fragment notifications?

This is my code for applications for Windows 8, in which I copy 1 image from a local folder to a folder for storing applications, and then displays a fragmentation notification. Please help me autocopy all images from the image library, and then these images indicated in the tile notifications. I do not know how to access or copy all images from the image library ... there is no user interface for copying images.

public private class BlankPage: Page {string imageRelativePath = String.Empty;

    public BlankPage()
    {
        this.InitializeComponent();
        CopyImages();
    }

    public async void CopyImages()
    {

        FileOpenPicker picker = new Windows.Storage.Pickers.FileOpenPicker();
        picker.ViewMode = PickerViewMode.Thumbnail;
        picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
        picker.FileTypeFilter.Add(".jpg");
        picker.FileTypeFilter.Add(".jpeg");
        picker.FileTypeFilter.Add(".png");
        picker.CommitButtonText = "Copy";
        StorageFile file = await picker.PickSingleFileAsync();
        StorageFile newFile = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFileAsync(file.Name);
        await file.CopyAndReplaceAsync(newFile);
        this.imageRelativePath = newFile.Path.Substring(newFile.Path.LastIndexOf("\\") + 1);

                IWideTileNotificationContent tileContent = null;
                ITileWideImage wideContent = TileContentFactory.CreateTileWideImage();
                wideContent.RequireSquareContent = false;
                wideContent.Image.Src = "ms-appdata:///local/" + this.imageRelativePath;
                wideContent.Image.Alt = "App data";
                tileContent = wideContent;
                tileContent.RequireSquareContent = false;
                TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());
            }
        }
+3
source share
2 answers

, IReadOnlyList , , TileUpdateManager. .

+2

PicturesLibrary:

// from my sample app "MetroContractSample" http://metrocontractsample.codeplex.com/documentation
var queryOptions = new QueryOptions(CommonFileQuery.DefaultQuery, new[] { ".jpg", ".png", ".bmp", ".gif", }) { FolderDepth = FolderDepth.Deep, };
StorageFileQueryResult query = KnownFolders.PicturesLibrary.CreateFileQueryWithOptions(queryOptions);
var fileInfoFactory = new FileInformationFactory(query, ThumbnailMode.SingleItem);
IReadOnlyList<FileInformation> fileInfoList = await fileInfoFactory.GetFilesAsync();

. PicturesLibrary Package.appxmanifest.

0

All Articles