/// <param name="cardMediaList"> Card media to display, we aren't always including all the card media, hence this list </param>
        public CardMediaCarouselPage(AbMediaContent startingMedia, List <AbMediaContent> cardMediaList, Card card = null)
        {
            InitializeComponent();

            this.card = card;
            this.cardMediaViewModels = new ObservableCollection <CardMediaViewModel>();

            foreach (AbMediaContent media in cardMediaList)
            {
                cardMediaViewModels.Add(new CardMediaViewModel()
                {
                    media = media, card = card, parentPage = this
                });
            }
            this.carouselView.ItemsSource = cardMediaViewModels;

            this.carouselView.Position          = cardMediaList.IndexOf(startingMedia);
            this.carouselView.PositionSelected += carouselView_PositionSelected;

            mediaLinkCaptureView.initialize(this, card);

            MessagingCenter.Subscribe <Object>(this, "FullScreenRequest", (sender) =>
            {
                toggleOverlays();
            });
        }
        private void carouselView_PositionSelected(object sender, PositionSelectedEventArgs e)
        {
            AbMediaContent curMedia = cardMediaViewModels[carouselView.Position].media;

            isFavoritedImage.Source = (curMedia.isFavorited ? "FavoriteIcon.png" : "NonFavoriteIcon");

            mediaLinkCaptureView.setLinkToMedia(curMedia);
        }
Пример #3
0
 private async void flowListView_FlowItemTapped(object sender, ItemTappedEventArgs e)
 {
     if (!isSelecting)
     {
         AbMediaContent curMedia = e.Item as AbMediaContent;
         await Navigation.PushAsync(new CardMediaCarouselPage(curMedia, card.mediaList.ToList <AbMediaContent>(), card));
     }
 }
Пример #4
0
 public AllCardsPage(AbMediaContent mediaToAdd, Card card = null) : this()
 {
     this.mediasToAddCard = card;
     this.mediasToAdd     = new List <AbMediaContent>()
     {
         mediaToAdd
     };
 }
Пример #5
0
        public void initialize(AbMediaContent media, Dir card)
        {
            this.addLinkView.initialize(media, card, this);

            this.deleteMediaView.intialize(media, card);

            this.linkedMediaView.initialize("Linked Media", card.linkManager.getLinkedMedia(media), card, this);

            this.mediaDisplayView.initialize(true, media, card);
        }
Пример #6
0
        protected override void OnBindingContextChanged()
        {
            CardMediaViewModel cardModel = BindingContext as CardMediaViewModel;

            this.media = cardModel.media;
            this.card  = cardModel.card;
            initialize(this.media, this.card);

            base.OnBindingContextChanged();
        }
        private async void openMediaPreview(ISortableCardItem item)
        {
            headerView.IsEnabled = false;

            AbMediaContent media = item as AbMediaContent;

            //await Navigation.PushAsync(new MediaPreviewCarouselPage(media, card, parentPage));

            headerView.IsEnabled = true;
        }
        private void createCard()
        {
            foreach (Java.IO.File file in mediaFiles)
            {
                AbMediaContent mediaContent = AbMediaContent
                                              .createMediaContent(FileUtilities.filePathToMediaType(file.Path), file.Path);

                card.addMedia(mediaContent);
            }
        }
