public MonsterPickerDialog(Context context, bool isMonsters, CombatState state) : base(context)
        {
            _State      = state;
            _IsMonsters = isMonsters;

            RequestWindowFeature((int)WindowFeatures.NoTitle);
            SetCanceledOnTouchOutside(true);

            SetContentView(Resource.Layout.MonsterPickerDialog);
            Window.SetSoftInputMode(SoftInput.AdjustResize);

            ((Button)FindViewById(Resource.Id.closeButton)).Click +=
                (object sender, EventArgs e) => { Dismiss(); };

            ((Button)FindViewById(Resource.Id.addButton)).Click +=
                (object sender, EventArgs e) => { AddSelectedMonster(); };



            _Monsters = new List <Monster>(from x in Monster.Monsters orderby x.Name select x);

            _VisibleMonsters = _Monsters;
            _SelectedMonster = _Monsters[0];

            _Adapter = new MonsterPickerAdapter(_Monsters);

            _Adapter.SelectedMonster = _SelectedMonster;

            ListView lv = ((ListView)FindViewById(Resource.Id.monsterListView));

            lv.Adapter = (
                _Adapter);
            lv.ItemClick +=
                (object sender, AdapterView.ItemClickEventArgs e) => {
                if (_SelectedMonster != _VisibleMonsters[e.Position])
                {
                    Monster old = _SelectedMonster;
                    _SelectedMonster         = _VisibleMonsters[e.Position];
                    _Adapter.SelectedMonster = _SelectedMonster;
                    UpdateMonster(old);
                    UpdateMonster(_SelectedMonster);
                }
            };

            ((EditText)FindViewById(Resource.Id.monsterEditText)).TextChanged +=
                (object sender, Android.Text.TextChangedEventArgs e) => { FilterMonsters(); };
        }
        private void FilterMonsters()
        {
            ListView lv = (ListView)FindViewById(Resource.Id.monsterListView);

            MonsterPickerAdapter ad = (MonsterPickerAdapter)
                                      lv.Adapter;

            EditText monsterEditText = (EditText)FindViewById(Resource.Id.monsterEditText);

            List <Monster> newMonsters = null;

            string text = monsterEditText.Text.Trim();

            if (text.Length == 0)
            {
                newMonsters = new List <Monster>(_Monsters);
            }
            else
            {
                newMonsters = new List <Monster>(from x in _Monsters where
                                                 x.Name.ToUpper().Contains(text.ToUpper()) orderby x.Name select x);
            }
            _VisibleMonsters = newMonsters;

            if (newMonsters.Count == 0)
            {
                _SelectedMonster = null;
            }
            else if (!newMonsters.Contains(_SelectedMonster))
            {
                _SelectedMonster = newMonsters[0];
            }

            ad.SelectedMonster = _SelectedMonster;
            ad.Monsters        = newMonsters;
        }