Beispiel #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;
                }
            }
        }
        public HashSet <JPChar> KanjiByRad(JPChar rad)
        {
            HashSet <JPChar> res = new HashSet <JPChar>();

            SQLiteCommand command = new SQLiteCommand(_dbConnection);

            command.CommandText = KANJI_FROM_RADS_QUERY;
            command.Parameters.Add(new SQLiteParameter("@id", rad.Id));
            SQLiteDataReader result = command.ExecuteReader(System.Data.CommandBehavior.KeyInfo);

            while (result.Read())
            {
                if (result.IsDBNull(0))
                {
                    continue;
                }
                Int32  id      = result.GetInt32(0);
                string lit     = result.GetString(1);
                int    strokes = result.GetInt32(2);
                JPChar k       = new JPChar((int)id, lit, strokes, false);
                res.Add(k);
            }
            result.Close();

            return(res);
        }
Beispiel #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;
                }
            }
        }
        public List <JPChar> GetRadList()
        {
            List <JPChar> res = new List <JPChar>();

            SQLiteCommand command = new SQLiteCommand(_dbConnection);

            command.CommandText = GET_RADS_QUERY;
            SQLiteDataReader result = command.ExecuteReader(System.Data.CommandBehavior.KeyInfo);

            while (result.Read())
            {
                int    id      = result.GetInt32(0);
                string lit     = result.GetString(1);
                int    strokes = result.GetInt32(2);
                int    entry   = result.GetInt32(3);
                string symbol  = result.GetString(4);
                JPChar r       = new JPChar(id, symbol, strokes, true);
                res.Add(r);
            }
            result.Close();

            return(res);
        }