Esempio n. 1
0
        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));
            });
        }
Esempio n. 2
0
        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();
        }