Exemple #1
0
        private async void AddImage(object obj)
        {
            var mediaPicker = new MediaPicker(App.UIContext);
            var photo       = await mediaPicker.TakePhotoAsync(new StoreCameraMediaOptions());

            MobileServiceFile file = await this.itemManager.AddImage(this.todoItem, photo.Path);

            var image = new TodoItemImageViewModel(file, this.todoItem, DeleteImage);

            this.images.Add(image);
        }
        public static async Task<TodoItemImageViewModel> CreateAsync(MobileServiceFile file, TodoItem todoItem, Action<TodoItemImageViewModel> deleteHandler)
        {
            var result = new TodoItemImageViewModel();

            result.deleteHandler = deleteHandler;
            result.name = file.Name;
            result.File = file;
            result.uri = await FileHelper.GetLocalFilePathAsync(todoItem.Id, file.Name);

            result.InitializeCommands();

            return result;
        }
Exemple #3
0
        public async Task LoadImagesAsync()
        {
            IEnumerable <MobileServiceFile> files = await this.itemManager.GetImageFilesAsync(todoItem);

            this.Images = new ObservableCollection <TodoItemImageViewModel>();

            foreach (var f in files)
            {
                var viewModel = await TodoItemImageViewModel.CreateAsync(f, this.todoItem, DeleteImage);

                this.Images.Add(viewModel);
            }
        }
Exemple #4
0
        private async void AddImage(object obj)
        {
            IPlatform mediaProvider   = DependencyService.Get <IPlatform>();
            string    sourceImagePath = await mediaProvider.TakePhotoAsync(App.UIContext);

            //var mediaPicker = new MediaPicker(App.UIContext);
            //var photo = await mediaPicker.TakePhotoAsync(new StoreCameraMediaOptions());

            if (sourceImagePath != null)
            {
                MobileServiceFile file = await this.itemManager.AddImage(this.todoItem, sourceImagePath);

                var image = await TodoItemImageViewModel.CreateAsync(file, this.todoItem, DeleteImage);

                this.images.Add(image);
            }
        }
        public static async Task<TodoItemImageViewModel> CreateAsync(MobileServiceFile file, TodoItem todoItem, Action<TodoItemImageViewModel> deleteHandler)
        {
            var result = new TodoItemImageViewModel();

            result.deleteHandler = deleteHandler;
            result.name = file.Name;
            result.File = file;

            var uri = await FileHelper.GetLocalFilePathAsync(todoItem.Id, file.Name);

            // hack until I figure out how to do this cross-platform
            if (Device.OS == TargetPlatform.Windows) {
                result.uri = new Uri(uri).AbsoluteUri;
            }
            else {
                result.uri = uri;
            }

            result.InitializeCommands();

            return result;
        }
Exemple #6
0
        public static async Task <TodoItemImageViewModel> CreateAsync(MobileServiceFile file, TodoItem todoItem, Action <TodoItemImageViewModel> deleteHandler)
        {
            var result = new TodoItemImageViewModel();

            result.deleteHandler = deleteHandler;
            result.name          = file.Name;
            result.File          = file;

            var uri = await FileHelper.GetLocalFilePathAsync(todoItem.Id, file.Name);

            // hack until I figure out how to do this cross-platform
            if (Device.OS == TargetPlatform.Windows)
            {
                result.uri = new Uri(uri).AbsoluteUri;
            }
            else
            {
                result.uri = uri;
            }

            result.InitializeCommands();

            return(result);
        }
        private async void DeleteImage(TodoItemImageViewModel imageViewModel)
        {
            await this.itemManager.DeleteImage(this.todoItem, imageViewModel.File);

            this.images.Remove(imageViewModel);
        }
Exemple #8
0
        private async void DeleteImage(TodoItemImageViewModel imageViewModel)
        {
            await this.itemManager.DeleteImage(this.todoItem, imageViewModel.File);

            this.images.Remove(imageViewModel);
        }
        private async void AddImage(object obj)
        {
            var mediaPicker = new MediaPicker(App.UIContext);
            var photo = await mediaPicker.TakePhotoAsync(new StoreCameraMediaOptions());

            MobileServiceFile file = await this.itemManager.AddImage(this.todoItem, photo.Path);

            var image = new TodoItemImageViewModel(file, this.todoItem, DeleteImage);

            this.images.Add(image);
        }