Esempio n. 1
0
        async void listNotes_ItemSelected(System.Object sender, Xamarin.Forms.SelectedItemChangedEventArgs e)
        {
            if (e.SelectedItem != null && e.SelectedItem is ConcernNote)
            {
                ConcernNote note = e.SelectedItem as ConcernNote;

                if (note.Key == null)
                {
                    return;
                }

                string action = await DisplayActionSheet("Note selection action", null, null, "No Action", "Edit", "Delete");

                switch (action)
                {
                case "Edit":
                    EditNote(note);
                    break;

                case "Delete":
                    DeleteNote(note);
                    break;

                default:
                    break;
                }
            }

            listNotes.ItemsSource = null;
            listNotes.ItemsSource = SetUpNotesListItemSource();
        }
Esempio n. 2
0
        private List <ConcernNote> SetUpNotesListItemSource()
        {
            if (notesKey != null)
            {
                DrawData.Notes.TryGetValue(notesKey, out List <ConcernNote> info);
                return(info?.OrderByDescending(x => x.Time).ToList());
            }
            else
            {
                List <ConcernNote> noteListTemp    = new List <ConcernNote>();
                List <string>      noteKeyListData = DrawData.Notes.Keys.ToList();

                foreach (string keyUsed in noteKeyListData)
                {
                    DrawData.Notes.TryGetValue(keyUsed, out List <ConcernNote> info);
                    List <ConcernNote> t2 = info?.OrderByDescending(x => x.Time).ToList();

                    foreach (ConcernNote noteItem in t2)
                    {
                        ConcernNote nn = new ConcernNote
                        {
                            Message = keyUsed + " - " + noteItem.Message,
                            Time    = noteItem.Time
                        };

                        noteListTemp.Add(nn);
                    }
                }
                return(noteListTemp);
            }
        }
Esempio n. 3
0
        private void DeleteNote(ConcernNote note)
        {
            bool ok = DrawData.Notes.TryGetValue(note.Key, out List <ConcernNote> notesFound);

            if (ok)
            {
                ConcernNote matched = notesFound.Find(x => x.ID == note.ID);
                if (matched != null)
                {
                    notesFound.Remove(matched);
                }
            }
        }
Esempio n. 4
0
        private async void EditNote(ConcernNote note)
        {
            bool ok = DrawData.Notes.TryGetValue(note.Key, out List <ConcernNote> notesFound);

            if (ok)
            {
                ConcernNote matched = notesFound.Find(x => x.ID == note.ID);
                if (matched != null)
                {
                    string result = await DisplayPromptAsync("Edit Information", $"Notes on {note.Key} Area?",
                                                             placeholder : "Add more information", keyboard : Keyboard.Text, initialValue : matched.Message);

                    if (!string.IsNullOrEmpty(result))
                    {
                        matched.Message = result;
                    }
                }
            }
        }