Example #1
0
        private void AddVocabularyCommandHandler()
        {
            int    weekOfYear  = DateTimeFormatInfo.CurrentInfo.Calendar.GetWeekOfYear(DateTime.Now, System.Globalization.CalendarWeekRule.FirstDay, DayOfWeek.Monday);
            string defaultName = string.Format("{0:MMdd}.Vocabulary{0:yyyy}.{1:0#}", DateTime.Now, weekOfYear);

            var strVocabularyName = InputBox.ShowDialog("Please, insert name of new Vocabulary", defaultName);

            if (string.IsNullOrEmpty(strVocabularyName))
            {
                return;
            }

            if (Vocabularies.Any(v => string.Compare(v.FileName, strVocabularyName, true) == 0))
            {
                MessageBox.ShowDialog(string.Format("Vocabulary '{0}' already exists.", strVocabularyName), "Warning");
            }
            else
            {
                Vocabularies.Add(new VocabularyListViewModel(dataService, dialogService)
                {
                    FileName = strVocabularyName
                });
                dataService.Set(new VocabularyRecord[0], strVocabularyName);
            }

            AddVocabularyCommand.RaiseCanExecuteChanged();
        }
Example #2
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);
        }