/// <summary>
        /// Initializes a new instance of the <see cref="NControl.Controls.ActionButton"/> class.
        /// </summary>
        public ActionButton()
        {
            var layout = new Grid {
                Padding = 0, ColumnSpacing = 0, RowSpacing = 0
            };

            ButtonShadowElement = new NControlView
            {
                DrawingFunction = (canvas, rect) => {
                    // Draw shadow
                    rect.Inflate(new NGraphics.Size(-4));
                    rect.Y += 4;

                    Device.OnPlatform(

                        //iOS
                        () => canvas.DrawEllipse(rect, null, new NGraphics.RadialGradientBrush(
                                                     new NGraphics.Color(0, 0, 0, 200), NGraphics.Colors.Clear)),

                        // Android
                        () => canvas.DrawEllipse(rect, null, new NGraphics.RadialGradientBrush(
                                                     new NGraphics.Point(rect.Width / 2, (rect.Height / 2) + 2),
                                                     new NGraphics.Size(rect.Width, rect.Height),
                                                     new NGraphics.Color(0, 0, 0, 200), NGraphics.Colors.Clear)),

                        // WP
                        () => canvas.DrawEllipse(rect, null, new NGraphics.RadialGradientBrush(
                                                     new NGraphics.Color(0, 0, 0, 200), NGraphics.Colors.Clear)),

                        null
                        );
                },
            };

            ButtonElement = new NControlView
            {
                DrawingFunction = (canvas, rect) => {
                    // Draw button circle
                    rect.Inflate(new NGraphics.Size(-8));
                    canvas.DrawEllipse(rect, null, new NGraphics.SolidBrush(ButtonColor.ToNColor()));
                }
            };

            ButtonIconLabel = new FontAwesomeLabel
            {
                XAlign    = TextAlignment.Center,
                YAlign    = TextAlignment.Center,
                TextColor = Color.White,
                Text      = AwasomeIcon.FAPlus,
                FontSize  = 24,
            };

            layout.Children.Add(ButtonShadowElement);
            layout.Children.Add(ButtonElement);
            layout.Children.Add(ButtonIconLabel);

            Content = layout;
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ExpenseClaimApp.Controls.ImageActionButton"/> class.
        /// </summary>
        public ImageActionButton()
        {
            var layout = new Grid {
                Padding = 0, ColumnSpacing = 0, RowSpacing = 0
            };

            ButtonShadowElement = new NControlView
            {
                DrawingFunction = (canvas, rect) =>
                {
                    // Draw shadow
                    rect.Inflate(new NGraphics.Size(-4));
                    rect.Y += 4;

                    if (Device.RuntimePlatform == Device.iOS)
                    {
                        //iOS
                        canvas.DrawEllipse(rect, null, new NGraphics.RadialGradientBrush(new NGraphics.Color(0, 0, 0, 200), NGraphics.Colors.Clear));
                    }
                    else if (Device.RuntimePlatform == Device.Android)
                    {
                        // Android
                        canvas.DrawEllipse(rect, null, new NGraphics.RadialGradientBrush(new NGraphics.Point(rect.Width / 2, (rect.Height / 2) + 2),
                                                                                         new NGraphics.Size(rect.Width, rect.Height), new NGraphics.Color(0, 0, 0, 200), NGraphics.Colors.Clear));
                    }
                }
            };

            ButtonElement = new NControlView
            {
                DrawingFunction = (canvas, rect) =>
                {
                    // Draw button circle
                    rect.Inflate(new NGraphics.Size(-8));
                    canvas.DrawEllipse(rect, null, new NGraphics.SolidBrush(ButtonColor.ToNColor()));
                }
            };

            ButtonIconImage = new Image {
                Scale = 0.4
            };

            var imageWrapper = new Grid {
                Padding = 5
            };

            imageWrapper.Children.Add(ButtonIconImage);

            layout.Children.Add(ButtonShadowElement);
            layout.Children.Add(ButtonElement);
            layout.Children.Add(imageWrapper);

            Content = layout;
        }