Beispiel #1
0
 private void CreateAddDiePopover()
 {
     _AddDiePopover = new ButtonStringPopover(AddDieButton);
     foreach (int die in new int[] { 4, 6, 8, 10, 12 })
     {
         ButtonStringPopoverItem item = new ButtonStringPopoverItem();
         item.Text = die.ToString();
         item.Tag  = die;
         _AddDiePopover.Items.Add(item);
     }
     _AddDiePopover.ItemClicked += Handle_AddDiePopoverItemClicked;
 }
Beispiel #2
0
        private void WillShowActionsPopover(object sender, EventArgs e)
        {
            ButtonStringPopover p = (ButtonStringPopover)sender;


            Character ch = (Character)p.Data;

            List <CharacterActionItem> actions = CharacterActions.GetInitiativeItems(ch, _SelectedCharacter, null);

            p.Items.Clear();
            foreach (CharacterActionItem it in actions)
            {
                ButtonStringPopoverItem b = new ButtonStringPopoverItem();
                b.Tag  = it;
                b.Text = it.Name;
                b.Icon = it.Icon;
                p.Items.Add(b);
            }
        }
Beispiel #3
0
            public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
            {
                ButtonStringPopoverItem clickedItem = state._CurrentItems[indexPath.Row];

                string text = clickedItem.Text;

                //if not a separator
                if (!text.IsEmptyOrNull() && !clickedItem.Disabled)
                {
                    if (clickedItem.Subitems != null && clickedItem.Subitems.Count > 0)
                    {
                        state._CurrentItems = clickedItem.Subitems;
                        state.RecalcHeight();
                        state.TableView.ReloadData();
                    }
                    else
                    {
                        if (state != null)
                        {
                            if (state.ItemClicked != null)
                            {
                                int    index = indexPath.Row;
                                object tag   = null;
                                if (index < state._CurrentItems.Count)
                                {
                                    tag = state._CurrentItems[indexPath.Row].Tag;
                                }

                                state.ItemClicked(state, new PopoverEventArgs(text, index, tag));
                            }

                            if (state.SetButtonText)
                            {
                                state.Button.SetText(text);
                            }
                        }
                        state._controller.Dismiss(true);
                    }
                }
            }
Beispiel #4
0
        void AddActionItems(List <CharacterActionItem> actionList, List <ButtonStringPopoverItem> items)
        {
            items.Clear();

            foreach (CharacterActionItem it in actionList)
            {
                ButtonStringPopoverItem p = new ButtonStringPopoverItem();
                p.Text = it.Name;
                p.Tag  = it;
                p.Icon = it.Icon;
                items.Add(p);

                if (it.SubItems != null)
                {
                    AddActionItems(it.SubItems, p.Subitems);
                }

                if (it.Action == CharacterActionType.None && it.SubItems == null)
                {
                    p.Disabled = true;
                }
            }
        }
Beispiel #5
0
            public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
            {
                UITableViewCell cell = new UITableViewCell(UITableViewCellStyle.Default, "ButtonStringPopover");

                ButtonStringPopoverItem item = state._CurrentItems[indexPath.Row];

                if (item.Text.IsEmptyOrNull())
                {
                    UIView bview = new UIView();
                    bview.BackgroundColor = UIExtensions.RGBColor(0xCCCCCC);
                    cell.BackgroundView   = bview;
                    bview = new UIView();
                    bview.BackgroundColor       = UIExtensions.RGBColor(0xCCCCCC);
                    cell.SelectedBackgroundView = bview;
                    cell.Tag = 1;
                }
                else
                {
                    cell.TextLabel.Text = item.Text;
                    cell.TextLabel.Font = UIFont.SystemFontOfSize(14);
                    if (item.Disabled)
                    {
                        cell.TextLabel.TextColor = UIColor.LightGray;
                    }

                    UIImage image = state.GetCellIcon(indexPath.Row);
                    if (item.Selected)
                    {
                        image = UIExtensions.GetSmallIcon("check");
                    }
                    cell.ImageView.Image = image;
                    cell.ImageView.Frame = new CGRect(0, 0, 16, 16);
                }


                return(cell);
            }
