private async Task DeleteImageCommandCommandExecute(VisualApartmentLocationPhoto parm) { var result = await Shell.Current.DisplayAlert( "Alert", "Are you sure you want to remove?", "Yes", "No"); if (result) { //if (parm.GetType() == typeof(VisualProjectLocationPhoto)) //{ VisualApartmentLocationPhoto obj = parm as VisualApartmentLocationPhoto; await InvasiveVisualApartmentLocationPhotoDataStore.DeleteItemAsync(obj); //InvasiveVisualApartmentLocationPhotoItems = new ObservableCollection<VisualApartmentLocationPhoto>(await InvasiveVisualApartmentLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false)); //InvasiveUnitPhotoCount = InvasiveVisualApartmentLocationPhotoItems.Count.ToString(); //} //if (parm.GetType() == typeof(VisualBuildingLocationPhoto)) //{ // VisualBuildingLocationPhoto obj = parm as VisualBuildingLocationPhoto; // await VisualBuildingLocationPhotoDataStore.DeleteItemAsync(obj); //} //if (parm.GetType() == typeof(VisualApartmentLocationPhoto)) //{ // VisualApartmentLocationPhoto obj = parm as VisualApartmentLocationPhoto; // await VisualApartmentLocationPhotoDataStore.DeleteItemAsync(obj); //} await Load(); } }
public async Task AddNewPhoto(VisualApartmentLocationPhoto obj) { await VisualApartmentLocationPhotoDataStore.AddItemAsync(obj); VisualApartmentLocationPhotoItems = new ObservableCollection <VisualApartmentLocationPhoto>(await VisualApartmentLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(Apartment_Visual.Id, false)); CountItem = VisualApartmentLocationPhotoItems.Count.ToString(); }
private async Task DeleteImageCommandCommandExecute(BindingModel parm) { var result = await Shell.Current.DisplayAlert( "Alert", "Are you sure you want to remove?", "Yes", "No"); if (result) { if (parm.GetType() == typeof(VisualProjectLocationPhoto)) { VisualProjectLocationPhoto obj = parm as VisualProjectLocationPhoto; await VisualProjectLocationPhotoDataStore.DeleteItemAsync(obj, IsEdit); } if (parm.GetType() == typeof(VisualBuildingLocationPhoto)) { VisualBuildingLocationPhoto obj = parm as VisualBuildingLocationPhoto; await VisualBuildingLocationPhotoDataStore.DeleteItemAsync(obj); } if (parm.GetType() == typeof(VisualApartmentLocationPhoto)) { VisualApartmentLocationPhoto obj = parm as VisualApartmentLocationPhoto; await VisualApartmentLocationPhotoDataStore.DeleteItemAsync(obj); } await LoadAsync(); } }
public async Task <bool> DeleteItemAsync(VisualApartmentLocationPhoto item) { //var oldItem = items.Where((VisualApartmentLocationPhoto arg) => arg.Id == id).FirstOrDefault(); //items.Remove(oldItem); //return await Task.FromResult(true); item.IsDelete = true; var oldItem = items.Where((VisualApartmentLocationPhoto arg) => arg.Id == item.Id).FirstOrDefault(); items.Remove(oldItem); items.Add(item); var oldITRaktem = App.VisualEditTrackingForInvasive.Where(c => c.Id == item.Id && c.IsServerData == true).SingleOrDefault(); if (oldITRaktem != null) { App.VisualEditTrackingForInvasive.Remove(oldITRaktem); App.VisualEditTrackingForInvasive.Add(new MultiImage() { Id = item.Id, Image = item.ImageUrl, ParentId = item.VisualApartmentId, Status = "Delete", IsDelete = true, IsServerData = true }); } var oldDelete = App.VisualEditTrackingForInvasive.Where(c => c.Id == item.Id && c.IsServerData == false && c.Status == "New").SingleOrDefault(); if (oldDelete != null) { App.VisualEditTrackingForInvasive.Remove(oldDelete); } return(await Task.FromResult(true)); }
public async Task <bool> AddItemAsync(VisualApartmentLocationPhoto item) { items.Add(item); App.VisualEditTracking.Add(new MultiImage() { Id = item.Id, Image = item.ImageUrl, ParentId = item.VisualApartmentId, Status = "New", IsServerData = false }); return(await Task.FromResult(true)); }
private async Task DeleteImageCommandCommandExecute(BindingModel parm) { try { var result = await Shell.Current.DisplayAlert( "Alert", "Are you sure you want to remove?", "Yes", "No"); if (result) { if (parm.GetType() == typeof(VisualProjectLocationPhoto)) { VisualProjectLocationPhoto obj = parm as VisualProjectLocationPhoto; await VisualProjectLocationPhotoDataStore.DeleteItemAsync(obj, IsEdit).ConfigureAwait(false); VisualProjectLocationPhotoItems = new ObservableCollection <VisualProjectLocationPhoto>(await VisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(ProjectLocation_Visual.Id, false)); if (VisualProjectLocationPhotoItems.Count == 0) { await Shell.Current.Navigation.PopAsync(); } } if (parm.GetType() == typeof(VisualBuildingLocationPhoto)) { VisualBuildingLocationPhoto obj = parm as VisualBuildingLocationPhoto; await VisualBuildingLocationPhotoDataStore.DeleteItemAsync(obj).ConfigureAwait(false);; VisualBuildingLocationPhotoItems = new ObservableCollection <VisualBuildingLocationPhoto>(await VisualBuildingLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(BuildingLocation_Visual.Id, false)); if (VisualBuildingLocationPhotoItems.Count == 0) { await Shell.Current.Navigation.PopAsync(); } } if (parm.GetType() == typeof(VisualApartmentLocationPhoto)) { VisualApartmentLocationPhoto obj = parm as VisualApartmentLocationPhoto; await VisualApartmentLocationPhotoDataStore.DeleteItemAsync(obj).ConfigureAwait(false);; VisualApartmentLocationPhotoItems = new ObservableCollection <VisualApartmentLocationPhoto>(await VisualApartmentLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(Apartment_Visual.Id, false)); if (VisualApartmentLocationPhotoItems.Count == 0) { await Shell.Current.Navigation.PopAsync(); } } // await LoadAsync(); } } catch (Exception) { } }
public async Task AddNewPhoto(VisualApartmentLocationPhoto obj) { if (App.IsInvasive == true) { // InvasiveVisualProjectLocationPhotoItems.Add(obj); await InvasiveVisualApartmentLocationPhotoDataStore.AddItemAsync(obj); InvasiveVisualApartmentLocationPhotoItems = new ObservableCollection <VisualApartmentLocationPhoto>(await InvasiveVisualApartmentLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false)); InvasiveUnitPhotoCount = InvasiveVisualApartmentLocationPhotoItems.Count.ToString(); return; } await VisualApartmentLocationPhotoDataStore.AddItemAsync(obj); VisualApartmentLocationPhotoItems = new ObservableCollection <VisualApartmentLocationPhoto>(await VisualApartmentLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false)); UnitPhotoCount = VisualApartmentLocationPhotoItems.Count.ToString(); }
private async Task <bool> Running() { if (App.ListCamera2Api != null) { foreach (var photo in App.ListCamera2Api) { VisualApartmentLocationPhoto newObj = new VisualApartmentLocationPhoto() { ImageUrl = photo.Image, Id = Guid.NewGuid().ToString(), VisualApartmentId = VisualForm.Id, DateCreated = DateTime.Now }; if (App.IsInvasive == true) { _ = AddNewPhoto(newObj).ConfigureAwait(false); } else { _ = AddNewPhoto(newObj).ConfigureAwait(false); // await VisualProjectLocationPhotoDataStore.AddItemAsync(newObj); } } App.ListCamera2Api.Clear(); } UnitPhotos = new ObservableCollection <VisualApartmentLocationPhoto>(); if (VisualForm != null) { if (string.IsNullOrEmpty(VisualForm.Id)) { VisualApartmentLocationPhotoItems = new ObservableCollection <VisualApartmentLocationPhoto>(await VisualApartmentLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false)); } else { VisualApartmentLocationPhotoItems = new ObservableCollection <VisualApartmentLocationPhoto>(await VisualApartmentLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false)); if (App.IsInvasive == true) { InvasiveVisualApartmentLocationPhotoItems = new ObservableCollection <VisualApartmentLocationPhoto>((await InvasiveVisualApartmentLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false))); InvasiveUnitPhotoCount = InvasiveVisualApartmentLocationPhotoItems.Count.ToString(); } } UnitPhotoCount = VisualApartmentLocationPhotoItems.Count.ToString(); } return(await Task.FromResult(true)); }
private async Task ImageDetailCommandCommandExecute(VisualApartmentLocationPhoto parm) { //if (parm.GetType() == typeof(VisualProjectLocationPhoto)) //{ // VisualProjectLocationPhoto = parm as VisualProjectLocationPhoto; // VisualProjectLocationPhoto = parm; ImgData.Path = parm.ImageUrl; ImgData.ParentID = parm.VisualApartmentId; ImgData.VisualApartmentLocationPhoto = parm; ImgData.IsEditVisual = true; //ImgData.VisualProjectLocationPhotos = VisualProjectLocationPhotoItems; ImgData.FormType = "VA"; await CurrentWithoutDetail.EditImage(ImgData, GetImage); //} //if (parm.GetType() == typeof(VisualBuildingLocationPhoto)) //{ // VisualBuildingLocationPhoto = parm as VisualBuildingLocationPhoto; // ImgData.Path = VisualBuildingLocationPhoto.ImageUrl; // ImgData.FormType = "VB"; // ImgData.IsEditVisual = IsEdit; // ImgData.VisualBuildingLocationPhoto = VisualBuildingLocationPhoto; // await CurrentWithoutDetail.EditImage(ImgData, GetImage); //} //if (parm.GetType() == typeof(VisualApartmentLocationPhoto)) //{ // VisualApartmentLocationPhoto = parm as VisualApartmentLocationPhoto; // ImgData.Path = VisualApartmentLocationPhoto.ImageUrl; // ImgData.FormType = "VA"; // ImgData.IsEditVisual = IsEdit; // ImgData.VisualApartmentLocationPhoto = VisualApartmentLocationPhoto; // await CurrentWithoutDetail.EditImage(ImgData, GetImage); //} }
private async Task ChoosePhotoFromCameraCommandExecute() { string selectedOption = await App.Current.MainPage.DisplayActionSheet("Select Option", "Cancel", null, new string[] { "Take New Photo", "From Gallery" }); switch (selectedOption) { case "Take New Photo": if (Device.RuntimePlatform == Device.Android) { await Shell.Current.Navigation.PushModalAsync(new Camera2Forms.CameraPage() { BindingContext = new CameraViewModel() { Apartment_Visual = VisualForm, IsVisualApartment = true } }); //await Shell.Current.Navigation.PushModalAsync(new Camera2Forms.CameraPageForAndroid() { BindingContext = new CameraViewModel() { Apartment_Visual = VisualForm, IsVisualApartment = true } }); } if (Device.RuntimePlatform == Device.iOS) { // await Shell.Current.Navigation.PushModalAsync(new Camera2Forms.CameraPage() { BindingContext = new CameraViewModel() { Apartment_Visual = VisualForm, IsVisualApartment = true } }); } break; case "From Gallery": if (Device.RuntimePlatform == Device.iOS) { //If the image is modified (drawings, etc) by the users, you will need to change the delivery mode to HighQualityFormat. bool imageModifiedWithDrawings = false; if (imageModifiedWithDrawings) { await GMMultiImagePicker.Current.PickMultiImage(true); } else { await GMMultiImagePicker.Current.PickMultiImage(); } // MessagingCenter.Unsubscribe<App, List<string>>((App)Xamarin.Forms.Application.Current, "ImagesSelectediOS"); MessagingCenter.Subscribe <App, List <string> >((App)Xamarin.Forms.Application.Current, "ImagesSelectediOS", (s, images) => { //If we have selected images, put them into the carousel view. if (images.Count > 0) { foreach (var item in images) { VisualApartmentLocationPhoto obj = new VisualApartmentLocationPhoto() { ImageUrl = item, Id = Guid.NewGuid().ToString(), VisualApartmentId = VisualForm.Id, DateCreated = DateTime.Now }; _ = AddNewPhoto(obj); } } }); } if (Device.RuntimePlatform == Device.Android) { DependencyService.Get <IMediaService>().OpenGallery(); MessagingCenter.Unsubscribe <App, List <string> >((App)Xamarin.Forms.Application.Current, "ImagesSelectedAndroid"); MessagingCenter.Subscribe <App, List <string> >((App)Xamarin.Forms.Application.Current, "ImagesSelectedAndroid", (s, images) => { foreach (var item in images) { VisualApartmentLocationPhoto obj = new VisualApartmentLocationPhoto() { ImageUrl = item, Id = Guid.NewGuid().ToString(), VisualApartmentId = VisualForm.Id, DateCreated = DateTime.Now }; _ = AddNewPhoto(obj); } //If we have selected images, put them into the carousel view. //if (images.Count > 0) //{ // // ImgCarouselView.ItemsSource = images; // //InfoText.IsVisible = true; //InfoText is optional //} }); } break; default: break; } }
private async void OnPictureFinished() { // ImageSource temp = CameraPreview.ImageSource; CameraViewModel vm = (CameraViewModel)this.BindingContext; // await DisplayAlert("Confirm", "Picture Taken", "", "Ok"); //string filepath = await DependencyService.Get<ISaveFile>().SaveFiles(Guid.NewGuid().ToString(), CameraPreview.byteArr); //img1.Source = filepath; //list.Add(filepath); // detailGrid.IsVisible = false; string filepath = await CrossScreenshot.Current.CaptureAndSaveAsync(); if (vm.IsVisualProjectLocatoion) { VisualProjectLocationPhoto obj = new VisualProjectLocationPhoto() { Image = filepath, Id = Guid.NewGuid().ToString(), VisualID = vm.ProjectLocation_Visual.Id }; await vm.AddNewPhoto(obj); } if (vm.IsVisualBuilding) { VisualBuildingLocationPhoto obj = new VisualBuildingLocationPhoto() { Image = filepath, Id = Guid.NewGuid().ToString(), VisualID = vm.BuildingLocation_Visual.Id }; await vm.AddNewPhoto(obj); } if (vm.IsVisualApartment) { VisualApartmentLocationPhoto obj = new VisualApartmentLocationPhoto() { Image = filepath, Id = Guid.NewGuid().ToString(), VisualID = vm.Apartment_Visual.Id }; await vm.AddNewPhoto(obj); } if (vm.IsProjectLocation) { ProjectCommonLocationImages obj = new ProjectCommonLocationImages() { ImageUrl = filepath, Id = Guid.NewGuid().ToString(), ProjectLocationId = vm.ProjectLocation.Id }; await vm.AddNewPhoto(obj); } if (vm.IsBuildingLocation) { BuildingCommonLocationImages obj = new BuildingCommonLocationImages() { Image = filepath, Id = Guid.NewGuid().ToString(), BuildingId = vm.BuildingLocation.Id }; await vm.AddNewPhoto(obj); } if (vm.IsApartment) { BuildingApartmentImages obj = new BuildingApartmentImages() { Image = filepath, Id = Guid.NewGuid().ToString(), ApartmentID = vm.BuildingApartment.Id }; await vm.AddNewPhoto(obj); } detailGrid.IsVisible = true; img1.Source = filepath; // countSelect.Text = list.Count + " Photo Taken"; }