예제 #1
0
        public async void OnBack(object sender, EventArgs e)
        {
            try
            {
                if (child != null)
                {
                    if (child.GetType() == typeof(NotesDetailTemplate))
                    {
                        ((NotesDetailTemplate)child).ResetFocus();
                        if (string.IsNullOrEmpty(((NotesDetailTemplate)child).currentNote.userNote))
                        {
                            var k = await App.Current.MainPage.DisplayAlert("Alert", "Empty Note, this note will be deleted", "Ok", "Cancel");

                            if (k)
                            {
                                for (int i = 0; i < App.serverData.mei_user.noteList.Count; i++)
                                {
                                    if (App.serverData.mei_user.noteList[i].noteID == ((NotesDetailTemplate)child).currentNote.noteID)
                                    {
                                        App.serverData.mei_user.noteList.RemoveAt(i);
                                    }
                                }
                                await((HomeLayout)App.Current.MainPage).SetLoading(true, "Deleting note...");
                                await BaseFunctions.DeletNoteFromServer(((NotesDetailTemplate)child).currentNote);

                                await((HomeLayout)App.Current.MainPage).SetLoading(false, " note...");
                            }
                            else
                            {
                                return;
                            }
                        }
                    }
                    if (child.GetType() == typeof(FeedbackPage))
                    {
                        ((FeedbackPage)child).ResetFocus();
                    }
                    if (this.Parent.GetType() == typeof(RelativeLayout))
                    {
                        ((RelativeLayout)this.Parent).Children.Remove(this);
                    }
                    ((HomeLayout)App.Current.MainPage).ResetCurrentPage();
                }
            }
            catch (Exception ex)
            {
                //  await App.Current.MainPage.DisplayAlert("Crash", ex.ToString(), "OK");
            }
        }