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); } }
protected override void DrawBackground( IDrawContext drawContext, Rectangle bounds) { base.DrawBackground(drawContext, bounds); // Calculate text bounds float textHeight = bounds.Height / 4; Rectangle textBounds = new Rectangle(bounds.X, bounds.Bottom - textHeight, bounds.Width, textHeight); // Calculate button bounds float buttonDimension = Math.Min(bounds.Width, bounds.Height - textHeight); float buttonRadius = buttonDimension / 2; Rectangle buttonBounds = new Rectangle( bounds.Center.X - buttonRadius, bounds.Center.Y - (textHeight / 2) - buttonRadius, buttonDimension, buttonDimension); // Calculate image bounds float imageDimension = buttonDimension / 2; Rectangle imageBounds = new Rectangle( buttonBounds.Center.X - (imageDimension / 2), buttonBounds.Center.Y - (imageDimension / 2), imageDimension, imageDimension); Bitmap icon = this.RadioButtonItem.Icon; if (this._isTouchDown) { drawContext.FillEllipse(buttonBounds, this.Theme.SubtleForegroundColor); if (null != icon) { drawContext.DrawImage(icon, imageBounds, Colors.White); } } else if (this.IsChecked) { drawContext.FillEllipse(buttonBounds, this.Theme.AccentColor); if (null != icon) { drawContext.DrawImage(icon, imageBounds, Colors.White); } } else { drawContext.DrawEllipse(buttonBounds.Center, buttonRadius - 1.0f, buttonRadius - 1.0f, this.Theme.SubtleForegroundColor, strokeWidth: 1.0f); if (null != icon) { drawContext.DrawImage(icon, imageBounds, this.Theme.SubtleForegroundColor); } } drawContext.DrawText(this.RadioButtonItem.Text, textBounds, this.Theme.SubtleForegroundColor, this._textFormat); }
protected override void DrawBackground( IDrawContext drawContext, Rectangle bounds) { base.DrawBackground(drawContext, bounds); // Calculate text bounds float textHeight = bounds.Height; Rectangle textBounds = new Rectangle(bounds.X, bounds.Bottom - textHeight, bounds.Width, textHeight); // Calculate button bounds float buttonDimension = Math.Min(bounds.Width, bounds.Height); float buttonRadius = buttonDimension / 2; Rectangle buttonBounds = new Rectangle( bounds.Center.X - buttonRadius, bounds.Center.Y - buttonRadius, buttonDimension, buttonDimension); if (this._isTouchDown) { drawContext.FillEllipse(buttonBounds, this.Theme.SubtleForegroundColor); drawContext.DrawText(this._text, textBounds, Colors.White, this._textFormat); } else if (this.IsChecked) { drawContext.FillEllipse(buttonBounds, this.Theme.AccentColor); drawContext.DrawText(this._text, textBounds, Colors.White, this._textFormat); } else { drawContext.DrawEllipse(buttonBounds.Center, buttonRadius - 1.0f, buttonRadius - 1.0f, this.Theme.SubtleForegroundColor, strokeWidth: 1.0f); drawContext.DrawText(this._text, textBounds, this.Theme.SubtleForegroundColor, this._textFormat); } }