async void OnEditCurrentClick(object sender, EventArgs e) { //get current selection PadoruEntry toEdit = GetSelection(); if (toEdit == null) { return; } //show padoru editor PadoruEditor editor = new PadoruEditor { CurrentStateEntry = toEdit, CurrentManagerConfig = currentManagerConfig }; if (editor.ShowDialog() == DialogResult.Cancel) { return; } //get edited entry PadoruEntry editedEntry = editor.CurrentStateEntry; if (editedEntry == null) { return; } //write back saved entry int index = currentCollection.Entries.IndexOf(toEdit); currentCollection.Entries.Remove(toEdit); currentCollection.Entries.Insert(index, editedEntry); SaveCollection(true); //re- populate selection panel await PopulateSelectionPanel(currentCollection.Entries); //update ui Refresh(); }
async void OnAddNewClick(object sender, EventArgs e) { //check collection exists if (currentCollection == null) { MessageBox.Show(this, "No Collection is currently active!", "No Collection", MessageBoxButtons.OK); return; } //create Padoru Editor and let user create new entry PadoruEditor editor = new PadoruEditor { EditingParentCollection = currentCollection, CurrentManagerConfig = currentManagerConfig }; if (editor.ShowDialog() != DialogResult.OK) { return; } //Get new entry PadoruEntry newEntry = editor.CurrentStateEntry; //add new entry to list of entrys if (newEntry != null) { currentCollection.Entries.Add(newEntry); currentlySelectedEntryId = newEntry.UID; SaveCollection(true); } //re- populate selection panel await PopulateSelectionPanel(currentCollection.Entries); //update ui Refresh(); }