protected override void AddAttachment(IMessageAttachment messageAttachment)
        {
            UIElement       attachmentElement;
            AttachmentModel attachmentModel = new AttachmentModel(_fileSystem, messageAttachment);

            switch (messageAttachment.Type)
            {
            case AttachmentType.Image:
                attachmentElement = new AttachmentImage(attachmentModel);
                break;

            case AttachmentType.Video:
                attachmentElement = new AttachmentVideo(attachmentModel);
                break;

            case AttachmentType.Audio:
                attachmentElement = new AttachmentAudio(attachmentModel);
                break;

            default:
                throw new ArgumentException("Unrecognized attachment type: " + messageAttachment.Type.ToString());
            }

            _currentParagraph.Inlines.Add(attachmentElement);
        }
Example #2
0
        public async Task <string> ThumbnailToBase64Async(AttachmentImage image)
        {
#if __ANDROID__
            var imageBytes = new byte[image.Stream.Length];
            image.Stream.Position = 0;
            image.Stream.Read(imageBytes, 0, (int)image.Stream.Length);
            var thumbnailBytes = GetThumbnailBytes(imageBytes, 200, 200);
#endif
#if WINDOWS_UWP
            StorageFolder folder = ApplicationData.Current.TemporaryFolder;
            var           file   = await folder.CreateFileAsync(Guid.NewGuid().ToString());

            var stream = await file.OpenStreamForWriteAsync();

            await image.Stream.CopyToAsync(stream);

            var thumb = await file.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.PicturesView);

            var thumbnailBytes = new byte[thumb.Size];
            thumb.AsStream().Read(thumbnailBytes, 0, (int)thumb.Size);
#endif
#if __IOS__
            var imageBytes = new byte[image.Stream.Length];
            image.Stream.Position = 0;
            image.Stream.Read(imageBytes, 0, (int)image.Stream.Length);
            var thumbnailBytes = GetThumbnailBytes(imageBytes, 200, 200);
#endif

            return(Convert.ToBase64String(thumbnailBytes));
        }
Example #3
0
        public AttachmentImage ThumbnailFromBase64(string serialisedThumbnail)
        {
            var             bytes = Convert.FromBase64String(serialisedThumbnail);
            AttachmentImage image = new AttachmentImage(new MemoryStream(bytes));

            return(image);
        }
Example #4
0
        public async Task <bool> SetProfilAsync(Profil profil, AttachmentImage image = null)
        {
            await InitWriteConnectionAsync();

            profil.AnbieterID = _loginService.AnbieterId;
            if (image != null)
            {
                profil.ProfilbildBase64 = await _thumbnailHelper.ThumbnailToBase64Async(image);
            }

            profil.AktualisiertAm = DateTime.Now;

            var profilJSON      = Newtonsoft.Json.JsonConvert.SerializeObject(profil);
            var profilJSONbytes = Encoding.UTF8.GetBytes(profilJSON);

            string key = "Profile/" + profil.AnbieterID + "/Profil.json";

            var customMeta = new CustomMetadata();

            customMeta.Entries.Add(new CustomMetadataEntry()
            {
                Key = PROFIL_VERSION_VOM, Value = DateTime.Now.ToString()
            });

            var profilUpload = await _writeConnection.ObjectService.UploadObjectAsync(_writeConnection.Bucket, key, new UploadOptions(), profilJSONbytes, customMeta, false);

            await profilUpload.StartUploadAsync();

            Barrel.Current.Empty("profil_" + profil.AnbieterID);

            return(profilUpload.Completed);
        }
Example #5
0
 public AttachmentImageViewModel(AttachmentImage attachmentImage)
 {
     AttachmentImage = attachmentImage;
     RahmenBrush     = new SolidColorBrush(Colors.RoyalBlue);
     KannNachVorne   = Visibility.Collapsed;
     KannNachHinten  = Visibility.Collapsed;
     IstSelektiert   = Visibility.Collapsed;
 }
        void ReleaseDesignerOutlets()
        {
            if (AttachmentContainer != null)
            {
                AttachmentContainer.Dispose();
                AttachmentContainer = null;
            }

            if (AttachmentImage != null)
            {
                AttachmentImage.Dispose();
                AttachmentImage = null;
            }

            if (BottomConstraint != null)
            {
                BottomConstraint.Dispose();
                BottomConstraint = null;
            }

            if (DeleteButton != null)
            {
                DeleteButton.Dispose();
                DeleteButton = null;
            }

            if (EditContainer != null)
            {
                EditContainer.Dispose();
                EditContainer = null;
            }

            if (EditingBodyLabel != null)
            {
                EditingBodyLabel.Dispose();
                EditingBodyLabel = null;
            }

            if (EditingCloseButton != null)
            {
                EditingCloseButton.Dispose();
                EditingCloseButton = null;
            }

            if (EditingTitleLabel != null)
            {
                EditingTitleLabel.Dispose();
                EditingTitleLabel = null;
            }

            if (ImageLoader != null)
            {
                ImageLoader.Dispose();
                ImageLoader = null;
            }

            if (OpenCameraButton != null)
            {
                OpenCameraButton.Dispose();
                OpenCameraButton = null;
            }

            if (OpenGalleryButton != null)
            {
                OpenGalleryButton.Dispose();
                OpenGalleryButton = null;
            }

            if (PlaceholderLabel != null)
            {
                PlaceholderLabel.Dispose();
                PlaceholderLabel = null;
            }

            if (SendButton != null)
            {
                SendButton.Dispose();
                SendButton = null;
            }

            if (TextMaxHeightConstraint != null)
            {
                TextMaxHeightConstraint.Dispose();
                TextMaxHeightConstraint = null;
            }

            if (TextView != null)
            {
                TextView.Dispose();
                TextView = null;
            }
        }