public static void Duplicate(string from, string dir, Action onNameGet, Action <string, string> onFinish) { TextInput.GetInput("Enter a name for your flashcards.", "Flashcards", name => { onNameGet(); if (name == "") { onFinish("", dir); return; } var flashcards = new Flashcards(from, dir); if (!flashcards.TryLoadCards()) { return; } var editor = new FlashcardsEditor(from, flashcards.description, flashcards.cards); editor.onFinish = () => { if (editor.Save($"{dir}/{name}")) { onFinish(name, dir); } }; editor.Show(); }, "", s => { return(TextInput.dirNameValid(s) && !Helper.Exists(dir + s)); }); }
public static void Create(string dir, Action onNameGet, Action <string, string> onFinish) { // Take name input for flashcards. TextInput.GetInput("Enter a name for your flashcards.", "Flashcards", name => { onNameGet(); if (name == "") { onFinish("", dir); return; } // Initialize and show flashcards editor. var editor = new FlashcardsEditor(name); editor.onFinish = () => { if (editor.DialogResult == DialogResult.OK) { if (editor.Save(dir + "/" + name)) { if (editor.DialogResult == DialogResult.OK) { onFinish(name, dir); } else { onFinish("", dir); } } } else { onFinish("", dir); } }; editor.Show(); }, "", s => { return(TextInput.dirNameValid(s) && !Helper.Exists(dir + s)); }); }
public static void Edit(string name, string dir, Action <string, string> uponCreation) { var flashcards = new Flashcards(name, dir); if (!flashcards.TryLoadCards()) { return; } var editor = new FlashcardsEditor(name, flashcards.description, flashcards.cards); editor.onFinish = () => { if (editor.Save(flashcards.path)) { uponCreation(name, dir); } }; editor.Show(); }