Exemplo n.º 1
0
        //--------------------------------------------------------------------------------------------------
        // Для ключа propertyName удаляет все ошибки из словаря errors.
        void DelErrors([CallerMemberName] string propertyName = null)
        {
            if (errors.ContainsKey(propertyName))
            {
                Errors.Remove(propertyName);
            }
            OnPropertyChanged("Errors");

            if (propertyName == "SelectedWordExpression" || propertyName == "SelectedWordTrans")
            {
                SaveWord.ChangeCanExecute();
            }
            if (propertyName == "SelectedWordExpression")
            {
                OnPropertyChanged("SelectedWordExpressionHasErrors");
            }
            if (propertyName == "SelectedWordTrans")
            {
                OnPropertyChanged("SelectedWordTransHasErrors");
            }

            if (propertyName == "SelectedSamplePhrase" || propertyName == "SelectedSampleTrans")
            {
                SaveSample.ChangeCanExecute();
            }
            if (propertyName == "SelectedSamplePhrase")
            {
                OnPropertyChanged("SelectedSamplePhraseHasErrors");
            }
            if (propertyName == "SelectedSampleTrans")
            {
                OnPropertyChanged("SelectedSampleTransHasErrors");
            }
        }
Exemplo n.º 2
0
        //--------------------------------------------------------------------------------------------------
        // В словарь errors добавляет по ключу propertyName ошибку со строкой errorString.
        void AddError(string errorString, [CallerMemberName] string propertyName = null)
        {
            ObservableCollection <string> err;

            if (errors.TryGetValue(propertyName, out err))
            {
                err.Add(errorString);
            }
            else
            {
                Errors.Add(propertyName, new ObservableCollection <string> {
                    errorString
                });
            }
            OnPropertyChanged("Errors");

            if (propertyName == "SelectedWordExpression" || propertyName == "SelectedWordTrans")
            {
                SaveWord.ChangeCanExecute();
            }
            if (propertyName == "SelectedWordExpression")
            {
                OnPropertyChanged("SelectedWordExpressionHasErrors");
            }
            if (propertyName == "SelectedWordTrans")
            {
                OnPropertyChanged("SelectedWordTransHasErrors");
            }

            if (propertyName == "SelectedSamplePhrase" || propertyName == "SelectedSampleTrans")
            {
                SaveSample.ChangeCanExecute();
            }
            if (propertyName == "SelectedSamplePhrase")
            {
                OnPropertyChanged("SelectedSamplePhraseHasErrors");
            }
            if (propertyName == "SelectedSampleTrans")
            {
                OnPropertyChanged("SelectedSampleTransHasErrors");
            }
        }
Exemplo n.º 3
0
        private static void SaveWord()
        {
            var word = new WordCard();

            Console.WriteLine("Word:");
            word.Word = Console.ReadLine();
            Console.WriteLine("Meaning:");

            var charArray = Console.ReadKey(true);

            Console.InputEncoding = System.Text.Encoding.Unicode;
            word.Meaning          = Console.ReadLine();
            Console.WriteLine("Difficulty(1-4):");
            var input = Console.ReadLine();

            word.Difficulty = int.Parse(string.IsNullOrEmpty(input) ? "100" : input);
            var saveWord = new SaveWord();

            saveWord.SaveOneWord(word);
            Console.Clear();
        }
Exemplo n.º 4
0
        public static void SaveWordOffline(string word, string definition = null)
        {
            SaveWord sw;

            try
            {
                sw = new SaveWord();
            }
            catch (Exception e)
            {
                throw new Exception("Could not open connection to offline database.", e);
            }

            bool wordAlreadySaved = SearchWordLogic.WordExistsOffline(word);
            bool definitionAlreadySavedOrIsNull = (!string.IsNullOrWhiteSpace(definition)) ? SearchDefinitionLogic.DefinitionExistsOffline(definition) : false;

            bool successfulSave;

            using (sw)
            {
                if (wordAlreadySaved && string.IsNullOrWhiteSpace(definition) || definitionAlreadySavedOrIsNull)
                {
                    return;
                }

                if (wordAlreadySaved && !definitionAlreadySavedOrIsNull && !string.IsNullOrWhiteSpace(definition))
                {
                    successfulSave = sw.AddDefinition(word, definition);
                }
                else
                {
                    successfulSave = sw.Save(word, definition);
                }
            }

            if (!successfulSave)
            {
                throw new Exception($"Could not save word: {word}.");
            }
        }
    private void Start()
    {
        //this is to identify the script and grab the variable containing collected words.
        // It then does the work of splitting the words.

        //Next I need to call a function that will do the work of making a 1:1 map to split the words;


        GameObject getCollectedScript = GameObject.Find("PouchWords");
        SaveWord   savedWords         = getCollectedScript.GetComponent <SaveWord>();

        print("Saved Words: " + savedWords.ReturnCollected());
        pouchWords = savedWords.ReturnCollected().Split(new char[] {});

        foreach (string word in pouchWords)
        {
            print("pouchwords: " + word);
            //attach word to position;
        }

        LoadWords(pouchWords);
    }