Beispiel #1
0
        private async Task PickPhotoCommandExecute(PlatformDocument document)
        {
            if (document.Name.EndsWith(".png") || document.Name.EndsWith(".jpg"))
            {
                var photoModel = new PhotoModel
                {
                    NoteId = Id
                };

                var mediaService = DependencyService.Get <IMediaService>();
                var fileSystem   = DependencyService.Get <IFileSystem>();
                var imageContent = fileSystem.ReadAllBytes(document.Path);

                var    resizedImage = mediaService.ResizeImage(imageContent, ConstantsHelper.ResizedImageWidth, ConstantsHelper.ResizedImageHeight);
                string path         = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                string imagePath    = Path.Combine(path, document.Name);

                File.WriteAllBytes(imagePath, resizedImage);
                photoModel.ResizedPath = imagePath;
                photoModel.Thumbnail   = imagePath;

                await _transformHelper.ResizeAsync(imagePath, photoModel);

                Photos.Add(photoModel.ToPhotoViewModel());
                PhotosCollectionChanged?.Invoke(this, EventArgs.Empty);
            }
            IsLoading = false;
        }
        public async Task OnGetAsync()
        {
            var photos = await service.GetAllAsync();

            foreach (var photo in photos)
            {
                PhotoDto2 elem = new PhotoDto2()
                {
                    Titlu     = photo.Titlu,
                    Descriere = photo.Descriere,
                    Path      = photo.Path,
                    Eveniment = photo.Eveniment,
                    Other     = photo.Other.Split(';')
                };
                Photos.Add(elem);
                string[] props = photo.Other.Split(';');
                foreach (string prop in props)
                {
                    if (!Properties.Contains(prop))
                    {
                        Properties.Add(prop);
                    }
                }
            }
            PhotosFiltered = Photos;
            Count          = PhotosFiltered.Count;
        }
        private async Task PickPhotoCommandExecute(PlatformDocument document)
        {
            IsLoading = true;
            var ci = CrossMultilingual.Current.CurrentCultureInfo;

            if (document.Name.EndsWith(".png") || document.Name.EndsWith(".jpg"))
            {
                var mediaService = DependencyService.Get <IMediaService>();
                var fileSystem   = DependencyService.Get <IFileSystem>();
                var imageContent = fileSystem.ReadAllBytes(document.Path);

                var resizedImage = mediaService.ResizeImage(imageContent, ConstantsHelper.ResizedImageWidth,
                                                            ConstantsHelper.ResizedImageHeight);
                var photoModel = new PhotoModel
                {
                    Name  = document.Name,
                    Image = Convert.ToBase64String(resizedImage)
                };

                Photos.Add(photoModel.ToPhotoViewModel());
                PhotosCollectionChanged?.Invoke(this, EventArgs.Empty);
                IsLoading = false;
            }
            else
            {
                IsLoading = false;
                var imagePickErrorMesssageLocalized =
                    Resmgr.Value.GetString(ConstantsHelper.ImagePickErrorMesssage, ci);
                var okLocalized = Resmgr.Value.GetString(ConstantsHelper.Ok, ci);

                _alertService.ShowOkAlert(imagePickErrorMesssageLocalized, okLocalized);
            }
        }
Beispiel #4
0
        public void OnAppearing()
        {
            eventAggregator.GetEvent <TabActivatedEvent>().Publish(nameof(HomePageViewModel));

            if (!hasAppeared)
            {
                hasAppeared = true;

                Task.Run(async() =>
                {
                    var photos = await unsplashService.GetRandomPhotosAsync(10);

                    if (photos != null)
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            Photos.Clear();
                            foreach (var photo in photos)
                            {
                                Photos.Add(photo);
                            }
                        });
                    }
                });
            }
        }
        public async Task OnGetAsync()
        {
            var media = await fc.Afisare_MediaAsync();

            Campuri = await fc.Initializare_proprietatiAsync();

            if (!string.IsNullOrEmpty(Cauta))
            {
                media.Clear();
                string p1, p2;
                p1    = Camp;
                p2    = Cauta;
                media = await fc.Afisare_rezultateAsync(Camp, p2);
            }

            media.Sort();
            int i = 0;

            foreach (var item in media)
            {
                var p = new PhotoDTO();
                p.Path = item;
                p.Id   = i;
                i     += 1;
                Photos.Add(p);
            }
        }
