private void deleteKnownWordToolStripMenuItem_Click(object sender, EventArgs e)
 {
     foreach (DataGridViewRow row in dgvKnownWords.SelectedRows)
     {
         var word = row.Cells[0].Value.ToString();
         dbOperator.DeleteUserVocabulary(word);
         dbOperator.AddIgnoreWord(word);
     }
     KeepLocationBind(dgvKnownWords);
 }
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 0)
     {
         string w = dataGridView1.Rows[e.RowIndex].Cells["Word"].Value.ToString();
         dbOperator.AddIgnoreWord(w);
         dataGridView1.Rows.RemoveAt(e.RowIndex);
     }
 }
예제 #3
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            string word = null;

            if (e.RowIndex >= 0)
            {
                word = dataGridView1.Rows[e.RowIndex].Cells["Word"].Value.ToString();
            }
            if (e.ColumnIndex == 0)
            {
                dbOperator.AddIgnoreWord(word);
                dataGridView1.Rows.RemoveAt(e.RowIndex);
            }
            if (e.ColumnIndex == 1) //已经记住该单词
            {
                string sentence = dataGridView1.Rows[e.RowIndex].Cells["SubtitleSentence"].Value.ToString();
                //var subtitleName = Path.GetFileNameWithoutExtension(SubtitleFileName);
                var userVo = dbOperator.GetUserWord(word);
                if (userVo == null)
                {
                    userVo = new UserVocabulary()
                    {
                        Word       = word,
                        Sentence   = sentence,
                        Source     = this.SubtitleFileName,
                        CreateTime = DateTime.Now
                    };
                }
                userVo.KnownStatus = KnownStatus.Known;
                userVo.UpdateTime  = DateTime.Now;
                dbOperator.SaveUserVocabulary(userVo);
                dataGridView1.Rows.RemoveAt(e.RowIndex);
            }
            else if (e.ColumnIndex == 2) //IsStar
            {
                var star = dataGridView1.Rows[e.RowIndex].Cells["IsStar"].Value;
                if (star == "☆")
                {
                    dataGridView1.Rows[e.RowIndex].Cells[2].Value = "★";
                    dbOperator.UpdateStarFlag(word, true);
                }
                else if (star == "★")
                {
                    dataGridView1.Rows[e.RowIndex].Cells[2].Value = "☆";
                    dbOperator.UpdateStarFlag(word, false);
                }
            }
        }