Пример #1
0
 public void GetPhoto(GetPhotoCallback callback)
 {
     this.getPhotoCallback = callback;
     MessagePrompt questionMessage = new MessagePrompt();
     questionMessage.Title = "Choose source:";
     SelectPhotoDialog dialogContent = new SelectPhotoDialog();
     dialogContent.TakePhotoCommand = new DelegateCommand((o) =>
         {
             questionMessage.Hide();
             this.photoCameraCapture.Show();
         });
     dialogContent.ChosePhotoCommand = new DelegateCommand((o) =>
         {
             questionMessage.Hide();
             this.photoChooserTask.Show();
         });
     dialogContent.RandomPhotoCommand = new DelegateCommand((o) =>
         {
             questionMessage.Hide();
             callback(null);
         });
     questionMessage.Body = dialogContent;
     RoundButton cancelButton = new RoundButton();
     cancelButton.ImageSource = new BitmapImage(new Uri("/Resources/icons/appbar.stop.rest.png", UriKind.Relative));
     cancelButton.Click += (sender, args) =>
         {
             questionMessage.Hide();
         };
     questionMessage.ActionPopUpButtons.Clear();
     questionMessage.ActionPopUpButtons.Add(cancelButton);
     questionMessage.Show();
 }
Пример #2
0
        public void GetPhoto(GetPhotoCallback callback)
        {
            this.getPhotoCallback = callback;
            MessagePrompt questionMessage = new MessagePrompt();

            questionMessage.Title = "Choose source:";
            SelectPhotoDialog dialogContent = new SelectPhotoDialog();

            dialogContent.TakePhotoCommand = new DelegateCommand((o) =>
            {
                questionMessage.Hide();
                this.photoCameraCapture.Show();
            });
            dialogContent.ChosePhotoCommand = new DelegateCommand((o) =>
            {
                questionMessage.Hide();
                this.photoChooserTask.Show();
            });
            dialogContent.RandomPhotoCommand = new DelegateCommand((o) =>
            {
                questionMessage.Hide();
                callback(null);
            });
            questionMessage.Body = dialogContent;
            RoundButton cancelButton = new RoundButton();

            cancelButton.ImageSource = new BitmapImage(new Uri("/Resources/icons/appbar.stop.rest.png", UriKind.Relative));
            cancelButton.Click      += (sender, args) =>
            {
                questionMessage.Hide();
            };
            questionMessage.ActionPopUpButtons.Clear();
            questionMessage.ActionPopUpButtons.Add(cancelButton);
            questionMessage.Show();
        }
Пример #3
0
        private void GetPhotoTaskCompleted(object sender, PhotoResult e)
        {
            if (getPhotoCallback != null)
            {
                if (e.TaskResult == TaskResult.OK)
                {
                    JpegInfo info = ExifReader.ReadJpeg(e.ChosenPhoto, e.OriginalFileName);
                    e.ChosenPhoto.Seek(0, SeekOrigin.Begin);
                    ExifOrientation _orientation = info.Orientation;
                    int             _angle       = 0;
                    switch (info.Orientation)
                    {
                    case ExifOrientation.TopLeft:
                    case ExifOrientation.Undefined:
                        _angle = 0;
                        break;

                    case ExifOrientation.TopRight:
                        _angle = 90;
                        break;

                    case ExifOrientation.BottomRight:
                        _angle = 180;
                        break;

                    case ExifOrientation.BottomLeft:
                        _angle = 270;
                        break;
                    }

                    Stream capturedImage;
                    if (_angle > 0d)
                    {
                        capturedImage = RotateStream(e.ChosenPhoto, _angle);
                    }
                    else
                    {
                        capturedImage = e.ChosenPhoto;
                    }
                    IMobeelizerFile file = Mobeelizer.CreateFile("photo", capturedImage);
                    this.getPhotoCallback(file);
                    this.getPhotoCallback = null;
                }
                else
                {
                    this.GetPhoto(getPhotoCallback);
                }
            }
        }
Пример #4
0
        private void GetPhotoTaskCompleted(object sender, PhotoResult e)
        {
            if (getPhotoCallback != null)
            {
                if (e.TaskResult == TaskResult.OK)
                {
                    JpegInfo info = ExifReader.ReadJpeg(e.ChosenPhoto, e.OriginalFileName);
                    e.ChosenPhoto.Seek(0, SeekOrigin.Begin);
                    ExifOrientation _orientation = info.Orientation;
                    int _angle = 0;
                    switch (info.Orientation)
                    {
                        case ExifOrientation.TopLeft:
                        case ExifOrientation.Undefined:
                            _angle = 0;
                            break;
                        case ExifOrientation.TopRight:
                            _angle = 90;
                            break;
                        case ExifOrientation.BottomRight:
                            _angle = 180;
                            break;
                        case ExifOrientation.BottomLeft:
                            _angle = 270;
                            break;
                    }

                    Stream capturedImage;
                    if (_angle > 0d)
                    {
                        capturedImage = RotateStream(e.ChosenPhoto, _angle);
                    }
                    else
                    {
                        capturedImage = e.ChosenPhoto;
                    }
                    IMobeelizerFile file = Mobeelizer.CreateFile("photo", capturedImage);
                    this.getPhotoCallback(file);
                    this.getPhotoCallback = null;
                }
                else
                {
                    this.GetPhoto(getPhotoCallback);
                }
            }
        }