public void RemoveBackgroundColor(BrushModel brush) { int index = BackgroundBrushModels.IndexOf(brush); if (index >= 0) { BackgroundBrushModels.RemoveAt(index); } if (index == 0) { OnPropertyChanged("BackgroundBrush"); } if (brush.IsAllowDelete) { Task.Run(async() => { var file = await StorageFile.GetFileFromPathAsync(brush.URIString); if (file != null) { await file.DeleteAsync(); } }); } }
public async Task InsertBackgroundColor(StorageFile file) { StorageFolder folder = ApplicationData.Current.LocalFolder; StorageFolder imgFolder = null; try { imgFolder = await folder.GetFolderAsync("BackgroundImg"); } catch { } if (imgFolder == null) { imgFolder = await folder.CreateFolderAsync("BackgroundImg"); } var copiedFile = await file.CopyAsync(imgFolder, file.Name, NameCollisionOption.GenerateUniqueName); BrushModel brush = new BrushModel() { URIString = copiedFile.Path }; BackgroundBrushModels.Add(brush); }
public void SelectBackgroundColor(BrushModel brush) { BackgroundBrushModels.Remove(brush); BackgroundBrushModels.Insert(0, brush); OnPropertyChanged("BackgroundBrush"); }
public async Task ClearImgCache() { StorageFolder folder = ApplicationData.Current.LocalFolder; StorageFolder imgFolder = null; try { imgFolder = await folder.GetFolderAsync("BackgroundImg"); } catch { } if (imgFolder != null) { await imgFolder.DeleteAsync(); } BackgroundBrushModels = new ObservableCollection <BrushModel>(BrushModel.GetBuiltInModels()); }