Beispiel #1
1
        public static List<PhotoData> GetPhotoData(bool deleteMessages)
        {
            var imagesData = new List<PhotoData>();
            OpenPOP.POP3.POPClient client = new POPClient( "mail.shockbyte.com.ar", 110, "*****@*****.**", "Password11", AuthenticationMethod.USERPASS );
            Console.WriteLine ("Connected");
            var count = client.GetMessageCount( );
            Console.WriteLine ("Message Count: " + count);
            for ( int i = 1; i <= count; i++ )
            {
                Console.WriteLine ("Message");
                var message = client.GetMessage( i, false );

                foreach ( Attachment att in message.Attachments )
                {
                    Console.WriteLine ("Att: " + att.ContentFileName);
                    var extPos = att.ContentFileName.LastIndexOf( "." );
                    if ( extPos >= 0 )
                    {
                        var ext = att.ContentFileName.Substring( extPos + 1 ).ToLowerInvariant( );

                        var photo = new PhotoData( ) { Data = att.DecodedAsBytes( ), From = message.From, Title = message.Subject, FileName = att.ContentFileName };

                        switch ( ext )
                        {
                            case "jpg":
                            case "jpeg":
                                photo.ImageType = "image/jpeg";
                                imagesData.Add( photo );

                                break;

                            case "gif":
                                photo.ImageType = "image/gif";
                                imagesData.Add( photo );

                                break;

                            case "png":
                                photo.ImageType = "image/png";
                                imagesData.Add( photo );

                                break;
                        }
                    }
                }
            }

            if ( deleteMessages )
            {
                client.DeleteAllMessages( );
            }

            client.Disconnect( );

            return imagesData;
        }
Beispiel #2
0
    public void GetPhotoPath()
    {
        //lastStatus = statusText.GetComponent<Text>().text;
        //photoRawImage.texture = dogTexture;

        FirebaseDatabase.DefaultInstance.GetReferenceFromUrl(DATA_URL).Child(spreadsheetID).Child(photoUID.text).GetValueAsync()
        .ContinueWith((task => {
            if (task.IsCanceled)
            {
                Firebase.FirebaseException e =
                    task.Exception.Flatten().InnerExceptions[0] as Firebase.FirebaseException;
                GetErrorMessage((AuthError)e.ErrorCode);
                return;
            }

            if (task.IsFaulted)
            {
                Firebase.FirebaseException e =
                    task.Exception.Flatten().InnerExceptions[0] as Firebase.FirebaseException;
                GetErrorMessage((AuthError)e.ErrorCode);
                return;
            }

            if (task.IsCompleted)
            {
                DataSnapshot snapshot = task.Result;         //task.Result;
                string t = snapshot.GetRawJsonValue();
                PhotoData extractedData = JsonUtility.FromJson <PhotoData>(t);
                print("Filename is: " + extractedData.Filename);
                lastStatus = "Filename is: " + extractedData.Filename;
                newFilename = extractedData.Filename;
            }
        }));
    }
Beispiel #3
0
        public int DeleteItem(PhotoData item)
        {
            var task = Database.DeleteAsync(item);

            task.Wait();
            return(task.Result);
        }
