public SpecialAbilityView(Monster monster, SpecialAbility ability)
        {
            _Monster = monster;
            _Ability = ability;


            BackgroundColor = UIColor.Clear;
            BorderColor     = 0xFFFFFFFF.UIColor();
            Border          = 2.0f;
            Gradient        = new GradientHelper(CMUIColors.PrimaryColorDark);


            _DeleteButton = new UIButton();
            _DeleteImage  = UIImage.FromFile("Images/External/redx.png");
            _DeleteButton.SetImage(_DeleteImage, UIControlState.Normal);
            _DeleteButton.TouchUpInside += delegate
            {
                _Monster.SpecialAbilitiesList.Remove(_Ability);
            };

            _SpecialTextButton = new GradientButton();
            _SpecialTextButton.SetTitleColor(0x00000000.UIColor(), UIControlState.Normal);
            _SpecialTextManager = new ButtonPropertyManager(_SpecialTextButton, MainUI.MainView, _Ability, "Text")
            {
                Multiline = true
            };
            _Manager.Add(_SpecialTextManager);

            _NameButton = new GradientButton();
            CMStyles.TextFieldStyle(_NameButton);
            _Manager.Add(new ButtonPropertyManager(_NameButton, MainUI.MainView, _Ability, "Name"));

            _TypeButton = new GradientButton();
            ButtonPropertyManager typeMan = new ButtonPropertyManager(_TypeButton, MainUI.MainView, _Ability, "Type");

            typeMan.ValueList = new List <KeyValuePair <object, string> > {
                new KeyValuePair <object, string>("Ex", "Ex"),
                new KeyValuePair <object, string>("Sp", "Sp"),
                new KeyValuePair <object, string>("Su", "Su"),
                new KeyValuePair <object, string>("", "-"),
            };
            _Manager.Add(typeMan);

            Add(_DeleteButton);
            Add(_NameButton);
            Add(_TypeButton);
            Add(_SpecialTextButton);

            LayoutSubviews();
        }
Exemplo n.º 2
0
        public override void Draw(CGRect rect)
        {
            SetNeedsDisplay();

            base.Draw(rect);



            rect.X      += _border / 2.0f;
            rect.Width  -= _border;
            rect.Y      += _border / 2.0f;
            rect.Height -= _border;


            CGContext cr = UIGraphics.GetCurrentContext();

            //cr.SetAllowsAntialiasing(true);

            float [] cornerRadii = new float[4];
            if (_CornerRadii != null)
            {
                Array.Copy(_CornerRadii, cornerRadii, 4);
            }
            else if (_SkipCorners != null)
            {
                for (int i = 0; i < 4; i++)
                {
                    cornerRadii[i] = _SkipCorners[i]?0f:CornerRadius;
                }
            }
            else
            {
                for (int i = 0; i < 4; i++)
                {
                    cornerRadii[i] = CornerRadius;
                }
            }


            GradientHelper useGradient = _gradient;
            bool           reversed    = false;

            if (!Enabled && _DisabledGradient != null)
            {
                useGradient = _DisabledGradient;
            }
            else if (Highlighted && Tracking)
            {
                if (_HighlightedGradient == null)
                {
                    reversed = true;
                }
                else
                {
                    _gradient = _HighlightedGradient;
                }
            }



            cr.DrawRoundRect(useGradient.Gradient, rect, cornerRadii, reversed?(float)Math.PI / 2.0f:(float)-Math.PI / 2.0f);


            if (_border > 0)
            {
                if (_SkipCorners == null && _CornerRadii == null)
                {
                    GraphicUtils.RoundRectPath(cr, rect, _cornerRadius);
                }
                else if (_SkipCorners != null)
                {
                    GraphicUtils.RoundRectPath(cr, rect, _cornerRadius, _SkipCorners);
                }
                else if (_CornerRadii != null)
                {
                    GraphicUtils.RoundRectPath(cr, rect, _CornerRadii);
                }

                cr.SetStrokeColor(_borderColor.CGColor.Components);
                cr.SetLineWidth(_border);
                cr.StrokePath();
            }

            if (BonusImage != null)
            {
                cr.TranslateCTM(0, BonusImage.Size.Height + _BonusImageRect.Y * 2.0f);
                cr.ScaleCTM(1.0f, -1.0f);

                cr.DrawImage(_BonusImageRect, _BonusImage.CGImage);
            }
        }