Esempio n. 1
0
        private void CreateVocabularyList(string fileName)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }
            if (Vocabularies.Any(v => string.Compare(v.FileName, fileName, true) == 0))
            {
                return;
            }

            var vocabularyList = new VocabularyListViewModel(dataService, dialogService)
            {
                FileName = fileName
            };

            Vocabularies.Add(vocabularyList);
            vocabularyList.SaveCommand.Execute(null);
        }
Esempio n. 2
0
        private void RemoveVocabularyCommandHandler(VocabularyListViewModel vocabulary)
        {
            if (!(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
            {
                MessageBox.ShowDialog("Need use modifiers");
                return;
            }

            if (vocabulary != null)
            {
                if (MessageBox.ShowDialog("Are you sure want delete vocabulary?", "Delete", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                {
                    try
                    {
                        DataService.Delete(vocabulary.FileName);
                        Refresh();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.ShowDialog(ex.Message, ex.GetType().Name, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    }
                }
            }
        }