Я пытаюсь сделать приложение UWP
который устанавливает обои рабочего стола на основе времени ввода. Как вы видите на картинке, после выбора изображения вы устанавливаете время и добавляете его в список. в указанное время изображение будет применено в качестве обоев через фоновое задание. Но я пропускаю важный шаг. Я пытаюсь найти способ сделать следующие две вещи.
- Я хочу создать список в файле, в который приложение может добавить изображение
URI и время отображения. и способ чтения фоновой задачи
Это.
- Пользовательский интерфейс может отображать добавленные изображения из списка с возможностью удаления одного из них.
Как мне реализовать то, что я упомянул в код, который у меня есть ?
//Pickup Image file
private async void FilePickerWallpaper(object sender, RoutedEventArgs e)
{
FileOpenPicker pickerWallpaper = new FileOpenPicker();
pickerWallpaper.ViewMode = PickerViewMode.Thumbnail;
pickerWallpaper.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
pickerWallpaper.FileTypeFilter.Add(".jpg");
pickerWallpaper.FileTypeFilter.Add(".jpeg");
pickerWallpaper.FileTypeFilter.Add(".png");
//Get to the App local folder
StorageFolder appFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
// Create a subfoloder
String timeNameFile = "TimeWallpaper";
StorageFolder timeFolder = await appFolder.CreateFolderAsync(timeNameFile, CreationCollisionOption.OpenIfExists);
//Check if the folder was created
if (await appFolder.TryGetItemAsync(timeNameFile) != null) Debug.WriteLine("Folder" + timeNameFile + "exist");
else Debug.WriteLine("Folder" + timeNameFile + "does not exist");
//Pick an Image
StorageFile fileName = await pickerWallpaper.PickSingleFileAsync();
if (fileName != null)
{
//Check if the file does not exist
if (await timeFolder.TryGetItemAsync(fileName.Name) != null)
{
string selectedImgName = fileName.Name;
await fileName.CopyAsync(timeFolder, selectedImgName, NameCollisionOption.ReplaceExisting);
//Preview the Image on the interface
selectImg.Source = new BitmapImage(new Uri("ms-appx:///TimeWallpaper/" + selectedImgName));
}
else
{
selectImg.Source = new BitmapImage(new Uri("ms-appx:///Assets/wallpaper.png"));
}
}
}
//add selected file to the List - w
private void AddFile00(object sender, RoutedEventArgs e)
{
BitmapImage bitImageSource = (BitmapImage)selectImg.Source;
}
//Oops! this is to remove the last added image to the list
private void RemoveFile(object sender, RoutedEventArgs e)
{
}