Пример #1
0
        public async void takePictures()
        {
            //Take picture camera loop
            bool isCamera = true;

            while (isCamera)
            {
                var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions {
                    Name = "photo.jpg", Directory = "Pictures", SaveToAlbum = false
                });

                if (file != null)
                {
                    ImageMediaContent newMedia = new ImageMediaContent(file.Path);
                    card?.addMedia(newMedia);
                    MediaManager.addNewMedia(newMedia);
                }
                else
                {
                    isCamera = false;
                }
            }

            await Navigation.PopAsync();
        }
Пример #2
0
        /// <summary>
        /// Add media to card and link card to media
        /// </summary>
        /// <param name="card"></param>
        private async void addMediaToCard(Card card)
        {
            LinkManager linkManager;

            if (mediasToAddCard != null)
            {
                linkManager = mediasToAddCard.linkManager;
            }
            else
            {
                linkManager = MediaManager.mediaLinkManager;
            }

            CardMediaContent cardMediaContent = new CardMediaContent(card.name);

            foreach (AbMediaContent media in mediasToAdd)
            {
                card.addMedia(media);
                linkManager.addLink(media, cardMediaContent);
            }

            if (mediasToAddCard != null)
            {
                mediasToAddCard.saveToFile();
            }
            else
            {
                MediaManager.saveMediaLinkManager();
            }


            EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset);
            CardPage        cardPage   = new CardPage(card);

            cardPage.Disappearing += (e, v) =>
            {
                waitHandle.Set();
            };

            await Navigation.PushAsync(cardPage);

            await Task.Run(() => waitHandle.WaitOne());

            // TODO fix issue, crashes only in IOS not android ...
            //await Navigation.PopAsync();
            mediasToAdd = null;
        }