Exemplo n.º 1
0
            public bool OnDrag(View v, DragEvent e)
            {
                switch (e.Action)
                {
                case DragAction.Entered:
                    break;

                case DragAction.Exited:
                    break;

                case DragAction.Ended:
                    break;

                case DragAction.Drop:
                    View dropView = (View)e.LocalState;
                    if (dropView.Parent is ListView)
                    {
                        if (((ListView)dropView.Parent).Adapter is CharacterListAdapter)
                        {
                            CharacterListAdapter dropAd   = (CharacterListAdapter)((ListView)dropView.Parent).Adapter;
                            Character            dropChar = dropAd[(int)dropView.Tag];

                            CombatFragment.CombatState.MoveDroppedCharacter(dropChar, null, _monsters);
                        }
                    }
                    break;
                }
                return(true);
            }
            public ConditionChangedHandler(View view, Character character, CharacterListAdapter adp, ViewGroup parent)
            {
                _View      = view;
                _Character = character;
                _Adp       = adp;
                _Parent    = parent;

                _Character.Monster.ActiveConditions.CollectionChanged += HandleConditionsChanged;

                _Character.Monster.PropertyChanged += HandlePropertyChanged;
                _Character.PropertyChanged         += HandlePropertyChanged;

                _View.ViewDetachedFromWindow += (object sender, View.ViewDetachedFromWindowEventArgs e) =>
                {
                    _Character.Monster.ActiveConditions.CollectionChanged -= HandleConditionsChanged;
                    _Character.Monster.PropertyChanged -= HandlePropertyChanged;
                    _Character.PropertyChanged         -= HandlePropertyChanged;
                    _Adp._Handlers.Remove(this);
                };
            }
            public ConditionButtonChangedHandler(View view, View b, Character character, ActiveCondition ac, CharacterListAdapter adp, ViewGroup parent)
            {
                _View            = view;
                _Character       = character;
                _Button          = b;
                _Adp             = adp;
                _Parent          = parent;
                _ActiveCondition = ac;

                _ActiveCondition.PropertyChanged += HandlePropertyChanged;
                _View.ViewDetachedFromWindow     += (object sender, View.ViewDetachedFromWindowEventArgs e) =>
                {
                    _ActiveCondition.PropertyChanged -= HandlePropertyChanged;
                    _Adp._ButtonHandlers.Remove(this);
                };
                b.ViewDetachedFromWindow += (object sender, View.ViewDetachedFromWindowEventArgs e) =>
                {
                    _ActiveCondition.PropertyChanged -= HandlePropertyChanged;
                    _Adp._ButtonHandlers.Remove(this);
                };
            }
            public bool OnDrag(View v, DragEvent e)
            {
                switch (e.Action)
                {
                case DragAction.Entered:
                    break;

                case DragAction.Exited:
                    break;

                case DragAction.Ended:
                    break;

                case DragAction.Drop:
                    View dropView = (View)e.LocalState;
                    if (dropView != _layout && dropView.Parent is ListView)
                    {
                        if (((ListView)dropView.Parent).Adapter is CharacterListAdapter)
                        {
                            CharacterListAdapter dropAd = (CharacterListAdapter)((ListView)dropView.Parent).Adapter;


                            try
                            {
                                Character targetChar = _ad._Characters[(int)_layout.Tag];
                                Character dropChar   = dropAd._Characters[(int)dropView.Tag];

                                _ad._State.MoveDroppedCharacter(dropChar, targetChar, targetChar.IsMonster);
                            }
                            catch (Exception ex)
                            {
                                System.Diagnostics.Debug.Write(ex.ToString());
                            }
                        }
                    }
                    break;
                }
                return(true);
            }
 public ListOnDragListener(CharacterListAdapter ad, View layout)
 {
     _ad     = ad;
     _layout = layout;
 }