Ejemplo n.º 1
0
 private void WordCard_WordEdited(object sender, EventArgs e)
 {
     if (SelectedWordList != null)
     {
         WordListManager.SaveList(SelectedWordList);
     }
 }
Ejemplo n.º 2
0
        private void WordCard_DeleteWord(object sender, EventArgs e)
        {
            if (SelectedWordList == null)
            {
                return;
            }
            WordEntry entry = (sender as WordCard)?.DataContext as WordEntry;

            if (entry != null)
            {
                if (SelectedWordList.WordList == null || SelectedWordList.WordList.Entries == null)
                {
                    return;
                }
                snackbarMain.MessageQueue.Enqueue(
                    entry.Word + " deleted",
                    "UNDO",
                    (obj) => {
                    obj.SelectedWordList.WordList.Entries.Insert(obj.Item2, obj.entry);
                    WordListManager.SaveList(obj.SelectedWordList);
                },
                    (SelectedWordList, SelectedWordList.WordList.Entries.IndexOf(entry), entry),
                    false,
                    true,
                    TimeSpan.FromSeconds(5));
                SelectedWordList.WordList.Entries.Remove(entry);
                WordListManager.SaveList(SelectedWordList);
            }
        }
Ejemplo n.º 3
0
 private void WordListsWindow_Closing(object sender, CancelEventArgs e)
 {
     if (SelectedWordList != null)
     {
         WordListManager.SaveList(SelectedWordList);
     }
 }
Ejemplo n.º 4
0
        private void btnRenameListSave_Click(object sender, RoutedEventArgs e)
        {
            if (renamingList == null)
            {
                return;
            }

            if (!WordlistNameValidationRule.ValidateWordlistName(txtRenameListName.Text, CultureInfo.InvariantCulture).IsValid)
            {
                txtRenameListName.Focus();
                Keyboard.Focus(txtRenameListName);
                txtRenameListName.SelectAll();
                return;
            }
            string newPath = Path.Combine(Path.GetDirectoryName(renamingList.Path), txtRenameListName.Text + ".xml");

            File.Move(renamingList.Path, newPath);
            renamingList.WordList.Name = txtRenameListName.Text;
            renamingList.Path          = newPath;
            WordListManager.SaveList(renamingList);
            renamingList = null;
            snackbar.MessageQueue.Enqueue($"{txtRenameListName.Text} renamed");
            dialogHost.IsOpen = false;
        }
Ejemplo n.º 5
0
 private void Application_Exit(object sender, ExitEventArgs e)
 {
     WordListManager.CommitDeletions();
 }