Beispiel #6
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Photos.Clear();

                var photos = await restService.GetPhotos();

                foreach (var photo in photos)
                {
                    Photos.Add(photo);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Beispiel #7
0
        public async Task GetPhotos()
        {
            if (IsBusy)
            {
                return;
            }

            Exception error = null;

            try
            {
                IsBusy = true;
                var items = await mobileService.GetPhotos();

                Photos.Clear();
                foreach (var item in items)
                {
                    Photos.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error: " + ex);
                error = ex;
            }
            finally
            {
                IsBusy = false;
            }

            if (error != null)
            {
                dialogService.ShowError("Error! " + error.Message + " OK");
            }
        }
Beispiel #8
0
        /// <summary>
        /// Retrieves a list of photos that belong to a particular directory.
        /// </summary>
        /// <param name="token">A reference to the current SessionToken object.</param>
        /// <param name="dir">A PhotoDirectory object representing the directory who's photos that are to be retrieved.</param>
        /// <returns></returns>
        public Photos GetPhotos(SessionToken token, PhotoDirectory dir)
        {
            IDbCommand cmd = GetCommand();

            cmd.CommandText = "SELECT ID, Name, VirtualPath, DateTaken, FileSize, ViewedCount FROM tblPhotos WHERE DirectoryID = " + dir.Id +
                              " AND IsDeleted <> 'Y' ORDER BY DateTaken, Name";
            //cmd.Parameters.Add(CreateIntParam("DirectoryID", dir.Id));

            Photos results = new Photos();

            using (IDataReader reader = cmd.ExecuteReader(CommandBehavior.Default))
            {
                while (reader.Read())
                {
                    Photo photo = new Photo(token,
                                            reader.GetInt32(0),
                                            reader.GetString(1),
                                            reader.GetString(2),
                                            reader.IsDBNull(3) ? DateTime.MinValue : reader.GetDateTime(3),
                                            reader.GetInt32(4),
                                            reader.GetInt32(5));
                    results.Add(photo);
                }
            }

            return(results);
        }
Beispiel #9
0
 public void FillPage()
 {
     if (Exhibit.Photos?.Count != 0)
     {
         Photos.Clear();
         foreach (var photo in Exhibit.Photos)
         {
             if (photo?.Photo != null)
             {
                 Photos.Add(ImageSource.FromStream(() => new MemoryStream(photo.Photo)));
             }
         }
         CarouselVisibility = true;
         if (Photos.Count == 1)
         {
             IndicatorVisibility = false;
         }
         else
         {
             IndicatorVisibility = true;
         }
     }
     else
     {
         CarouselVisibility = false;
     }
     Title = Exhibit.Title;
     Text  = Exhibit.Text;
 }
Beispiel #10
0
 private void UpdateList(IEnumerable <Photo> photos)
 {
     Photos.Clear();
     foreach (var photo in photos)
     {
         Photos.Add(photo);
     }
 }
Beispiel #11
0
        public void UploadPicture(string pictureName, string name)
        {
            Photo photo = new Photo();

            photo.FileName = pictureName;
            photo.Name     = name;
            Photos.Add(photo);
        }
Beispiel #12
0
 public void FillPage()
 {
     Photos.Clear();
     foreach (var photo in Exhibit.Photos)
     {
         Photos.Add(photo);
     }
     Title = Exhibit.Title;
 }
        public async Task OpenCamearaAsync()
        {
            var cameraStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Plugin.Permissions.Abstractions.Permission.Camera); 
            if (cameraStatus != PermissionStatus.Granted)
            {
                
            {
                    
 var results = await CrossPermissions.Current.RequestPermissionsAsync(Plugin.Permissions.Abstractions.Permission.Camera); 
                if (results.ContainsKey(Plugin.Permissions.Abstractions.Permission.Camera))

                    {
                        
 cameraStatus = results[Plugin.Permissions.Abstractions.Permission.Camera];
                    }
                    

                }
            }
            
 var storageStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Plugin.Permissions.Abstractions.Permission.Storage); 
            if (storageStatus != PermissionStatus.Granted)

            {
                
            {
                    
 var results = await CrossPermissions.Current.RequestPermissionsAsync(Plugin.Permissions.Abstractions.Permission.Storage); 
                if (results.ContainsKey(Plugin.Permissions.Abstractions.Permission.Storage))

                    {
                        
 storageStatus = results[Plugin.Permissions.Abstractions.Permission.Storage];
                    }
                    

                }
            }
            

            if (cameraStatus == PermissionStatus.Granted && storageStatus == PermissionStatus.Granted)
            {
                await CrossMedia.Current.Initialize();

                if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
                {
                    await DialogService.ShowAlertAsync("Camera is not ready", "Warning", "Ok");

                    return;
                }
                var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
                {
                    PhotoSize          = Plugin.Media.Abstractions.PhotoSize.Small,
                    CompressionQuality = 70
                });

                if (file == null)
                {
                    return;
                }
                var imageSource = ImageSource.FromStream(() =>
                {
                    var stream = file.GetStream();
                    return(stream);
                });
                Photos.Add(new ImageItemViewModel
                {
                    ImageSource = imageSource,
                    ImageName   = file.Path.Substring(file.Path.LastIndexOf("/") + 1)
                });
            }
        }
