private void NewChar_CharacterAdded(object sender, ChineseCharacter newChar) { if (this.Characters.Any(c => c.UChar == newChar.UChar)) { MessageBox.Show("Character existed!"); return; } this.Characters.Add(newChar); }
private void Button_Click(object sender, RoutedEventArgs e) { ChineseCharacter chineseCharacter = new ChineseCharacter() { UChar = this.ChineseCharacter.UChar, Pinyin = this.ChineseCharacter.Pinyin, Definition = this.ChineseCharacter.Definition, Level = this.ChineseCharacter.Level }; this.CharacterAdded?.Invoke(this, chineseCharacter); this.ChineseCharacter = new ChineseCharacter(); }
private void LoadNextChar() { this.Button_A.IsEnabled = true; this.Button_B.IsEnabled = true; this.Button_C.IsEnabled = true; this.Button_D.IsEnabled = true; this.CurrentChar = this.Characters[this.Random.Next(0, this.Characters.Count - 1)]; this.Pinyin_1 = this.Characters[this.Random.Next(0, this.Characters.Count - 1)].Pinyin; this.Pinyin_2 = this.Characters[this.Random.Next(0, this.Characters.Count - 1)].Pinyin; this.Pinyin_3 = this.Characters[this.Random.Next(0, this.Characters.Count - 1)].Pinyin; this.Pinyin_4 = this.Characters[this.Random.Next(0, this.Characters.Count - 1)].Pinyin; int i = this.Random.Next(0, 4); switch (i) { case 0: this.Pinyin_1 = this.CurrentChar.Pinyin; break; case 1: this.Pinyin_2 = this.CurrentChar.Pinyin; break; case 2: this.Pinyin_3 = this.CurrentChar.Pinyin; break; case 3: this.Pinyin_4 = this.CurrentChar.Pinyin; break; default: break; } }
public NewChar() { InitializeComponent(); this.DataContext = this; this.ChineseCharacter = new ChineseCharacter(); }