Esempio n. 1
0
        //Swiping up will delete the card and take the user back to the subject page if then then press delete on the popup
        //Swiping down will show the user the answer; giving them the option to either press the button or use a gesture
        private async void SwipeContainer_Swipe(object sender, SwipedEventArgs e)
        {
            if (e.Direction == SwipeDirection.Up)
            {
                bool popupResult = await DisplayAlert("Alert", "Are you sure you want to delete this card?", "Delete", "Cancel");


                if (popupResult)
                {
                    ArrayControl.deleteCard(pubSelectedSubject, pubSelectedCard);


                    this.Navigation.RemovePage(this);


                    pubSubjectPage.updateCards();
                }
            }
            else if (e.Direction == SwipeDirection.Down)
            {
                answer.IsVisible = true;

                BackgroundImageSource = ImageSource.FromResource("FlashCardsApp.CardBackgroundOpen.png");
            }
        }
Esempio n. 2
0
        //If the page is in view mode, tapping the edit button will enable edit mode, allowing the user to change the text in the entries
        //Once in edit mode the button changes to a save button; when pressed the changed entries will be saved and the page will go back into view mode
        private void btnEdit_Clicked(object sender, EventArgs e)
        {
            if (btnEdit.Text == "Edit")
            {
                answer.IsVisible = true;

                btnEdit.BackgroundColor = Color.Green;
                btnEdit.Text            = "Save";

                question.IsReadOnly = false;
                answer.IsReadOnly   = false;

                BackgroundImageSource = ImageSource.FromResource("FlashCardsApp.CardBackgroundOpen.png");
            }
            else
            {
                btnEdit.BackgroundColor = Color.Blue;
                btnEdit.Text            = "Edit";

                question.IsReadOnly = true;
                answer.IsReadOnly   = true;


                ArrayControl.editCard(pubSelectedSubject, pubSelectedCard, question.Text, answer.Text);

                pubSubjectPage.updateCards();

                ArrayControl.JsonSave();
            }
        }
Esempio n. 3
0
        //If the page is in view mode, tapping the edit button will enable edit mode, allowing the user to change the name of the subject
        //Once in edit mode the button changes to a save button; when pressed the changed entry will be saved and the page will go back into view mode
        private void btnEditName_Clicked(object sender, EventArgs e)
        {
            if (btnEditName.Text == "Title")
            {
                btnEditName.BackgroundColor = Color.Green;
                btnEditName.Text            = "Save";

                subjectTitle.IsReadOnly = false;
            }
            else
            {
                btnEditName.BackgroundColor = Color.FromHex("#fafafa");
                btnEditName.Text            = "Title";

                subjectTitle.IsReadOnly = true;


                ArrayControl.EditSubject(pubSelectedSubject, subjectTitle.Text);

                pubMainPageVM.pubMP.UpdateSubjects();


                ArrayControl.JsonSave();
            }
        }
Esempio n. 4
0
        //Adds a new subject to the subject array, updates the list view, and takes the user to the subject page with edit mode enabled
        private async void btnCreateSbj_Clicked(object sender, EventArgs e)
        {
            ArrayControl.CreateSubject("New Subject");

            UpdateSubjects();

            await Navigation.PushAsync(new SubjectPage(ArrayControl.subjectArray.Length - 1, viewModel, true));
        }
Esempio n. 5
0
        //Adds a new card to the card array, updates the list view, and takes the user to the card page with edit mode enabled
        private async void btnCreate_Clicked(object sender, EventArgs e)
        {
            ArrayControl.CreateCard(pubSelectedSubject);

            updateCards();

            await Navigation.PushAsync(new CardPage(pubSelectedSubject, ArrayControl.cardArray.Length - 1, this, true));
        }
Esempio n. 6
0
        //Detecs if the user swipes down, and saves the arrays to a JSON file then tells the user
        private async void SwipeContainer_Swipe(object sender, SwipedEventArgs e)
        {
            if (e.Direction == SwipeDirection.Down)
            {
                ArrayControl.JsonSave();

                await DisplayAlert("Alert", "Cards Saved Successfully!", "Ok");
            }
        }
Esempio n. 7
0
        //Saves all of the arrays to a JSON file and refreshes the main page list view
        public void UpdateSubjects()
        {
            ArrayControl.JsonSave();

            viewModel.updateListView();

            SubjectsListView.ItemsSource = null;
            SubjectsListView.ItemsSource = viewModel.subjects;
        }
Esempio n. 8
0
        //Deletes the subject that the user is currently on the page for, then removes the page and updates the mainpage listview
        private void btnDelete_Clicked(object sender, EventArgs e)
        {
            ArrayControl.DeleteSubject(pubSelectedSubject);

            this.Navigation.RemovePage(this);


            pubMainPageVM.pubMP.UpdateSubjects();
        }
Esempio n. 9
0
        //Saves all of the arrays to a JSON file and refreshes the list view
        public void updateCards()
        {
            viewModel.updateListView(pubSelectedSubject);

            CardsListView.ItemsSource = null;
            CardsListView.ItemsSource = viewModel.cards;


            ArrayControl.JsonSave();
        }