public async Task AddNewPhoto(VisualBuildingLocationPhoto obj)
        {
            await VisualBuildingLocationPhotoDataStore.AddItemAsync(obj);

            VisualBuildingLocationPhotoItems = new ObservableCollection <VisualBuildingLocationPhoto>(await VisualBuildingLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(BuildingLocation_Visual.Id, false));
            CountItem = VisualBuildingLocationPhotoItems.Count.ToString();
        }
Пример #2
0
        public async Task <bool> DeleteItemAsync(VisualBuildingLocationPhoto item)
        {
            //var oldItem = items.Where((VisualBuildingLocationPhoto arg) => arg.Id == id).FirstOrDefault();
            //items.Remove(oldItem);

            //return await Task.FromResult(true);
            item.IsDelete = true;
            var oldItem = items.Where((VisualBuildingLocationPhoto 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.VisualBuildingId, 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(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();
            }
        }
        private async Task ImageDetailCommandCommandExecute(VisualBuildingLocationPhoto parm)
        {
            ImgData.Path     = parm.ImageUrl;
            ImgData.ParentID = parm.VisualBuildingId;
            ImgData.VisualBuildingLocationPhoto = parm;
            ImgData.IsEditVisual = true;

            ImgData.FormType = "VB";
            await CurrentWithoutDetail.EditImage(ImgData, GetImage);
        }
Пример #5
0
        public async Task <bool> AddItemAsync(VisualBuildingLocationPhoto item)
        {
            //items.Add(item);

            //return await Task.FromResult(true);
            items.Add(item);
            App.VisualEditTracking.Add(new MultiImage()
            {
                Id = item.Id, Image = item.ImageUrl, ParentId = item.VisualBuildingId, Status = "New", IsServerData = false
            });
            return(await Task.FromResult(true));
        }
Пример #6
0
        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)
            {
            }
        }
        private async Task <bool> Running()
        {
            if (App.ListCamera2Api != null)
            {
                foreach (var photo in App.ListCamera2Api)
                {
                    VisualBuildingLocationPhoto newObj = new VisualBuildingLocationPhoto()
                    {
                        ImageUrl = photo.Image, Id = Guid.NewGuid().ToString(), VisualBuildingId = 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 <VisualBuildingLocationPhoto>();
            if (VisualForm != null)
            {
                if (string.IsNullOrEmpty(visualForm.Id))
                {
                    VisualBuildingLocationPhotoItems = new ObservableCollection <VisualBuildingLocationPhoto>(await VisualBuildingLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false));
                }
                else
                {
                    VisualBuildingLocationPhotoItems = new ObservableCollection <VisualBuildingLocationPhoto>(await VisualBuildingLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false));

                    if (App.IsInvasive == true)
                    {
                        InvasiveVisualBuildingLocationPhotoItems = new ObservableCollection <VisualBuildingLocationPhoto>((await InvasiveVisualBuildingLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false)));
                        InvasiveUnitPhotoCount = InvasiveVisualBuildingLocationPhotoItems.Count.ToString();
                    }
                }

                UnitPhotoCount = VisualBuildingLocationPhotoItems.Count.ToString();
            }

            return(await Task.FromResult(true));
        }
        private async Task DeleteImageCommandCommandExecute(VisualBuildingLocationPhoto parm)
        {
            var result = await Shell.Current.DisplayAlert(
                "Alert",
                "Are you sure you want to remove?",
                "Yes", "No");



            if (result)
            {
                VisualBuildingLocationPhoto obj = parm as VisualBuildingLocationPhoto;
                await InvasiveVisualBuildingLocationPhotoDataStore.DeleteItemAsync(obj);

                InvasiveVisualBuildingLocationPhotoItems = new ObservableCollection <VisualBuildingLocationPhoto>(await InvasiveVisualBuildingLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false));
                InvasiveUnitPhotoCount = InvasiveVisualBuildingLocationPhotoItems.Count.ToString();
            }
        }
        public async Task AddNewPhoto(VisualBuildingLocationPhoto obj)
        {
            if (App.IsInvasive == true)
            {
                // InvasiveVisualProjectLocationPhotoItems.Add(obj);
                await InvasiveVisualBuildingLocationPhotoDataStore.AddItemAsync(obj);

                InvasiveVisualBuildingLocationPhotoItems = new ObservableCollection <VisualBuildingLocationPhoto>(await InvasiveVisualBuildingLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false));
                InvasiveUnitPhotoCount = InvasiveVisualBuildingLocationPhotoItems.Count.ToString();
            }
            else
            {
                await VisualBuildingLocationPhotoDataStore.AddItemAsync(obj);

                VisualBuildingLocationPhotoItems = new ObservableCollection <VisualBuildingLocationPhoto>(await VisualBuildingLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false));
                UnitPhotoCount = VisualBuildingLocationPhotoItems.Count.ToString();
            }
        }
Пример #10
0
        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()
                        {
                            BuildingLocation_Visual = VisualForm, IsVisualBuilding = true
                        }
                    });

                    //await Shell.Current.Navigation.PushModalAsync(new Camera2Forms.CameraPageForAndroid() { BindingContext = new CameraViewModel() { BuildingLocation_Visual = VisualForm, IsVisualBuilding = true } });
                }
                if (Device.RuntimePlatform == Device.iOS)
                {
                    await Shell.Current.Navigation.PushModalAsync(new Camera2Forms.CameraPage()
                    {
                        BindingContext = new CameraViewModel()
                        {
                            BuildingLocation_Visual = VisualForm, IsVisualBuilding = 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)
                            {
                                VisualBuildingLocationPhoto obj = new VisualBuildingLocationPhoto()
                                {
                                    ImageUrl = item, Id = Guid.NewGuid().ToString(), VisualBuildingId = 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)
                        {
                            VisualBuildingLocationPhoto obj = new VisualBuildingLocationPhoto()
                            {
                                ImageUrl = item, Id = Guid.NewGuid().ToString(), VisualBuildingId = 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;
            }
        }