private void ClearDataViewMenuItemClick(object sender, RoutedEventArgs e) { DataView.View = null; DataView.ItemsSource = null; Radical2Chars.Clear(); Char2Radicals.Clear(); ResetStatusText(); }
private void SearchByRadical(char Radical, Action UpdateStatusRadicalCountTextFunc, Action UpdateDataViewToEmpty) { if (Radical2Chars.ContainsKey(Radical)) { RefreshDataViewWithChars(DoSearchByRadical(Radical, Radical2Chars), UpdateStatusRadicalCountTextFunc); } else { UpdateDataViewToEmpty(); } }
private void SearchByMultipleRadical(string Radicals, Action UpdateStatusRadicalCountTextFunc, Action UpdateDataViewToEmpty) { IEnumerable <char> IntersectedChars = null; foreach (var Radical in Radicals) { if (Radical2Chars.TryGetValue(Radical, out string Chars)) { if (IntersectedChars == null) { IntersectedChars = Chars.ToList(); continue; } IntersectedChars = IntersectedChars.Intersect(Chars.ToList()); } else { IntersectedChars = null; break; } } if (IntersectedChars == null) { UpdateDataViewToEmpty(); return; } Dictionary <char, List <string> > result = new Dictionary <char, List <string> >(); foreach (var Char in IntersectedChars) { result.Add(Char, Char2Radicals[Char]); } RefreshDataViewWithChars(result, UpdateStatusRadicalCountTextFunc); }