Beispiel #14
0
        public Restaurant(string JsonDataString)
        {
            JsonObject JsonData = JsonObject.Parse(JsonDataString);

            this.Id          = (int)JsonData.GetNamedNumber("id");
            this.Label       = JsonData.GetNamedString("label");
            this.Description = JsonData.GetNamedString("description");
            this.Cuisine     = JsonData.GetNamedString("cuisine");
            this.Telephone   = (JsonData.GetNamedValue("telephone").ValueType == JsonValueType.String) ? JsonData.GetNamedString("telephone") : null;

            this.LiveMusic    = JsonData.GetNamedBoolean("live_music");
            this.PaymentCards = JsonData.GetNamedBoolean("payment_cards");
            this.Parking      = JsonData.GetNamedBoolean("parking");

            this.OperationTime = "Ресторан" + " " + JsonData.GetNamedString("restaurant_open") + " - " + JsonData.GetNamedString("restaurant_open") + "\n" +
                                 "Кухня" + " " + JsonData.GetNamedString("kitchen_open") + " - " + JsonData.GetNamedString("kitchen_close");
            this.Logo            = JsonData.GetNamedString("logo");
            this.BackgroundImage = JsonData.GetNamedString("background_image");

            this.Email     = (JsonData.GetNamedValue("email").ValueType == JsonValueType.String) ? JsonData.GetNamedString("email") : null;
            this.Website   = (JsonData.GetNamedValue("website").ValueType == JsonValueType.String) ? JsonData.GetNamedString("website") : null;
            this.Facebook  = (JsonData.GetNamedValue("facebook").ValueType == JsonValueType.String) ? JsonData.GetNamedString("facebook") : null;
            this.Instagram = (JsonData.GetNamedValue("instagram").ValueType == JsonValueType.String) ? JsonData.GetNamedString("instagram") : null;

            this.Locations = new ObservableCollection <Location>();
            foreach (var item in JsonData.GetNamedArray("locations").Select(n => n.GetObject()))
            {
                Locations.Add(new Location((int)item.GetNamedNumber("id"),
                                           (item.GetNamedValue("latitude").ValueType == JsonValueType.Number) ? item.GetNamedNumber("latitude") : -1,
                                           (item.GetNamedValue("longitude").ValueType == JsonValueType.Number) ? item.GetNamedNumber("longitude") : -1,
                                           item.GetNamedString("address"),
                                           item.GetNamedString("telephones")));
            }

            this.Photos = new ObservableCollection <Photo>();
            foreach (var item in JsonData.GetNamedArray("photos").Select(n => n.GetString()))
            {
                Photos.Add(new Photo(item));
            }

            this.Menu = new ObservableCollection <MenuItem>();
            foreach (var item in JsonData.GetNamedArray("menu").Select(n => n.GetObject()))
            {
                int    Id    = (int)item.GetNamedNumber("id");
                string Label = item.GetNamedString("label");

                Menu.Add(new MenuItem(Id, Label));
            }

            this.RestaurantSocial = new Social(
                (int)JsonData.GetNamedObject("social").GetNamedNumber("comments"),
                (JsonData.GetNamedObject("social").GetNamedValue("like_id").ValueType == JsonValueType.Number) ? (int)JsonData.GetNamedObject("social").GetNamedNumber("like_id") : -1,
                (int)JsonData.GetNamedObject("social").GetNamedNumber("likes"),
                (int)JsonData.GetNamedObject("social").GetNamedNumber("shares"),
                (JsonData.GetNamedObject("social").GetNamedValue("favourite_id").ValueType == JsonValueType.Number) ? (int)JsonData.GetNamedObject("social").GetNamedNumber("favourite_id") : -1);
        }
        private void LoadImageList()
        {
            Photos.Clear();
            var data = inOutService.LoadPhotoData();

            foreach (var photoData in data)
            {
                Photos.Add(photoViewModelFactory.CreatePhotoViewModel(photoData));
            }
        }