Пример #9
0
        private async void camera_Tapped(object sender, EventArgs e)
        {
            AbMediaContent image = await MediaCaptureUtilities.takePicture(parentCard, parentPage);

            if (image != null)
            {
                this.imageFilePath  = image.filePath;
                contactImage.Source = ImageSource.FromFile(imageFilePath);
            }
        }
        private void isFavoriteBarItem_Clicked(object sender, EventArgs e)
        {
            AbMediaContent curMedia = cardMediaViewModels[carouselView.Position].media;

            curMedia.isFavorited   = !curMedia.isFavorited;
            isFavoriteBarItem.Icon = (curMedia.isFavorited ? "FavoriteIcon.png" : "NonFavoriteIcon");

            //save media changes to its parent card
            this.card.saveToFile();
        }
        private void delete_Clicked(object sender, EventArgs e)
        {
            AbMediaContent curMedia = cardMediaViewModels[carouselView.Position].media;

            //TODO if card is null delete media async else just delete from the card
            this.card.removeMedia(curMedia);
            MediaManager.deleteMediaAsync(curMedia);

            cardMediaViewModels.RemoveAt(carouselView.Position);
        }
        public MediaSelectPage(AbMediaContent media)
        {
            InitializeComponent();

            this.media = media;



            mediaDisplayView.setMedia(false, media);

            //linkSwitch.IsToggled = media.isSelected;
        }
        private void isFavorite_Clicked(object sender, EventArgs e)
        {
            AbMediaContent curMedia = cardMediaViewModels[carouselView.Position].media;

            MediaManager.favoriteManager.setFavorite(!curMedia.isFavorited, curMedia);
            MediaManager.saveFavoriteManager();

            isFavoritedImage.Source = (curMedia.isFavorited ? "FavoriteIcon.png" : "NonFavoriteIcon");

            //save media changes to its parent card
            card?.saveToFile();
        }
Пример #14
0
        public void setFavorite(bool isFavorited, AbMediaContent media)
        {
            if (isFavorited)
            {
                addFavorite(media);
            }
            else
            {
                removeFavorite(media);
            }

            media.isFavorited = isFavorited;
        }
 private void toggleLinkMedia(AbMediaContent media)
 {
     if (media.isSelected)
     {
         selectedMedia.Add(media);
         linkManager.addLink(rootMedia, media);
     }
     else
     {
         selectedMedia.Remove(media);
         linkManager.removeLink(rootMedia, media);
     }
 }
        protected override void OnBindingContextChanged()
        {
            AbMediaContent media = this.BindingContext as AbMediaContent;

            if (media.mediaType == MediaContentType.Card)
            {
                hideAll();
                base.cardMediaVisible();
            }
            else
            {
                base.OnBindingContextChanged();
            }
        }
        private async void addLink_Clicked(object sender, EventArgs e)
        {
            AbMediaContent curMedia = cardMediaViewModels[carouselView.Position].media;

            var action = await DisplayActionSheet("Choose media type to link to", "Cancel", null, "Image", "Video", "Audio", "Note");

            if (action != "Cancel")
            {
                MediaContentType mediaType;
                Enum.TryParse <MediaContentType>(action, out mediaType);

                //await Navigation.PushAsync(new LinkedMediaListPage(mediaType, curMedia, card));
            }
        }
Пример #18
0
        //Open existing note
        public NoteView(bool isEditable, AbMediaContent media)
        {
            InitializeComponent();

            this.noteMedia       = media as NoteMediaContent;
            this.titleEntry.Text = noteMedia.name;
            this.bodyEditor.Text = noteMedia.bodyText;

            this.bodyEditor.IsEnabled = isEditable;
            this.titleEntry.IsEnabled = isEditable;

            this.titleEntry.Focus();

            this.parentPage = Navigation.NavigationStack.LastOrDefault();
        }
Пример #19
0
        private async Task saveChangesAsync()
        {
            if (titleEntry.Text == "")
            {
                await parentPage.DisplayAlert("Warning", "Note must have title", "Ok");

                return;
            }

            string filePath;


            //If null we are creating new text file
            if (this.noteMedia == null)
            {
                filePath = Path.Combine(FilePaths.allNotesPath, $@"{Guid.NewGuid()}.txt");
                IFile file = await FileSystem.Current.LocalStorage.CreateFileAsync(filePath, CreationCollisionOption.FailIfExists);
            }
            else
            {
                filePath = noteMedia.filePath;
            }

            // Write to text file
            IFile textFile = await FileSystem.Current.GetFileFromPathAsync(filePath);

            await textFile.WriteAllTextAsync(titleEntry.Text + System.Environment.NewLine + bodyEditor.Text);

            // If null add to card
            if (this.noteMedia == null)
            {
                this.noteMedia          = new NoteMediaContent(filePath);
                this.noteMedia.name     = titleEntry.Text;
                this.noteMedia.bodyText = bodyEditor.Text;
                parentCard?.addMedia(this.noteMedia);
                MediaManager.addNewMedia(this.noteMedia);
            }
            else
            {
                // Update actual note media instance in memory
                this.noteMedia.name     = titleEntry.Text;
                this.noteMedia.bodyText = bodyEditor.Text;
            }
            capturedMedia = noteMedia;
            // End page
            // await Navigation.PopAsync();
        }
