Exemplo n.º 1
0
        protected virtual void AddActionSheetOption(ActionSheetOption opt, NSWindow alertWindow, NSStackView containerView, int yPos, bool isDestructive = false)
        {
            var btn = new NSButton(new CGRect(0, yPos, 200, 28))
            {
                Title = opt.Text ?? string.Empty
            };

            if (isDestructive)
            {
                var colorTitle = new NSMutableAttributedString(btn.AttributedTitle);
                colorTitle.AddAttribute(NSStringAttributeKey.ForegroundColor, NSColor.Red, new NSRange(0, opt.Text.Length));
                btn.AttributedTitle = colorTitle;
            }

            if (opt.ItemIcon != null)
            {
                btn.Image = NSImage.ImageNamed(opt.ItemIcon);
            }

            btn.Activated += (sender, e) =>
            {
                this.windowFunc().EndSheet(alertWindow);
                opt.Action?.Invoke();
            };

            containerView.AddSubview(btn);
        }
Exemplo n.º 2
0
        protected virtual void AddActionSheetOption(ActionSheetOption opt, UIAlertController controller, UIAlertActionStyle style, IBitmap image = null)
        {
            var alertAction = UIAlertAction.Create(opt.Text, style, x => opt.Action?.Invoke());

            if (opt.ItemIcon == null && image != null)
            {
                opt.ItemIcon = image;
            }

            //if (opt.ItemIcon != null)
            //    alertAction.SetValueForKey(opt.ItemIcon.ToNative(), new NSString("image"));

            controller.AddAction(alertAction);
        }
        protected virtual void AddActionSheetOption(ActionSheetOption opt, UIAlertController controller, UIAlertActionStyle style, string imageName)
        {
            var alertAction = UIAlertAction.Create(opt.Text, style, x => opt.Action?.Invoke());

            if (opt.ItemIcon == null && imageName != null)
            {
                opt.ItemIcon = imageName;
            }

            if (opt.ItemIcon != null)
            {
                var icon = UIImage.FromBundle(opt.ItemIcon);
                alertAction.SetValueForKey(icon, new NSString("image"));
            }
            controller.AddAction(alertAction);
        }
Exemplo n.º 4
0
        protected virtual void AddActionSheetOption(ActionSheetOption opt, UIAlertController controller, UIAlertActionStyle style, IBitmap image = null)
        {
            var alertAction = UIAlertAction.Create(opt.Text, style, x => opt.Action?.Invoke());

            if (opt.ItemIcon == null && image != null)
                opt.ItemIcon = image;

            if (opt.ItemIcon != null)
                alertAction.SetValueForKey(opt.ItemIcon.ToNative(), new Foundation.NSString("image"));

            controller.AddAction(alertAction);
        }
Exemplo n.º 5
0
 protected virtual void AddActionSheetOption(ActionSheetOption opt, UIAlertController controller, UIAlertActionStyle style)
 {
     controller.AddAction(UIAlertAction.Create(opt.Text, style, x => opt.TryExecute()));
 }
Exemplo n.º 6
0
 protected virtual void AddActionSheetOption(ActionSheetOption opt, UIAlertController controller, UIAlertActionStyle style)
 {
     controller.AddAction(UIAlertAction.Create(opt.Text, style, x => opt.TryExecute()));
 }