示例#1
0
        private void NewWord_Click(object sender, RoutedEventArgs e)
        {
            var new_win = new NewWord(null /*new WordsModel()*/,
                                      null, 2 /*DbModel.DomainClasses.Enum.WordType.Arbitrary_Sentences*/);

            new_win.ShowDialog();
        }
示例#2
0
        public void LoadDataWord(DataGridView dtgv)
        {
            NewWord nword  = new NewWord();
            var     source = nword.GetDataWord();

            dtgv.DataSource         = source;
            dtgv.Columns[0].Visible = false;
        }
示例#3
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            NewWord newword = new NewWord();

            newword.DeleteRecent();
            MessageBox.Show(deletedata);
            lvRecent.Clear();
        }
示例#4
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            NewWord word = new NewWord();

            TuDapAn = word.GetTuRandom();
            SpeechSynthesizer Speaker = new SpeechSynthesizer();

            Speaker.Speak(TuDapAn);
        }
示例#5
0
        private void Loaddata(ListView lvRecent)
        {
            NewWord newword = new NewWord();

            List <string> source = newword.GetRecent();

            for (int i = 0; i < source.Count; i++)
            {
                lvRecent.Items.Add(source[i]);
            }
        }
示例#6
0
        public void item_click_listview(object sender, MouseEventArgs e)
        {
            tbSearch.Text = listView1.SelectedItems[0].Text;
            NewWord resultSearch = new NewWord();
            Word    result       = new Word();

            result         = resultSearch.GetWordWhenSearch(tbSearch.Text);
            tvMeaning.Text = result.ViWord;
            tvExample.Text = result.Example;
            tvType.Text    = result.Type;
        }
示例#7
0
        void LoadWord(ListView dtword)
        {
            NewWord       word   = new NewWord();
            List <string> source = word.Init();

            for (int i = 0; i < source.Count; i++)
            {
                dtword.Items.Add(source[i]);
            }
            listView1.Sort();
        }
        private void loadData(ListView lvFavorite)
        {
            NewWord       word   = new NewWord();
            List <string> source = word.GetFavoriteWord();

            for (int i = 0; i < source.Count; i++)
            {
                lvFavorite.Items.Add(source[i]);
            }
            lvFavorite.Sort();
        }
