Beispiel #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);
        }
Beispiel #2
0
 internal void SwitchToImageEditor(FeedbackImageVM imageVM)
 {
     CurrentImageVM = imageVM;
     if (imageVM.IsEditable)
     {
         switchViewStateAction(FeedbackViewState.ImageEdit);
     }
     else
     {
         switchViewStateAction(FeedbackViewState.ImageShow);
     }
 }
 internal void SwitchToImageEditor(FeedbackImageVM imageVM)
 {
     CurrentImageVM = imageVM;
     if (imageVM.IsEditable)
     {
         switchViewStateAction(FeedbackViewState.ImageEdit);
     }
     else
     {
         switchViewStateAction(FeedbackViewState.ImageShow);
     }
 }
Beispiel #4
0
 public void RemoveAttachment(FeedbackImageVM attachment)
 {
     this.Attachments.Remove(attachment);
 }
Beispiel #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);
 }