Пример #20
0
        // TODO perhaps move behavior to DayMediaObservableCollection
        private async void flowListView_FlowItemTapped(object sender, ItemTappedEventArgs e)
        {
            AbMediaContent media = e.Item as AbMediaContent;

            if (!isSelecting)
            {
                if (media.mediaType == MediaContentType.MediaCount)
                {
                    MediaCountBox mediaBox = media as MediaCountBox;
                    mediaBox.toggleOpen();
                }
                else // NOTE: reusing CardMediaCarouselPage will break disappear logic in MediaDisplayView
                {
                    await Navigation.PushAsync(new CardMediaCarouselPage(media, MediaManager.allMedia));
                }
            }
        }
Пример #21
0
        private void FlowListView_FlowItemTapped(object sender, ItemTappedEventArgs e)
        {
            if (IsVisible)
            {
                AbMediaContent media = e.Item as AbMediaContent;

                if (media.mediaType == MediaContentType.MediaCount)
                {
                    MediaCountBox mediaBox = media as MediaCountBox;
                    mediaBox.toggleOpen();
                }
                else
                {
                    selectMedia(media);
                }
            }
        }
        private void confirmDelete_Clicked(object sender, EventArgs e)
        {
            AbMediaContent curMedia = getCurMedia();

            if (card == null)
            {
                MediaManager.deleteMediaAsync(curMedia);
            }
            else
            {
                this.card.removeMedia(curMedia);
            }

            cardMediaViewModels.RemoveAt(carouselView.Position);

            toggleToolbarVisible(false, deleteConfirmationBar, .5);
        }
Пример #23
0
        async void stopButton_Clicked(object sender, EventArgs e)
        {
            if (isRecording)
            {
                AudioPlayerManager.stopRecordAudio();

                DateTime audioDuration = new DateTime((long)AudioPlayerManager.getAudioDuration(audioFilePath));
                recordingDuration.Text = audioDuration.ToString("HH:mm:ss");

                PromptConfig prompt = new PromptConfig();
                prompt.SetCancelText("Cancel");
                prompt.SetOkText("Create");
                prompt.SetMessage("Name audio recording");
                prompt.SetInputMode(InputType.Default);

                PromptResult promptResult = await UserDialogs.Instance.PromptAsync(prompt);

                if (promptResult.Ok)
                {
                    // prompt rename audio file
                    // Create a file, if one doesn't already exist.
                    IFile audioFile = await FileSystem.Current.LocalStorage.GetFileAsync(audioFilePath);

                    await audioFile.RenameAsync(promptResult.Text + ".wav");

                    audioFilePath = audioFile.Path;
                }

                this.capturedMedia = new AudioMediaContent(audioFilePath);

                parentCard?.addMedia(capturedMedia);
                MediaManager.addNewMedia(capturedMedia);


                stopRecordMode();
            }
            else if (isPlaying)
            {
                AudioPlayerManager.stopPlayAudio();

                stopPlayMode();
            }

            //audioPlayerFinished();
        }
Пример #24
0
        public AudioView(AbMediaContent media)
        {
            InitializeComponent();

            this.mediaNameLabel.Text = System.IO.Path.GetFileNameWithoutExtension(media.filePath);

            DateTime audioDuration = new DateTime((long)AudioPlayerManager.getAudioDuration(media.filePath));

            recordingDuration.Text = audioDuration.ToString("HH:mm:ss");

            this.audioMedia = media as AudioMediaContent;

            stopButton.IsEnabled = false;

            // WARNING TODO MEMORY LEAK not unsubscribing from event
            // will need to add to some preparefordispose method called from parent page
            AudioPlayerManager.audioPlayFinished += audioPlayFinished;
        }