Beispiel #16
0
        /// <summary>
        /// Добавлем фото в список
        /// </summary>
        /// <param name="obj">json</param>
        /// <param name="result">ссылка в описание или комменте</param>
        public static void ListAdd(object obj, string result, List <Photo.Comment> comments = null)
        {
            JObject jObject = JObject.Parse(obj.ToString());
            Photo   item    = new Photo(jObject["owner_id"].Value <int>(), jObject["id"].Value <int>(), jObject["photo_604"].ToString(), result, comments);

            if (Photos.IndexOf(item) < 0)
            {
                Photos.Add(item);
            }
        }
        private async Task PickPhotoAsync()
        {
            var photoPath = await MediaService.PickPhotoAsync();

            if (photoPath != null)
            {
                Photos.Add(photoPath);
                IsImageAdded = true;
            }
        }
Beispiel #18
0
 private void PhotoTaken(object sender, IPhotoMetadata e)
 {
     FileName  = e.FileName;
     FilePath  = e.FilePath;
     Latitude  = e.Latitude;
     Longitude = e.Longitude;
     Timestamp = e.Timestamp;
     Photos.Add(new PhotoMetadata {
         FileName = FileName, Timestamp = Timestamp, Latitude = Latitude, Longitude = Longitude
     });
 }
        public void OnLoad()
        {
            Photos.Clear();

            var photos = photoRepository.GetAll();

            foreach (var photo in photos)
            {
                Photos.Add(photo);
            }
        }
        void SortByTime()
        {
            List <PhotosListModel> listModels = Photos.ToList();

            listModels.Sort((emp1, emp2) => emp1.CreationTime.CompareTo(emp2.CreationTime));
            Photos.Clear();
            foreach (var photosListModel in listModels)
            {
                Photos.Add(photosListModel);
            }
        }
        void AddPhoto(string caption, string uri)
        {
            var image = new BitmapImage();

            image.BeginInit();
            image.UriSource = new Uri(uri, UriKind.Relative);
            image.EndInit();
            Photos.Add(ViewModelSource.Create(() => new Photo {
                Caption = caption, SizeInfo = "700x467", Source = image, ViewSize = new Size(150, 100)
            }));
        }
Beispiel #22
0
 public Photo AddPhoto(string filename, string comment, PhotoType type)
 {
     lock (Photos)
     {
         var p = new Photo(ObjectMode.New)
         {
             Vehicle = this, Filename = filename, Comment = comment, Type = type
         };
         Photos.Add(p);
         return(p);
     }
 }
