Ejemplo n.º 1
0
        internal async Task ShowPhotoResult(PhotoResult result)
        {
            var imageVM = new FeedbackImageVM(this.ParentVM);

            imageVM.IsEditable = true;
            byte[] imageBytes = null;
            if (Path.GetExtension(result.OriginalFileName).ToLower().EndsWith("jpg"))
            {
                BitmapImage img = new BitmapImage();
                img.SetSource(result.ChosenPhoto);
                var wbBitmap = new WriteableBitmap(img);
                using (var stream = new MemoryStream())
                {
                    wbBitmap.WritePNG(stream);
                    stream.Seek(0, System.IO.SeekOrigin.Begin);
                    imageBytes = new byte[stream.Length];
                    stream.Read(imageBytes, 0, (int)stream.Length);
                }
            }
            else //png
            {
                imageBytes = new byte[result.ChosenPhoto.Length];
                await result.ChosenPhoto.ReadAsync(imageBytes, 0, (int)result.ChosenPhoto.Length);
            }
            imageVM.FeedbackImage = new FeedbackAttachment(Path.GetFileName(result.OriginalFileName), imageBytes, null);
            Attachments.Add(imageVM);
            this.ParentVM.SwitchToImageEditor(imageVM);
        }
Ejemplo n.º 2
0
 internal void SwitchToImageEditor(FeedbackImageVM imageVM)
 {
     CurrentImageVM = imageVM;
     if (imageVM.IsEditable)
     {
         switchViewStateAction(FeedbackViewState.ImageEdit);
     }
     else
     {
         switchViewStateAction(FeedbackViewState.ImageShow);
     }
 }
Ejemplo n.º 3
0
 internal void SwitchToImageEditor(FeedbackImageVM imageVM)
 {
     CurrentImageVM = imageVM;
     if (imageVM.IsEditable)
     {
         switchViewStateAction(FeedbackViewState.ImageEdit);
     }
     else
     {
         switchViewStateAction(FeedbackViewState.ImageShow);
     }
 }
Ejemplo n.º 4
0
 public void RemoveAttachment(FeedbackImageVM attachment)
 {
     this.Attachments.Remove(attachment);
 }
Ejemplo n.º 5
0
 public void AddAttachment(FeedbackImageVM attachment)
 {
     this.Attachments.Add(attachment);
 }
 internal async Task ShowPhotoResult(PhotoResult result)
 {
     var imageVM = new FeedbackImageVM(this.ParentVM);
     imageVM.IsEditable = true;
     byte[] imageBytes = null;
     if (Path.GetExtension(result.OriginalFileName).ToLower().EndsWith("jpg"))
     {
         BitmapImage img = new BitmapImage();
         img.SetSource(result.ChosenPhoto);
         var wbBitmap = new WriteableBitmap(img);
         using (var stream = new MemoryStream())
         {
             wbBitmap.WritePNG(stream);
             stream.Seek(0, System.IO.SeekOrigin.Begin);
             imageBytes = new byte[stream.Length];
             stream.Read(imageBytes, 0, (int)stream.Length);
         }
     }
     else //png
     {
         imageBytes = new byte[result.ChosenPhoto.Length];
         await result.ChosenPhoto.ReadAsync(imageBytes, 0, (int)result.ChosenPhoto.Length);
     }
     imageVM.FeedbackImage = new FeedbackAttachment(Path.GetFileName(result.OriginalFileName), imageBytes, null);
     Attachments.Add(imageVM);
     this.ParentVM.SwitchToImageEditor(imageVM);
 }
 public void RemoveAttachment(FeedbackImageVM attachment)
 {
     this.Attachments.Remove(attachment);
 }
 public void AddAttachment(FeedbackImageVM attachment)
 {
     this.Attachments.Add(attachment);
 }