Beispiel #4
0
 public IActionResult AddPhoto([FromBody] PhotoData request)
 {
     try
     {
         BaseResponse response = _peopleClient.AddPhotoAsync(request);
         LogData      logData  = new()
         {
             CallSide         = nameof(PeopleController),
             CallerMethodName = nameof(AddPhoto),
             CreatedOn        = _dateTimeUtil.GetCurrentDateTime(),
             Request          = request,
             Response         = response
         };
         _logger.AddLog(logData);
         return(Ok(response));
     }
     catch (Exception ex)
     {
         LogData logData = new()
         {
             CallSide         = nameof(PeopleController),
             CallerMethodName = nameof(AddPhoto),
             CreatedOn        = _dateTimeUtil.GetCurrentDateTime(),
             Request          = request,
             Response         = ex
         };
         _logger.AddErrorLog(logData);
         return(InternalServerError());
     }
 }
        private async void _camera_PictureCaptured(object sender, PictureCapturedEventArgs e)
        {
            var photo = new PhotoData()
            {
                DateTime = DateTime.Now,
                Uri      = e.File.Path,
            };

            await _camera.StopAsync();

            await PhotoPreviewView.ShowAndWaitAsync(photo);

            await _camera.Initialize();

            var t = Task.Run(async() =>
            {
                await DataProvider.Instance.SavePhotoAsync(photo);
            });

            CameraControlsCaptureButton.IsEnabled = true;
            if (App.IsXbox())
            {
                CameraControlsCaptureButton.Focus(FocusState.Keyboard);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            Log.WriteLine(LogPriority.Debug, TAG, "OnCreate - Enter");
            base.OnCreate(savedInstanceState);
            AppContextLiveData.Instance.SetLocale(this);

            if (AppContextLiveData.Instance.IsPortrait)
            {
                SetContentView(Resource.Layout.PhotoShowActivityPortrait);
            }
            else
            {
                SetContentView(Resource.Layout.PhotoShowActivityLandscape);
            }

            long id = Intent.GetLongExtra("ID", -1);

            _photodata = Database.GetPhotoDataItem(id);

            InitializeAppContext(_photodata);
            InitializeBaseActivityUI();

            FindViewById <ImageButton>(Resource.Id.menuButton).SetOnClickListener(this);

            _displayOverlappedButton = FindViewById <ImageButton>(Resource.Id.buttonDisplayOverlapped);
            _displayOverlappedButton.SetOnClickListener(this);

            _saveToDeviceButton = FindViewById <ImageButton>(Resource.Id.buttonSaveToDevice);
            _saveToDeviceButton.SetOnClickListener(this);

            _shareButton = FindViewById <ImageButton>(Resource.Id.buttonShare);
            _shareButton.SetOnClickListener(this);

            _tiltCorrectorButton = FindViewById <ImageButton>(Resource.Id.buttonTiltCorrector);
            _tiltCorrectorButton.SetOnClickListener(this);

            _cropButton = FindViewById <ImageButton>(Resource.Id.buttonCropImage);
            _cropButton.SetOnClickListener(this);

            _confirmCloseButtons            = FindViewById <LinearLayout>(Resource.Id.confirmCloseButtons);
            _confirmCloseButtons.Visibility = ViewStates.Gone;
            FindViewById <ImageButton>(Resource.Id.confirmButton).SetOnClickListener(this);
            FindViewById <ImageButton>(Resource.Id.closeButton).SetOnClickListener(this);

            _activityControlBar    = FindViewById <LinearLayout>(Resource.Id.PhotoShowActivityControlBar);
            _mainActivityStatusBar = FindViewById <LinearLayout>(Resource.Id.mainActivityStatusBar);
            photoView = FindViewById <ScaleImageView>(Resource.Id.photoView);

            HideControls();

            var pictureSize = new System.Drawing.Size(GetPictureWidth(), GetPictureHeight());

            _compassView.Initialize(Context, false, pictureSize);

            var delayedAction = new System.Threading.Timer(o => { LoadImageAndProfile(); },
                                                           null, TimeSpan.FromSeconds(0.1), TimeSpan.FromMilliseconds(-1));

            Start();
            Log.WriteLine(LogPriority.Debug, TAG, "OnCreate - Exit");
        }
Beispiel #7
0
        private static void LoadCustomPhotos()
        {
            string path = $"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}\\assets";

            if (!Directory.Exists(path))
            {
                Dbgl($"Directory {path} does not exist!");
                return;
            }
            customPhotos.Clear();

            Regex pattern = new Regex(@"(png|jpg|jpeg|bmp)$");


            foreach (string file in Directory.GetFiles(path))
            {
                string fileName = Path.GetFileName(file);
                if (!pattern.IsMatch(fileName))
                {
                    continue;
                }

                Texture2D tex       = new Texture2D(2, 2);
                byte[]    imageData = File.ReadAllBytes(file);
                tex.LoadImage(imageData);
                PhotoData pd = new PhotoData();
                pd.filePath = file;
                pd.fileName = fileName;
                pd.realTime = new DateTime();
                pd.actorsId = new int[0];
                pd.comments = "";
                pd.bytes    = imageData;
                customPhotos.Add(pd);
            }
        }
Beispiel #8
0
        public int InsertItem(PhotoData item)
        {
            var task = Database.InsertAsync(item);

            task.Wait();
            return(task.Result);
        }
Beispiel #9
0
    private List <PhotoData> GetUserPhotosFromDb()
    {
        var photosDataList = new List <PhotoData>();
        var userId         = (int)MyUtils.GetUserField("id_user");

        DataSet userData   = db.GetDataSet(string.Format("select * from users where id_user={0}", userId));
        DataSet photosData = db.GetDataSet(string.Format("select * from photos where id_user={0}", userId));

        var userPhotoId = userData.Tables[0].Rows[0]["id_photo"];

        if (photosData.Tables.Count > 0)
        {
            DataTable photosTable = photosData.Tables[0];

            for (int i = 0; i < photosTable.Rows.Count; i++)
            {
                var pd = new PhotoData
                {
                    GuidPhoto   = Guid.Parse(photosTable.Rows[i]["GUID"].ToString()),
                    idPhoto     = (int)photosTable.Rows[i]["id_photo"],
                    idUser      = (int)photosTable.Rows[i]["id_user"],
                    isApproved  = (bool)photosTable.Rows[i]["is_approved"],
                    isPrivate   = (bool)photosTable.Rows[i]["is_private"],
                    isMainPhoto = !(userPhotoId is DBNull) && (int)userPhotoId == (int)photosTable.Rows[i]["id_photo"]
                };

                photosDataList.Add(pd);
            }
        }

        return(photosDataList);
    }
Beispiel #10
0
        /// <summary>
        /// Guarda la imagen en disco duro y crea un enlace para
        /// guardarlo en la base de datos para despues mandarlo
        /// a todos los clientes por SignalR
        /// </summary>
        /// <param name="imageBase64">Imagen en base 64</param>
        /// <param name="basePath">Path base</param>
        /// <param name="qrCode">Guid que almacenaba el código QR</param>
        /// <returns></returns>
        public static bool UploadImage(string imageBase64, string basePath, string qrCode)
        {
            bool isSuccess = true;
            // nombre del archivo
            string fileName = String.Format("Storage/{0}.bmp", qrCode);
            // ruta completa en donde se guardardá el archivo
            string filePath = Path.Combine(basePath, fileName);
            // Url que se enviará a los clientes para que descarguen la imagen
            string urlToSend = Path.Combine(ConfigurationManager.AppSettings["PhotoPath"], fileName);

            try
            {
                PhotoData.SavePhotoFile(imageBase64, filePath);
                PhotoData.UpdatePhotoInfo(urlToSend, qrCode);
                // Se envía el URL a los clientes
                var hub = GlobalHost.ConnectionManager.GetHubContext <PhotoHub>();
                hub.Clients.All.onImageUploaded(urlToSend);
            }
            catch (Exception)
            {
                isSuccess = false;
                throw;
            }
            return(isSuccess);
        }
Beispiel #11
0
        public ActionResult Photo(string vendorId)
        {
            ViewBag.Message = "Your application description page.";
            PhotoData model = new PhotoData();

            model.vendorId = vendorId;
            return(View(model));
        }
        public async Task Hide()
        {
            ((App)(App.Current)).BackRequested -= PhotoPreviewView_BackRequested;
            SizeChanged           -= PhotoPreviewView_SizeChanged;
            ImageRoot.SizeChanged -= ImageRoot_SizeChanged;

            IsVisible = false;

            var splitChar = _photo.IsLocal ? '\\' : '/';
            var filename  = (_photo.Uri.Split(splitChar).LastOrDefault()?.Split('.').FirstOrDefault() ?? "");

            var saveInkTask          = Inker.SaveInkToFile($"ink_{filename}.gif");
            var saveThumbnailTask    = InkHelpers.RenderImageWithInkToFileAsync(Inker, await _file.OpenReadAsync(), $"thumb_{filename}.jpg");
            var closingAnimationTask = Root.Scale(1.2f, 1.2f, (float)ActualWidth / 2, (float)ActualHeight / 2).Fade(0).StartAsync();

            await Task.WhenAll(saveInkTask, closingAnimationTask, saveThumbnailTask);

            _photo.InkUri       = saveInkTask.Result ?? _photo.InkUri;
            _photo.ThumbnailUri = saveThumbnailTask.Result ?? _photo.ThumbnailUri;


            Root.Visibility = Visibility.Collapsed;

            _canvasImage.Dispose();
            _canvasImage = null;

            _photo = null;
            _file  = null;

            ImageCanvas.Invalidate();

            FinishedHiding?.Invoke(this, null);

            _tags.Clear();
            _knownFaces.Clear();
            _facePanels.Clear();
            FaceCanvas.Children.Clear();

            if (Description != null)
            {
                Description.Text = "";
            }

            _effectsGenerator = null;

            FiltersButton.IsChecked = false;
            DetailsButton.IsChecked = false;
            InkButton.IsChecked     = false;
            Inker.InkPresenter.StrokeContainer.Clear();

            _photoInfoInitialized = false;

            if (EffectsView != null)
            {
                EffectsView.Visibility = Visibility.Collapsed;
                _effects.Clear();
            }
        }
Beispiel #13
0
 private static void dealList(List <Hashtable> list)
 {
     for (int i = list.Count - 1; i >= 0; i--)
     {
         PhotoData data = list[i]["PhotoData"] as PhotoData;
         string    name = data.Name;
         TreeNode  node = FindNode(_PhotoRoot, name);
         while (node.Parent != null)
         {
             bool   find       = false;
             string parentname = node.Parent.Text;
             foreach (Hashtable table1 in list)
             {
                 PhotoData data1 = table1["PhotoData"] as PhotoData;
                 if (data1.Name == parentname)
                 {
                     if (data1.MinX < data.MinX && data1.MaxX > data.MaxX && data1.MinY < data.MinY && data1.MaxY > data.MaxY)
                     {
                         find = true;
                         break;
                     }
                 }
             }
             if (find)
             {
                 list.RemoveAt(i);
                 break;
             }
             node = node.Parent;
         }
     }
     for (int i = list.Count - 1; i >= 0; i--)
     {
         PhotoData data = list[i]["PhotoData"] as PhotoData;
         string    name = data.Name;
         TreeNode  node = FindNode(_PhotoRoot, name);
         while (node.Parent != null)
         {
             bool   find       = false;
             string parentname = node.Parent.Text;
             foreach (Hashtable table1 in list)
             {
                 PhotoData data1 = table1["PhotoData"] as PhotoData;
                 if (data1.Name == parentname)
                 {
                     find = true;
                     break;
                 }
             }
             if (find)
             {
                 list.RemoveAt(i);
                 break;
             }
             node = node.Parent;
         }
     }
 }
        public void OnFavouriteEditRequest(int position)
        {
            PhotoData item = _adapter[position];

            item.Favourite = !item.Favourite;
            Context.Database.UpdateItem(item);

            _adapter.NotifyDataSetChanged();
        }
Beispiel #15
0
 public bool DeleteImage(PhotoData imageData)
 {
     if (File.Exists(imageData.OriginalPhotoPath))
     {
         Directory.Delete(imageData.DirectoryPath, true);
         return(true);
     }
     return(false);
 }
    public void Initialize(PhotoData photoData, int index)
    {
        indexGalleryItem = index;
        string imageURL     = FlickrAPI.GetImageUrl(photoData);
        string imageSizeURL = FlickrAPI.GetSizePhoto(photoData.id);

        wwwImageLoader.LoadImage(imageURL);
        sizeManager.SetImageSize(imageSizeURL);
    }
Beispiel #17
0
 public ActionResult Upload(PhotoData model)
 {
     ViewBag.Message = "Your application description page.";
     if (model != null)
     {
         MultipartFileData f        = model.image;
         string            vendorId = model.vendorId;
     }
     return(View());
 }
Beispiel #18
0
 internal void UpdateItem(PhotoData item)
 {
     _database.UpdateItem(item);
     MainThread.BeginInvokeOnMainThread(() =>
                                        PhotoUpdated?.Invoke(this, new PhotoDataEventArgs()
     {
         data = item
     })
                                        );
 }
Beispiel #19
0
 public void InsertItem(PhotoData item)
 {
     _database.InsertItem(item);
     MainThread.BeginInvokeOnMainThread(() =>
                                        PhotoAdded?.Invoke(this, new PhotoDataEventArgs()
     {
         data = item
     })
                                        );
 }
Beispiel #20
0
    public void LoadData()
    {
        DateTime startTime = DateTime.Now;

        lastStatus = "Starting large database read...";
        print("Starting database read...");

        FirebaseDatabase.DefaultInstance.GetReferenceFromUrl(DATA_URL).Child(spreadsheetID).GetValueAsync()
        .ContinueWith((task => {
            if (task.IsCanceled)
            {
                Firebase.FirebaseException e =
                    task.Exception.Flatten().InnerExceptions[0] as Firebase.FirebaseException;

                GetErrorMessage((AuthError)e.ErrorCode);

                return;
            }

            if (task.IsFaulted)
            {
                Firebase.FirebaseException e =
                    task.Exception.Flatten().InnerExceptions[0] as Firebase.FirebaseException;

                GetErrorMessage((AuthError)e.ErrorCode);

                return;
            }

            if (task.IsCompleted)
            {
                DataSnapshot snapshot = task.Result;             //task.Result;

                string photoData = snapshot.GetRawJsonValue();
                //print("photoData = " + photoData);

                int rowCount = 0;

                foreach (var child in snapshot.Children)
                {
                    string t = child.GetRawJsonValue();
                    rowCount++;
                    PhotoData extractedData = JsonUtility.FromJson <PhotoData>(t);

                    //print("row " + rowCount + " t: " + t);
                    //print("photoUID: " + extractedData.Photo_uid + ", size: " + extractedData.Size + ", location: " + extractedData.Location);

                    //print("extractedData = " + extractedData);
                }
                lastStatus = "Read " + rowCount + " rows from database.";
                print("Read " + rowCount + " rows from database.");
                TimeElapsed(startTime);
            }
        }));
    }
Beispiel #21
0
        // PUT api/photos/5
        public void Put(Guid id, PhotoData newValues)
        {
            var existingValues = _db.Photos.FindById(id);

            if (existingValues == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            CopyWriteableValues(newValues, existingValues);
            _db.SaveChanges();
        }
Beispiel #22
0
 public void DeleteItem(PhotoData item)
 {
     System.IO.File.Delete(item.PhotoFileName);
     _database.DeleteItem(item);
     MainThread.BeginInvokeOnMainThread(() =>
                                        PhotoDeleted?.Invoke(this, new PhotoDataEventArgs()
     {
         data = item
     })
                                        );
 }
 public void OnPhotoDeleteRequest(int position)
 {
     AlertDialog.Builder alert = new AlertDialog.Builder(this).SetCancelable(false);
     alert.SetPositiveButton(Resources.GetText(Resource.String.Common_Yes), (senderAlert, args) =>
     {
         PhotoData item = _adapter[position];
         Context.PhotosModel.DeleteItem(item);
     });
     alert.SetNegativeButton(Resources.GetText(Resource.String.Common_No), (senderAlert, args) => { });
     alert.SetMessage(Resources.GetText(Resource.String.Photos_DeletePhotoQuestion));
     var answer = alert.Show();
 }
Beispiel #24
0
 /// <summary>
 /// 取得描画影像图所需文件以及金字塔级别和比例
 /// </summary>
 /// <param name="list"></param>
 /// <param name="node"></param>
 private static void FindDrawTif(List <Hashtable> list, TreeNode node, bool show_shiqu = false)
 {
     if (node == _PhotoRoot)
     {
         foreach (TreeNode subnode in node.Nodes)
         {
             FindDrawTif(list, subnode, show_shiqu);
         }
     }
     else
     {
         PhotoData data = node.Tag as PhotoData;
         if (data == null)
         {
             return;
         }
         if (data.FileName != "" && data.FileName != null)
         {
             int  overviewlevel = 0;
             int  overviewzoom  = 0;
             bool flg           = show_shiqu || SetOverView(data, out overviewlevel, out overviewzoom);
             if (flg || (!flg && node.Nodes.Count <= 0 && overviewlevel == -1))
             {
                 if ((!show_shiqu && data.FileName.IndexOf(SHIQU_FILENAME) < 0) || (show_shiqu && data.FileName.IndexOf(SHIQU_FILENAME) >= 0))
                 {
                     Hashtable table = new Hashtable();
                     table.Add("PhotoData", data);
                     table.Add("overviewlevel", overviewlevel);
                     table.Add("overviewzoom", overviewzoom);
                     list.Add(table);
                 }
                 foreach (TreeNode subnode in node.Nodes)
                 {
                     FindDrawTif(list, subnode, show_shiqu);
                 }
             }
             else
             {
                 foreach (TreeNode subnode in node.Nodes)
                 {
                     FindDrawTif(list, subnode, show_shiqu);
                 }
             }
         }
         else
         {
             foreach (TreeNode subnode in node.Nodes)
             {
                 FindDrawTif(list, subnode, show_shiqu);
             }
         }
     }
 }
Beispiel #25
0
        private void CopyWriteableValues(PhotoData newValues, Photo existingValues)
        {
            existingValues.Card = newValues.Card;
            var photographer = _db.Photographers.Find(ph => ph.Initials == newValues.PhotographerInitials).FirstOrDefault();

            if (photographer != null)
            {
                existingValues.Photographer = photographer;
            }
            existingValues.Event    = _db.Events.Find(e => e.EventName == newValues.Event).SingleOrDefault();
            existingValues.Sequence = newValues.Sequence;
            existingValues.Station  = newValues.Station;
        }
        public void PhotoDataModelMapTest()
        {
            var entity = new PhotoData
            {
                MimeType = Guid.NewGuid().ToString(),
                Data     = Guid.NewGuid().ToByteArray()
            };

            var model = Mapper.Map <PhotoDataModel>(entity);

            Assert.Equal(entity.MimeType, model.MimeType);
            Assert.Equal(entity.Data, model.Data);
        }
        public void OnTagEditRequest(int position)
        {
            PhotoData item   = _adapter[position];
            var       dialog = new EditTagDialog(this, item);

            dialog.Show(r =>
            {
                if (r == Result.Ok)
                {
                    _adapter.NotifyDataSetChanged();
                }
            });
        }
Beispiel #28
0
        private static void SetTreeNodeBoundingBox(TreeNode node)
        {
            if (node == null)
            {
                return;
            }
            foreach (TreeNode subnode in node.Nodes)
            {
                SetTreeNodeBoundingBox(subnode);
            }
            if (node.Text == "普兰店")
            {
                string a = "";
            }
            if (node.Tag != null)
            {
                return;
            }
            PhotoData mydata = new PhotoData();

            if (node.Nodes.Count > 0)
            {
                PhotoData data = node.Nodes[0].Tag as PhotoData;
                mydata.MinX = data.MinX;
                mydata.MinY = data.MinY;
                mydata.MaxX = data.MaxX;
                mydata.MaxY = data.MaxY;
            }
            foreach (TreeNode subnode in node.Nodes)
            {
                PhotoData data = subnode.Tag as PhotoData;
                if (mydata.MinX > data.MinX && data.MinX != 0)
                {
                    mydata.MinX = data.MinX;
                }
                if (mydata.MaxX < data.MaxX && data.MaxX != 0)
                {
                    mydata.MaxX = data.MaxX;
                }
                if (mydata.MinY > data.MinY && data.MinY != 0)
                {
                    mydata.MinY = data.MinY;
                }
                if (mydata.MaxY < data.MaxY && data.MaxY != 0)
                {
                    mydata.MaxY = data.MaxY;
                }
            }
            mydata.Name = node.Text;
            node.Tag    = mydata;
        }
Beispiel #29
0
        public static MatchPhoto AddNew(string FileName, string Title, int MatchID, User Owner)
        {
            PhotoData data = new PhotoData();

            data.UploadDate = DateTime.Now;
            data.AuthorID   = Owner.ID;
            data.Title      = Title;
            data.FileName   = FileName;
            data.MatchID    = MatchID;
            MatchPhoto photo = new MatchPhoto(data);

            data.ID = photo.Save();
            return(photo);
        }
        private async void UploadButtonClick(object sender, RoutedEventArgs e)
        {
            (sender as Button).IsEnabled = false;

            var picker = new Windows.Storage.Pickers.FileOpenPicker();

            picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;

            picker.FileTypeFilter.Add(".jpg");
            picker.FileTypeFilter.Add(".jpeg");
            picker.FileTypeFilter.Add(".png");

            var files = await picker.PickMultipleFilesAsync();

            var photos = new List <PhotoData>();

            if (files != null && files.Count > 0)
            {
                var folder = await AdventureObjectStorageHelper.GetDataSaveFolder();

                foreach (var file in files)
                {
                    var newFile = file;

                    if ((await file.GetParentAsync()).Path != folder.Path)
                    {
                        newFile = await file.CopyAsync(folder);
                    }

                    var photo = new PhotoData()
                    {
                        DateTime = DateTime.Now,
                        Uri      = newFile.Path,
                    };

                    //photo.ThumbnailUri = await VisionAPI.Instance.GetThumbnail(await newFile.OpenReadAsync(), newFile.DisplayName + "_thumb.jpg");

                    photos.Add(photo);
                }

                //await Data.Instance.SavePhotosAsync(photos);

                //Frame.Navigate(typeof(AdventurePage), null);
            }
            else
            {
                (sender as Button).IsEnabled = true;
            }
        }
        void InitializeAppContext(PhotoData photodata)
        {
            var loc = new GpsLocation(photodata.Longitude, photodata.Latitude, photodata.Altitude);

            /* Fetching altitude from elevation map if available (this is not needed probably)
             * if (AppContextLiveData.Instance.Settings.AltitudeFromElevationMap)
             * {
             *  var elevationTile = new ElevationTile(loc);
             *  if (elevationTile.Exists())
             *  {
             *      if (elevationTile.LoadFromZip())
             *      {
             *          loc.Altitude = elevationTile.GetElevation(loc);
             *      }
             *  }
             * }*/

            _context = new AppContextStaticData(loc, new PlaceInfo(), photodata.Heading);
            _context.LeftTiltCorrector  = photodata.LeftTiltCorrector ?? 0;
            _context.RightTiltCorrector = photodata.RightTiltCorrector ?? 0;
            //### This can be removed later
            if (photodata.PictureWidth == 0)
            {
                photodata.PictureWidth = AppContextLiveData.Instance.Settings.CameraPictureSize.Width;
            }
            if (photodata.PictureHeight == 0)
            {
                photodata.PictureHeight = AppContextLiveData.Instance.Settings.CameraPictureSize.Height;
            }


            //Elavation data will be loaded when user will enable showing of elevation data
            if (photodata.JsonElevationProfileData == null)
            {
                photodata.ShowElevationProfile = false;
            }

            Context.Settings.LoadData(this);
            Context.Settings.IsViewAngleCorrection = false;
            Context.Settings.Categories            = JsonConvert.DeserializeObject <List <PoiCategory> >(photodata.JsonCategories);
            Context.Settings.SetCameraParameters((float)photodata.ViewAngleHorizontal, (float)photodata.ViewAngleVertical,
                                                 photodata.PictureWidth, photodata.PictureHeight);
            Context.Settings.MaxDistance          = Convert.ToInt32(photodata.MaxDistance);
            Context.Settings.MinAltitute          = Convert.ToInt32(photodata.MinAltitude);
            Context.ShowFavoritesOnly             = photodata.FavouriteFilter;
            Context.Settings.ShowElevationProfile = photodata.ShowElevationProfile;
            Context.ElevationProfileData          = ElevationProfileData.Deserialize(photodata.JsonElevationProfileData);
        }
    private List<PhotoData> GetUserPhotosFromDb()
    {
        var photosDataList = new List<PhotoData>();
        var userId = (int)MyUtils.GetUserField("id_user");

        DataSet userData = db.GetDataSet(string.Format("select * from users where id_user={0}", userId));
        DataSet photosData = db.GetDataSet(string.Format("select * from photos where id_user={0}", userId));

        var userPhotoId = userData.Tables[0].Rows[0]["id_photo"];

        if (photosData.Tables.Count > 0)
        {
            DataTable photosTable = photosData.Tables[0];

            for (int i = 0; i < photosTable.Rows.Count; i++)
            {
                var pd = new PhotoData
                {
                    GuidPhoto = Guid.Parse(photosTable.Rows[i]["GUID"].ToString()),
                    idPhoto = (int)photosTable.Rows[i]["id_photo"],
                    idUser = (int)photosTable.Rows[i]["id_user"],
                    isApproved = (bool)photosTable.Rows[i]["is_approved"],
                    isPrivate = (bool)photosTable.Rows[i]["is_private"],
                    isMainPhoto = !(userPhotoId is DBNull) && (int)userPhotoId == (int)photosTable.Rows[i]["id_photo"]
                };

                photosDataList.Add(pd);

            }
        }

        return photosDataList;
    }