示例#1
0
        public void SelectRad(JPChar rad)
        {
            HashSet <JPChar> kanji = _kanjiByRads[rad];

            if (_currentKanjiSelection.Count == 0 && _selectedRads.Count == 0)
            {
                _currentKanjiSelection.UnionWith(kanji);
            }
            else if (_currentKanjiSelection.Count > 0)
            {
                _currentKanjiSelection.IntersectWith(kanji);
            }

            KanjiListChanged?.Invoke(this, new EventArgs());

            _selectedRads.Add(rad);
            rad.IsSelected = true;

            foreach (JPChar r in _radList)
            {
                if (r.IsSelected || !r.IsEnabled)
                {
                    continue;
                }

                var checkKanji = _currentKanjiSelection.Intersect(_kanjiByRads[r]);
                if (checkKanji.Count() == 0)
                {
                    r.IsEnabled = false;
                }
            }
        }
示例#2
0
        internal void ClearRads()
        {
            foreach (JPChar rad in _selectedRads)
            {
                rad.IsSelected = false;
            }
            _selectedRads.Clear();
            _currentKanjiSelection.Clear();
            KanjiListChanged?.Invoke(this, new EventArgs());

            foreach (JPChar r in _radList)
            {
                r.IsEnabled = true;
            }
        }
示例#3
0
        public void DeselectRad(JPChar rad)
        {
            _selectedRads.Remove(rad);
            rad.IsSelected = false;

            _currentKanjiSelection.Clear();



            bool first = true;

            foreach (JPChar r in _selectedRads)
            {
                HashSet <JPChar> kanji = _kanjiByRads[r];
                if (first)
                {
                    _currentKanjiSelection.UnionWith(kanji);
                    first = false;
                }
                else
                {
                    _currentKanjiSelection.IntersectWith(kanji);
                }
            }

            KanjiListChanged?.Invoke(this, new EventArgs());

            foreach (JPChar r in _radList)
            {
                if (r.IsSelected || r.IsEnabled)
                {
                    continue;
                }

                if (_selectedRads.Count > 0)
                {
                    var checkKanji = _currentKanjiSelection.Intersect(_kanjiByRads[r]);
                    if (checkKanji.Count() > 0)
                    {
                        r.IsEnabled = true;
                    }
                }
                else
                {
                    r.IsEnabled = true;
                }
            }
        }