예제 #1
0
        protected override void DrawBackground(
            IDrawContext drawContext,
            Rectangle bounds)
        {
            base.DrawBackground(drawContext, bounds);

            if ((bounds.Height <= 0) || (bounds.Width <= 0))
            {
                return;
            }

            Size      shadowPadding     = new Size(bounds.Width / 10, bounds.Height / 10);
            Size      shadowThinPadding = new Size(shadowPadding.Width / 2, shadowPadding.Height / 2);
            Rectangle buttonRect        = bounds.Deflate(shadowPadding.Width, shadowPadding.Height);
            Rectangle shadowRect        = Rectangle.FromLTRB(bounds.X, buttonRect.Top - shadowThinPadding.Height, buttonRect.Right + shadowThinPadding.Width, bounds.Bottom);
            Rectangle imageRect         = buttonRect.Deflate(buttonRect.Width / 6, buttonRect.Height / 6);

            float blurAmount = Math.Min(shadowPadding.Width, shadowPadding.Height) / 1.5f;

            Color shadowColor = Colors.Gray;

            if ((this._isTouchDown) || (!this.IsEnabled))
            {
                drawContext.FillEllipseShadow(shadowRect, shadowColor, blurAmount / 2);
                drawContext.FillEllipse(buttonRect, this.ButtonPressedBackgroundColor);
                drawContext.DrawImage(this._icon, imageRect, this.ButtonPressedForegroundColor);
            }
            else
            {
                drawContext.FillEllipseShadow(shadowRect, shadowColor, blurAmount);
                drawContext.FillEllipse(buttonRect, this.ButtonBackgroundColor);
                drawContext.DrawImage(this._icon, imageRect, this.ForegroundColor);
            }
        }