Example #1
0
 public void SetButtonStyleAtIndex(ASMultiSelectActionSheetButtonStyle style, int index)
 {
     if (index < Buttons.Count)
     {
         ASMultiSelectActionSheetButton button = Buttons.ElementAt(index);
         button.SetButtonStyleForButton(style);
     }
     else
     {
         Console.WriteLine("ERROR: Index out of bounds.");
         return;
     }
 }
Example #2
0
        private ASMultiSelectActionSheetButton MakeButtonWithTitle(string title, ASMultiSelectActionSheetButtonStyle style, int row)
        {
            ASMultiSelectActionSheetButton b = new ASMultiSelectActionSheetButton();

            b.Layer.MasksToBounds = true;
            b.Layer.BorderWidth   = 0.0f;
            b.SetTitle(title, UIControlState.Normal);
            b.TouchUpInside += ButtonPressed;
            b.Style          = style;
            b.Row            = row;
            b.SetButtonStyleForButton(style);

            return(b);
        }
Example #3
0
        public void SetButtonStyleForButton(ASMultiSelectActionSheetButtonStyle style)
        {
            UIColor backgroundColor = UIColor.White;
            UIColor borderColor     = UIColor.White;
            UIColor titleColor      = UIColor.Black;
            UIFont  font            = null;

            switch (style)
            {
            case ASMultiSelectActionSheetButtonStyle.Default:
                font = UIFont.SystemFontOfSize(15.0f);
                break;

            case ASMultiSelectActionSheetButtonStyle.MultiSelect:
                font = UIFont.SystemFontOfSize(15.0f);
                break;

            case ASMultiSelectActionSheetButtonStyle.Cancel:
                font       = UIFont.BoldSystemFontOfSize(25.0f);
                titleColor = UIColor.FromRGB(0.21f, 0.54f, 0.75f);
                break;

            case ASMultiSelectActionSheetButtonStyle.PerformAction:
                font       = UIFont.SystemFontOfSize(25.0f);
                titleColor = UIColor.FromRGB(0.21f, 0.54f, 0.75f);
                SetTitleColor(UIColor.DarkGray, UIControlState.Disabled);
                break;

            default:
                break;
            }

            SetTitleColor(titleColor, UIControlState.Normal);
            TitleLabel.Font = font;
            SetBackgroundImage(PixelImageWithColor(backgroundColor), UIControlState.Normal);
            SetBackgroundImage(PixelImageWithColor(borderColor), UIControlState.Highlighted);
            Layer.BorderColor  = borderColor.CGColor;
            Layer.CornerRadius = 5.0f;

            if (style == ASMultiSelectActionSheetButtonStyle.MultiSelect)
            {
                SetImage(UIImage.FromFile("check-circle-Small.png"), UIControlState.Selected);
            }
        }
Example #4
0
        /// <summary>
        /// Creates an action sheet section.
        /// </summary>
        /// <param name="title">Title.</param>
        /// <param name="message">Subtitle.</param>
        /// <param name="buttonDefs">Button titles and an optional object.</param>
        /// <param name="style">Button style; this controls appearance and behavior in some cases.</param>
        /// <param name="actionButtonTitle">If defined, the section will also include a stacked action button.</param>
        /// <param name="actionObject">Optional: A custom action or command to bind to the action button.</param>
        public ASMultiSelectActionSheetSection(string title, string message, List <Tuple <string, object> > buttonDefs, ASMultiSelectActionSheetButtonStyle style, string actionButtonTitle, object actionObject = null)
        {
            if (!String.IsNullOrEmpty(title))
            {
                UILabel titleLabel = new UILabel();
                titleLabel.BackgroundColor = UIColor.Clear;
                titleLabel.TextAlignment   = UITextAlignment.Center;
                titleLabel.Font            = UIFont.BoldSystemFontOfSize(25.0f);
                titleLabel.TextColor       = UIColor.Black;
                titleLabel.Lines           = 1;
                titleLabel.Text            = title;
                TitleLabel = titleLabel;
                AddSubview(TitleLabel);
            }

            if (!String.IsNullOrEmpty(message))
            {
                UILabel messageLabel = new UILabel();
                messageLabel.BackgroundColor = UIColor.Clear;
                messageLabel.TextAlignment   = UITextAlignment.Center;
                messageLabel.Font            = UIFont.SystemFontOfSize(15.0f);
                messageLabel.TextColor       = UIColor.Black;
                messageLabel.Lines           = 0;
                messageLabel.Text            = message;
                MessageLabel = messageLabel;
                AddSubview(MessageLabel);
            }

            horizontalLines = new List <UIView>();
            UIView titleLine = new UIView();

            titleLine.BackgroundColor = UIColor.FromRGB(0.63f, 0.63f, 0.63f);
            horizontalLines.Add(titleLine);
            AddSubview(titleLine);

            List <ASMultiSelectActionSheetButton> buttons = new List <ASMultiSelectActionSheetButton>();
            int index = 0;

            if (buttonDefs.Any())
            {
                foreach (var d in buttonDefs)
                {
                    ASMultiSelectActionSheetButton b = MakeButtonWithTitle(d.Item1, style, index++);
                    b.Data = d.Item2;
                    buttons.Add(b);

                    AddSubview(b);
                }
            }

            ASMultiSelectActionSheetButton cancel = MakeButtonWithTitle("Cancel", ASMultiSelectActionSheetButtonStyle.Cancel, index++);

            buttons.Add(cancel);
            AddSubview(cancel);

            controlLine = new UIView();
            controlLine.BackgroundColor = UIColor.FromRGB(0.63f, 0.63f, 0.63f);
            AddSubview(controlLine);

            ASMultiSelectActionSheetButton action = MakeButtonWithTitle(actionButtonTitle, ASMultiSelectActionSheetButtonStyle.PerformAction, index++);

            action.Data    = actionObject;
            action.Enabled = false;
            buttons.Add(action);
            AddSubview(action);
            ActionButton = action;

            Buttons = buttons;
        }