示例#9
0
        private void simpleButton5_Click(object sender, EventArgs e)
        {
            NewWord word = new NewWord();

            try
            {
                word.SetFavorite(tbSearch.Text);
                MessageBox.Show(addSuccess);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
示例#10
0
        private void button1_Click(object sender, EventArgs e)
        {
            NewWord word   = new NewWord();
            int     number = word.Dem() + 1;

            try
            {
                word.InsertNewWords(number, tbAddNewWord.Text, tbAddMeaning.Text, cbType.Text, tbAddExample.Text);
                MessageBox.Show(AddNewwordSuccess);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
示例#11
0
        private void btRemove_Click(object sender, EventArgs e)
        {
            NewWord word = new NewWord();

            for (int i = 0; i < lvFavorite.Items.Count; i++)
            {
                if (lvFavorite.Items[i].Selected)
                {
                    word.XoaFavorite(lvFavorite.Items[i].Text);
                    lvFavorite.Clear();
                    loadData(lvFavorite);
                    MessageBox.Show("Xóa từ yêu thích thành công");
                }
            }
        }
示例#12
0
        private void CheckResult()
        {
            if (learningWords == null || learningWords.Count <= 0)
            {
                return;
            }

            //Check if the result was correct
            var isSynonym = !string.IsNullOrEmpty(learningWords [Index].Synonym) &&
                            !string.IsNullOrEmpty(learningWords [Index].Synonym
                                                  .Split(new char[] { ',', ';', '.' }, learningWords [Index].Synonym.Length)
                                                  .Where(x => x.ToLower().Equals(NewWord.ToLower())).FirstOrDefault());
            var isCorrect = NewWord.ToLower().Equals(learningWords [Index].Word.ToLower()) || isSynonym;

            if (learningMode == LearningMode.SupperMemo)
            {
                SupperMemo.Setup(learningWords [Index], isCorrect);
                UpdateDatabase(learningWords [Index]);
            }

            //if answer was correct remove this word from array
            if (isCorrect)
            {
                var example = learningWords [Index].Example;
                if (!string.IsNullOrEmpty(example))
                {
                    if (VisibleAction != null && learningWords.Count - 1 == 0)
                    {
                        VisibleAction();
                    }

                    SmartLearningApplication.Instance.ShowAlert("Example: " + learningWords [Index].Word, example, () => {
                        SetupValue();
                    });
                }
                else
                {
                    SmartLearningApplication.Instance.ShowToast("Correct!");
                    SetupValue();
                }
            }
            else
            {
                SmartLearningApplication.Instance.ShowError("The answer was not correct");
            }
        }
示例#13
0
        private void btSearch_Click(object sender, EventArgs e)
        {
            string  KeyWord      = tbSearch.Text;
            NewWord resultSearch = new NewWord();
            Word    result       = new Word();

            resultSearch.AddRecentWord(KeyWord);
            result = resultSearch.GetWordWhenSearch(KeyWord);
            if (result != null)
            {
                tvMeaning.Text = result.ViWord;
                tvExample.Text = result.Example;
                tvType.Text    = result.Type;
            }
            else
            {
                MessageBox.Show(message_wordnotfound);
            }
        }
示例#14
0
        static public void Menu()
        {
            int    Choosen;
            string filePath = @"word.txt";

            string[] lines = File.ReadAllLines(filePath);
            var      dict  = new StringDictionary(20);

            foreach (string s in lines)
            {
                string[] a = s.Split(": ");
                dict.Add(a[0], a[1]);
            }
            do
            {
                Console.WriteLine("<<<<<<<<<< DICTIONARY >>>>>>>>>>");
                Console.WriteLine("1. FIND WORD");
                Console.WriteLine("2. ADDING NEW WORD");
                Console.WriteLine("3. DELETE WORD IN DATABASE");
                Console.WriteLine("4. EXIT");
                Console.Write("YOUR CHOOSEN:");

                Choosen = int.Parse(Console.ReadLine());
                switch (Choosen)
                {
                case 1:
                    Console.WriteLine("Input the word you need to translate into Vietnamese(Upcase the first character):");
                    string val    = Console.ReadLine();
                    var    result = dict.Get(val);
                    Console.WriteLine("Meaning in Vietnamese:");
                    Console.WriteLine(result);
                    Console.WriteLine("Press any key to continue!");
                    Console.ReadKey();
                    Console.Clear();
                    break;

                case 2:
                    string NewWord;
                    Console.WriteLine("Enter Your Word and it's meanning in Vietnamese:");
                    Console.WriteLine("Ex: School: Truong Hoc");
                    NewWord = Console.ReadLine();
                    string[] nword = NewWord.Split(": ");
                    dict.Add(nword[0], nword[1]);
                    Console.WriteLine("Press any key to continue!");
                    Console.ReadKey();
                    Console.Clear();
                    break;

                case 3:
                    string DeLeteWord;
                    Console.Write("Enter word you want to delete!");
                    Console.WriteLine("Ex: School: Truong Hoc");
                    DeLeteWord = Console.ReadLine();
                    dict.Delete(DeLeteWord);
                    Console.WriteLine("Press any key to continue!");
                    Console.ReadKey();

                    Console.Clear();
                    break;

                case 4:
                    string fileName = @"word.txt";
                    //Kiểm tra nếu có file rồi thì xóa
                    FileInfo fi = new FileInfo(fileName);
                    if (fi.Exists)
                    {
                        fi.Delete();
                    }
                    //Tạo ra file mới
                    FileStream   fs      = new FileStream(fileName, FileMode.Create);
                    StreamWriter sWriter = new StreamWriter(fs, Encoding.UTF8);
                    // write some code here <3
                    for (int i = 0; i < 20; i++)
                    {
                        sWriter.WriteLine(dict.Save(i));
                    }
                    //End
                    sWriter.Flush();
                    fs.Close();
                    break;

                default:
                    Console.WriteLine("Re-Enter your choose:");
                    break;
                }
            } while (Choosen != 4);
            Console.ReadLine();
        }