public async Task AddNewPhoto(VisualProjectLocationPhoto obj) { await VisualProjectLocationPhotoDataStore.AddItemAsync(obj); VisualProjectLocationPhotoItems = new ObservableCollection <VisualProjectLocationPhoto>(await VisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(ProjectLocation_Visual.Id, false)); CountItem = VisualProjectLocationPhotoItems.Count.ToString(); }
public async Task <bool> DeleteItemAsync(VisualProjectLocationPhoto item, bool IsEditVisual) { item.IsDelete = true; var oldItem = items.Where((VisualProjectLocationPhoto 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.VisualLocationId, 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)); }
private async Task DeleteImageCommandCommandExecute(VisualProjectLocationPhoto 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 InvasiveVisualProjectLocationPhotoDataStore.DeleteItemAsync(obj, true); InvasiveVisualProjectLocationPhotoItems = new ObservableCollection <VisualProjectLocationPhoto>(await InvasiveVisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false)); InvasiveUnitPhotoCount = InvasiveVisualProjectLocationPhotoItems.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(); } }
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 AddNewPhoto(VisualProjectLocationPhoto obj) { await VisualProjectLocationPhotoDataStore.AddItemAsync(obj).ConfigureAwait(false); VisualProjectLocationPhotoItems = new ObservableCollection <VisualProjectLocationPhoto>(await VisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false)); UnitPhotoCount = VisualProjectLocationPhotoItems.Count.ToString(); }
private async Task <bool> Running() { if (App.ListCamera2Api != null) { foreach (var photo in App.ListCamera2Api) { VisualProjectLocationPhoto newObj = new VisualProjectLocationPhoto() { ImageUrl = photo.Image, Id = Guid.NewGuid().ToString(), VisualLocationId = VisualForm.Id }; if (App.IsInvasive == true) { _ = AddNewPhoto(newObj).ConfigureAwait(false); } else { _ = AddNewPhoto(newObj).ConfigureAwait(false); // await VisualProjectLocationPhotoDataStore.AddItemAsync(newObj); } } App.ListCamera2Api.Clear(); } UnitPhotos = new ObservableCollection <VisualProjectLocationPhoto>(); if (VisualForm != null) { if (string.IsNullOrEmpty(visualForm.Id)) { VisualProjectLocationPhotoItems = new ObservableCollection <VisualProjectLocationPhoto>(await VisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false).ConfigureAwait(false)); } else { App.IsVisualEdidingMode = true; VisualProjectLocationPhotoItems = new ObservableCollection <VisualProjectLocationPhoto>(await VisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false).ConfigureAwait(false)); if (App.IsInvasive == true) { InvasiveVisualProjectLocationPhotoItems = new ObservableCollection <VisualProjectLocationPhoto>(await InvasiveVisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false).ConfigureAwait(false)); InvasiveUnitPhotoCount = InvasiveVisualProjectLocationPhotoItems.Count.ToString(); } // VisualProjectLocationPhotoItems = VisualProjectLocationPhotoItems.Where(c => c.IsDelete = false).ToList(); //if (App.IsVisualEdidingMode == true) //{ // VisualProjectLocationPhotoItems = new ObservableCollection<VisualProjectLocationPhoto>(await VisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, true)); // App.IsVisualEdidingMode = false; //} //else //{ // VisualProjectLocationPhotoItems = new ObservableCollection<VisualProjectLocationPhoto>(await VisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false)); //} } UnitPhotoCount = VisualProjectLocationPhotoItems.Count.ToString(); } 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 <bool> AddItemAsync(VisualProjectLocationPhoto item) { if (App.IsInvasive == true) { item.InvasiveImage = true; } items.Add(item); App.VisualEditTrackingForInvasive.Add(new MultiImage() { Id = item.Id, Image = item.ImageUrl, ParentId = item.VisualLocationId, Status = "New", IsServerData = false }); return(await Task.FromResult(true)); }
public async Task AddNewPhoto(VisualProjectLocationPhoto obj) { if (App.IsInvasive == true) { // InvasiveVisualProjectLocationPhotoItems.Add(obj); await InvasiveVisualProjectLocationPhotoDataStore.AddItemAsync(obj); InvasiveVisualProjectLocationPhotoItems = new ObservableCollection <VisualProjectLocationPhoto>(await InvasiveVisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false)); InvasiveUnitPhotoCount = InvasiveVisualProjectLocationPhotoItems.Count.ToString(); } else { await VisualProjectLocationPhotoDataStore.AddItemAsync(obj); VisualProjectLocationPhotoItems = new ObservableCollection <VisualProjectLocationPhoto>(await VisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false)); UnitPhotoCount = VisualProjectLocationPhotoItems.Count.ToString(); } }
private async Task ImageDetailCommandCommandExecute(VisualProjectLocationPhoto parm) { //if (parm.GetType() == typeof(VisualProjectLocationPhoto)) //{ // VisualProjectLocationPhoto = parm as VisualProjectLocationPhoto; // VisualProjectLocationPhoto = parm; ImgData.Path = parm.ImageUrl; ImgData.ParentID = parm.VisualLocationId; ImgData.VisualProjectLocationPhoto = parm; ImgData.IsEditVisual = true; //ImgData.VisualProjectLocationPhotos = VisualProjectLocationPhotoItems; ImgData.FormType = "VP"; 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 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"; }
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() { ProjectLocation_Visual = VisualForm, IsVisualProjectLocatoion = true } }); // await Shell.Current.Navigation.PushModalAsync(new Camera2Forms.CameraPageForAndroid() { BindingContext = new CameraViewModel() { ProjectLocation_Visual = VisualForm, IsVisualProjectLocatoion = true } }); } if (Device.RuntimePlatform == Device.iOS) { await Shell.Current.Navigation.PushModalAsync(new Camera2Forms.CameraPage() { BindingContext = new CameraViewModel() { ProjectLocation_Visual = VisualForm, IsVisualProjectLocatoion = true } }); } //MessagingCenter.Unsubscribe<Camera2Forms.CameraPage, ObservableCollection<MultiImage>>(this, "ImageList"); //MessagingCenter.Subscribe<Camera2Forms.CameraPage, ObservableCollection<MultiImage>>(this, "ImageList", async (Camera2Forms.CameraPage obj, ObservableCollection<MultiImage> item) => //// MessagingCenter.Subscribe<Camera2Forms.CameraPage, ObservableCollection<MultiImage>>(this, "ImageList", async (obj, item) => //{ // var items = item as ObservableCollection<MultiImage>; // foreach (var photo in items) // { // VisualProjectLocationPhoto newObj = new VisualProjectLocationPhoto() { ImageUrl = photo.Image, Id = Guid.NewGuid().ToString(), VisualLocationId = VisualForm.Id }; // if (App.IsInvasive == true) // { // _ = AddNewPhoto(newObj).ConfigureAwait(false); // } // else // { // _ = AddNewPhoto(newObj).ConfigureAwait(false); // // await VisualProjectLocationPhotoDataStore.AddItemAsync(newObj); // } // } // items.Clear(); // //VisualProjectLocationPhotoItems = new ObservableCollection<VisualProjectLocationPhoto>(await VisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id)); // //UnitPhotoCount = VisualProjectLocationPhotoItems.Count.ToString(); // // UnitPhotoCount = (await VisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(ProjectLocation.Id)).Count().ToString(); //}); 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) { VisualProjectLocationPhoto obj = new VisualProjectLocationPhoto() { ImageUrl = item, Id = Guid.NewGuid().ToString(), VisualLocationId = VisualForm.Id }; _ = 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) { VisualProjectLocationPhoto obj = new VisualProjectLocationPhoto() { ImageUrl = item, Id = Guid.NewGuid().ToString(), VisualLocationId = VisualForm.Id }; _ = AddNewPhoto(obj).ConfigureAwait(false); } //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; } }