Beispiel #6
0
        public ToolbarView()
        {
            BackgroundColor = new UIColor(1, 0, 0, 0);

            List <String> names = new List <String>()
            {
                "Combat", "Monsters", "Feats", "Spells", "Rules", "Treasure"
            };
            List <String> images = new List <String>()
            {
                "sword", "monster", "star", "scroll", "book", "treasure"
            };

            float pos         = 0;
            float buttonWidth = 110;
            float buttonGap   = -1;
            int   i           = 0;

            foreach (string s in names)
            {
                GradientButton b = new GradientButton();
                b.Frame = (new CGRect(pos, 0, buttonWidth, 50));
                b.SetImage(UIExtensions.GetSmallIcon(images[i]), UIControlState.Normal);

                b.Border      = 1;
                b.CornerRadii = new float[] { 4, 16, 0, 0 };

                b.SetTitle(s, UIControlState.Normal);
                UIEdgeInsets si = b.ImageEdgeInsets;
                si.Right         += 10;
                b.ImageEdgeInsets = si;

                pos += buttonWidth + buttonGap;
                buttons.Add(b);
                b.Tag            = i;
                b.TouchUpInside += HandleBTouchUpInside;
                i++;


                AddSubview(b);
            }

            clickedButton          = buttons[0];
            clickedButton.Gradient = new GradientHelper(CMUIColors.PrimaryColorDarker, CMUIColors.PrimaryColorMedium);

            _SettingsButton = new GradientButton();
            _SettingsButton.SetImage(UIImage.FromFile("Images/settings.png"), UIControlState.Normal);
            //_SettingsButton.Border = 0;
            //_SettingsButton.BackgroundColor = UIColor.Clear;
            //_SettingsButton.Gradient = new GradientHelper(0x00000000.UIColor());
            _SettingsButton.CornerRadius   = 0;
            _SettingsButton.TouchUpInside += SettingsButtonClicked;
            _SettingsButton.Frame          = new CGRect(Bounds.Width - 64, (Bounds.Height - 48.0f) / 2.0f, 48f, 48f);

            AddSubview(_SettingsButton);

            settingsPopover = new ButtonStringPopover(_SettingsButton);
            var pi = new ButtonStringPopoverItem()
            {
                Text = "Import"
            };

            settingsPopover.Items.Add(pi);
            pi = new ButtonStringPopoverItem {
                Text = "Export"
            };
            settingsPopover.Items.Add(pi);
            settingsPopover.Items.Add(new ButtonStringPopoverItem());
            serverItem = new ButtonStringPopoverItem {
                Text = "Run Local Service"
            };
            SetLocalServiceIcon();
            settingsPopover.Items.Add(serverItem);
            pi = new ButtonStringPopoverItem {
                Text = "Local Service Port"
            };
            settingsPopover.Items.Add(pi);
            pi = new ButtonStringPopoverItem {
                Text = "Local Service Passcode"
            };
            settingsPopover.Items.Add(pi);
            settingsPopover.ItemClicked += (sender, eee) =>
            {
                switch (eee.Index)
                {
                case 0:

                    Import();

                    break;

                case 1:

                    Export();

                    break;

                case 2:
                    LocalServiceClicked();
                    break;

                case 4:
                    LocalServicePortClicked();
                    break;

                case 5:
                    LocalServicePasscodeClicked();
                    break;
                }
            };


            _AboutButton = new GradientButton();
            _AboutButton.SetImage(UIImage.FromFile("Images/External/info.png"), UIControlState.Normal);
            // _AboutButton.Border = 0;
            //_AboutButton.BackgroundColor = UIColor.Clear;
            //_AboutButton.Gradient = new GradientHelper(0x00000000.UIColor());
            _AboutButton.CornerRadius   = 0;
            _AboutButton.TouchUpInside += AboutButtonClicked;
            _AboutButton.Frame          = new CGRect(Bounds.Width - 23, (Bounds.Height - 48.0f) / 2.0f, 48f, 48f);

            Add(_AboutButton);
            BackgroundColor = UIColor.Black;

            MobileSettings.Instance.PropertyChanged += MobileSettingsPropertyChanged;
        }