Example #1
0
        void ButtonHandler(SharedButton.ControlEvent control, float x, float y, float width, float height, string text)
        {
            switch (control)
            {
            case SharedButton.ControlEvent.Init:

                m_myButton = UIButton.FromType(UIButtonType.System);
                m_myButton.SetTitle(text, UIControlState.Normal);
                m_myButton.Frame = new CoreGraphics.CGRect(x, y, width, height);
                using (var imageData = NSData.FromStream(SharedResource.GetStream("settings.png")))
                {
                    using (var image = UIImage.LoadFromData(imageData))
                    {
                        m_myButton.SetImage(image, UIControlState.Normal);
                        m_myButton.ImageEdgeInsets = new UIEdgeInsets(0, m_myButton.Frame.Size.Width - image.Size.Width - 15, 0, 0);
                        m_myButton.TitleEdgeInsets = new UIEdgeInsets(0, 0, 0, image.Size.Width + 15);
                    }
                }
                View.Add(m_myButton);
                break;

            case SharedButton.ControlEvent.Click:
                m_myButton.SetTitle(text, UIControlState.Normal);
                break;
            }
        }
        void ButtonHandler(SharedButton.ControlEvent control, float x, float y, float width, float height, string text)
        {
            switch (control)
            {
            case SharedButton.ControlEvent.Init:
                var layout = FindViewById <LinearLayout>(Resource.Id.myLayout);
                m_myButton      = new Button(this);
                m_myButton.Text = text;
                var draw = new BitmapDrawable(this.Resources, SharedResource.GetStream("settings.png"));
                draw.SetBounds(0, 0, 128, 128);
                m_myButton.SetCompoundDrawables(null, null, draw, null);
                m_myButton.CompoundDrawablePadding = 5;
                layout.AddView(m_myButton);
                break;

            case SharedButton.ControlEvent.Click:
                m_myButton.Text = text;
                break;
            }
        }