Пример #25
0
        private async Task saveChangesAsync()
        {
            if (nameEntry.Text == null || nameEntry.Text == "")
            {
                await parentPage.DisplayAlert("Warning", "Contact must have name", "Ok");

                return;
            }

            string filePath;

            if (this.contactMedia == null)
            {
                filePath = Path.Combine(FilePaths.allContactsPath, $@"{Guid.NewGuid()}" + ".contact");
                IFile file = await FileSystem.Current.LocalStorage.CreateFileAsync(filePath, CreationCollisionOption.FailIfExists);
            }
            else
            {
                filePath = contactMedia.filePath;
            }

            ContactMediaContent newContactMedia = contactMedia;

            // update fields on contact media
            if (newContactMedia == null)
            {
                newContactMedia = new ContactMediaContent(filePath);
            }
            newContactMedia.initialize(nameEntry.Text, phoneEntry.Text, imageFilePath);


            // If null add to card
            if (this.contactMedia == null)
            {
                parentCard?.addMedia(newContactMedia);
                MediaManager.addNewMedia(newContactMedia);
            }

            this.capturedMedia = newContactMedia;
            this.contactMedia  = this.capturedMedia as ContactMediaContent;
            JSONSerialManager.serialize(filePath, newContactMedia);

            //await Navigation.PopAsync();
        }
Пример #26
0
        //Open existing contact
        public ContactView(bool isEditable, AbMediaContent media)
        {
            InitializeComponent();

            this.contactMedia        = media as ContactMediaContent;
            this.contactImage.Source = contactMedia.image;
            this.imageFilePath       = contactMedia.imageFilePath;
            this.nameEntry.Text      = contactMedia.name;
            this.phoneEntry.Text     = contactMedia.phoneNumber;

            /*
             * if(imageFilePath == null || imageFilePath == "")
             * {
             *  this.changeImageLabel.Text = "Set Image";
             * }
             * else
             *  this.changeImageLabel.Text = "Change Image";
             */

            this.parentPage = Navigation.NavigationStack.LastOrDefault();
        }
Пример #27
0
        private void selectMedia(AbMediaContent media)
        {
            if (media.isSelected)
            {
                selectedMedia.Remove(media);
            }
            else
            {
                selectedMedia.Add(media);
            }
            media.isSelected = !media.isSelected;

            if (selectedMedia.Count == 1)
            {
                enableSelectionIcons();
            }
            else if (selectedMedia.Count == 0)
            {
                disableSelectionIcons();
            }

            numSelectedLabel.Text = selectedMedia.Count + " selected";
        }
        public MediaPreviewCarouselPage(AbMediaContent startingMedia, Dir card, ContentPage parentPage)
        {
            InitializeComponent();

            this.card = card;
            this.cardMediaViewModels = new ObservableCollection <CardMediaViewModel>();


            ObservableCollection <AbMediaContent> mediaList = card.getMediaListByType(startingMedia.mediaType);

            foreach (AbMediaContent media in mediaList)
            {
                cardMediaViewModels.Add(new CardMediaViewModel()
                {
                    media = media, card = card, parentPage = parentPage
                });
            }
            this.carouselView.ItemsSource = cardMediaViewModels;

            this.carouselView.Position = mediaList.IndexOf(startingMedia);

            this.carouselView.PositionSelected += carouselView_PositionSelected;
        }
Пример #29
0
 public bool containsMedia(AbMediaContent media)
 {
     return(mediaList.Contains(media));
 }
        private void carouselView_PositionSelected(object sender, PositionSelectedEventArgs e)
        {
            AbMediaContent curMedia = cardMediaViewModels[carouselView.Position].media;

            isFavoriteBarItem.Icon = (curMedia.isFavorited ? "FavoriteIcon.png" : "NonFavoriteIcon");
        }