Beispiel #23
0
 private void AddPhotosInFolder(string folder)
 {
     try
     {
         foreach (string fileName in Directory.GetFiles(folder, "*.jpg"))
         {
             m_photos.Add(new Photo(fileName));
         }
     }
     catch (UnauthorizedAccessException) { }
     catch (IOException) { }
 }
Beispiel #24
0
        /**
         * This method is for taking the picture using CrossMedia
         *
         * doc for CrossMedia https://github.com/jamesmontemagno/MediaPlugin
         */
        private async void TakePhotoAsync()
        {
            sLogger.TakingAPhoto();
            UserDialogs.Instance.ShowLoading("laden");
            var file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
            {
                DefaultCamera = CameraDevice.Rear
            });

            Photos.Add(file);
            UserDialogs.Instance.HideLoading();
        }
Beispiel #25
0
        private async void LoadMore()
        {
            IsBusy = true;
            _currentPage++;

            var results = await _flickrApi.SearchPhotos(_searchTerm, _currentPage, PageSize);

            foreach (var photo in results)
            {
                Photos.Add(photo);
            }
            IsBusy = false;
        }
Beispiel #26
0
        private async Task TakePicture()
        {
            if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
            {
                await Shell.Current.DisplayAlert("No Camera", ":( No camera available.", "OK");

                return;
            }

            var file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
            {
                Directory   = "Test",
                SaveToAlbum = true,

                CompressionQuality = 100,
                CustomPhotoSize    = 50,
                PhotoSize          = PhotoSize.MaxWidthHeight,
                MaxWidthHeight     = 2000,
            });

            if (file == null)
            {
                return;
            }

            var newPhoto = new Photo
            {
                PhotoUrl    = file.Path,
                ApartmentId = Apartment.Id,
                //Base64=base64,
                Source = ImageSource.FromStream(() =>
                {
                    var fileStream = file.GetStream();
                    return(fileStream);
                })
            };


            if (Photos == null)
            {
                Photos = new ObservableCollection <Photo>()
                {
                    newPhoto
                };
                OnPropertyChanged(nameof(Photos));
            }
            else
            {
                Photos.Add(newPhoto);
            }
        }
        private void Collection_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args)
        {
            foreach(Photo photo in args.NewItems)
            {
                itemsAdded++;
                Photos.Add(photo);
            }

            if(itemsAdded == 20)
            {
                var collection = (ObservableCollection<Photo>)sender;
                collection.CollectionChanged -= Collection_CollectionChanged;
            }
        }
        void DoScan(IImportSource source, bool recurse, bool merge, CancellationToken token)
        {
            FireEvent(ImportEvent.PhotoScanStarted);

            foreach (var info in source.ScanPhotos(recurse, merge))
            {
                ThreadAssist.ProxyToMain(() => Photos.Add(info));
                if (token.IsCancellationRequested)
                {
                    break;
                }
            }

            FireEvent(ImportEvent.PhotoScanFinished);
        }
Beispiel #29
0
        private async void Search(string searchTerm)
        {
            IsBusy      = true;
            _searchTerm = searchTerm;

            _currentPage = 1;
            Photos.Clear();

            var results = await _flickrApi.SearchPhotos(_searchTerm, _currentPage, PageSize);

            foreach (var photo in results)
            {
                Photos.Add(photo);
            }
            IsBusy = false;
        }
Beispiel #30
0
        /// <summary>
        /// Adds a photo to the collection (<see cref="Photos"/>) of product
        /// photos.
        /// </summary>
        private void Add()
        {
            if (fileOperation.IsCorrectDialog() == false)
            {
                return;
            }
            FileOperation.CreateDirectory("Images");
            fileOperation.CopyFile();
            Photos.Add(fileOperation.NewPhoto());
            Photo = Photos.FirstOrDefault();

            // Save the photo.
            products[index].Photos = Photos;
            fileOperation.Products = products;
            fileOperation.Serialize();
        }