Exemple #1
0
        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();
                    }
                });
            }
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        public void SelectBackgroundColor(BrushModel brush)
        {
            BackgroundBrushModels.Remove(brush);
            BackgroundBrushModels.Insert(0, brush);

            OnPropertyChanged("BackgroundBrush");
        }
Exemple #4
0
        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());
        }