コード例 #1
0
        void ShowList(int id)
        {
            if (CombatListButton != null)
            {
                //get a context, any context
                Context c = CombatListButton.Context;

                CMPreferences.SetLastCombatTab(CombatListButton.Context, id);


                CombatListButton.Background = ContextCompat.GetDrawable(c, (id == 0) ?
                                                                        Resource.Drawable.blue_button_inverse : Resource.Drawable.blue_button);
                CombatListLayout.Visibility = (id == 0) ? ViewStates.Visible : ViewStates.Gone;
                PlayerListButton.Background = ContextCompat.GetDrawable(c, (id == 1) ?
                                                                        Resource.Drawable.blue_button_inverse : Resource.Drawable.blue_button);
                PlayerListLayout.Visibility  = (id == 1) ? ViewStates.Visible : ViewStates.Gone;
                MonsterListButton.Background = ContextCompat.GetDrawable(c, (id == 2) ?
                                                                         Resource.Drawable.blue_button_inverse : Resource.Drawable.blue_button);
                MonsterListLayout.Visibility = (id == 2) ? ViewStates.Visible : ViewStates.Gone;

                characterView.Visibility   = (id == 0) ? ViewStates.Visible : ViewStates.Gone;
                dieRollerLayout.Visibility = (id != 0) ? ViewStates.Visible : ViewStates.Gone;
            }
        }
コード例 #2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View v = inflater.Inflate(Resource.Layout.Combat, container, false);

            v.FindViewById <Button>(Resource.Id.nextButton).Click +=
                delegate { NextClicked(); };
            v.FindViewById <Button>(Resource.Id.prevButton).Click +=
                delegate { PrevClicked(); };
            v.FindViewById <Button>(Resource.Id.upButton).Click +=
                delegate { UpClicked(); };
            v.FindViewById <Button>(Resource.Id.downButton).Click +=
                delegate { DownClicked(); };
            v.FindViewById <Button>(Resource.Id.rollInitiativeButton).Click +=
                delegate { RollInitiativeClicked(); };
            v.FindViewById <Button>(Resource.Id.sortButton).Click += (object sender, EventArgs e) =>
            {
                SortInitiativeClicked();
            };
            v.FindViewById <Button>(Resource.Id.resetButton).Click += (object sender, EventArgs e) =>
            {
                ResetInitiativeClicked();
            };


            UpdateCurrentCharacter(v);

            ListView lv = v.FindViewById <ListView>(Resource.Id.initiativeList);

            _InitListAdapter = new InitiativeListAdapter(_CombatState, v);
            lv.Adapter       = (_InitListAdapter);

            _InitListAdapter.CharacterClicked += (sender, e) =>
            {
                if (_SelectedCharacter != e.Character)
                {
                    _SelectedCharacter         = e.Character;
                    _InitListAdapter.Character = e.Character;
                    _InitListAdapter.NotifyDataSetChanged();
                }
                ShowCharacter(v, e.Character);
            };

            lv.ItemClick += (sender, e) => {
                Character c = ((BaseAdapter <Character>)lv.Adapter)[e.Position];
                if (_SelectedCharacter != c)
                {
                    _SelectedCharacter         = c;
                    _InitListAdapter.Character = _SelectedCharacter;
                    _InitListAdapter.NotifyDataSetChanged();
                }
                ShowCharacter(v, c);
            };


            CombatListButton  = v.FindViewById <Button>(Resource.Id.combatListButton);
            PlayerListButton  = v.FindViewById <Button>(Resource.Id.playerListButton);
            MonsterListButton = v.FindViewById <Button>(Resource.Id.monsterListButton);

            CombatListLayout  = v.FindViewById <View>(Resource.Id.combatListLayout);
            PlayerListLayout  = v.FindViewById <View>(Resource.Id.playerListLayout);
            MonsterListLayout = v.FindViewById <View>(Resource.Id.monsterListLayout);

            dieRollerLayout = v.FindViewById <View>(Resource.Id.dieRollerLayout);
            characterView   = v.FindViewById <WebView>(Resource.Id.characterView);


            SetupColumnTabButton(CombatListButton, 0);
            SetupColumnTabButton(PlayerListButton, 1);
            SetupColumnTabButton(MonsterListButton, 2);



            AddCharacterList(inflater, container, v, Resource.Id.playerListLayout, false);
            AddCharacterList(inflater, container, v, Resource.Id.monsterListLayout, true);

            if (CombatListButton != null)
            {
                ShowList(CMPreferences.GetLastCombatTab(v.Context));
            }

            ShowCharacter(v, _ViewCharacter);

            SetupDieRoller(v);

            return(v);
        }