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); Rectangle iconBounds = bounds; if (this._iconSize.HasValue) { Size iconSize = this._iconSize.Value; iconBounds = new Rectangle( bounds.Left + ((bounds.Width - iconSize.Width) / 2), bounds.Top + ((bounds.Height - iconSize.Height) / 2), iconSize.Width, iconSize.Height); } if (this._isChecked) { drawContext.DrawImage(this._checkedIcon, iconBounds, this._tintColor); } else { drawContext.DrawImage(this._uncheckedIcon, iconBounds, this._tintColor); } }
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) { const float Padding = 10.0f; base.DrawBackground(drawContext, bounds); bounds = bounds.Deflate(Padding, 0); float origin = (this._swipeDirection == ListViewSwipeDirection.Primary ? 1.0f : 0.0f); Rectangle imageBounds = new Rectangle( bounds.X + (origin * (bounds.Width - this._iconSize.Width)), bounds.Center.Y - (this._iconSize.Height / 2.0f), this._iconSize.Width, this._iconSize.Height); Rectangle textBounds = bounds.Deflate(imageBounds.Width + Padding, 0); if (null != this.Icon) { drawContext.DrawImage(this.Icon, imageBounds, this.ForegroundColor); } if (null != this.Text) { drawContext.DrawText(this.Text, textBounds, this.ForegroundColor, this._textFormat); } }
public void Draw(IDrawContext drawContext, TileDefinition tileDefinition, Rectangle destination) { drawContext.DrawImage(new DrawImageParams { Texture = this.Texture, Source = tileDefinition.Rectangle, Destination = destination, }); }
public override int Draw(IDrawContext drawContext, Transform transform) { this.SetSampler(drawContext); drawContext.DrawImage(new DrawImageParams { Texture = this.Texture, Destination = new Rectangle(this.Rectangle) }); return 1; }
protected override void DrawBackground( IDrawContext drawContext, Rectangle bounds) { base.DrawBackground(drawContext, bounds); //drawContext.DrawRectangle(bounds, Color.FromArgb(0x40, 255, 0, 0)); float margin = Math.Min(bounds.Width, bounds.Height) * 0.1f; bounds = bounds.Inflate(-margin, -margin); float imageDimension = Math.Min(bounds.Width, bounds.Height) * 0.65f; float textHeight = bounds.Height * 0.35f; Rectangle imageBounds = new Rectangle( bounds.Center.X - (imageDimension / 2f), bounds.Center.Y - ((imageDimension + textHeight) / 2f), imageDimension, imageDimension); Rectangle textBounds = new Rectangle(bounds.X, imageBounds.Bottom, bounds.Width, bounds.Bottom - imageBounds.Bottom); //drawContext.DrawRectangle(bounds, Color.FromArgb(0x40, 255, 0, 0)); //drawContext.DrawRectangle(imageBounds, Color.FromArgb(0x40, 255, 0, 0)); //drawContext.DrawRectangle(textBounds, Color.FromArgb(0x40, 255, 0, 0)); Color foregroundColor; if (this.Theme == AppTheme.Dark) { if (this.IsChecked) { foregroundColor = this.Application.Theme.AccentColor; } else { foregroundColor = this.Application.Theme.SubtleForegroundColor; } } else { foregroundColor = Colors.White; } drawContext.DrawImage(this._icon, imageBounds, foregroundColor); drawContext.DrawText(this.Text, textBounds, foregroundColor, this._textFormat); }
protected override void DrawBackground( IDrawContext drawContext, Rectangle bounds) { base.DrawBackground(drawContext, bounds); float imageDimension = Math.Min(bounds.Width, bounds.Height) * 0.65f; float textHeight = bounds.Height * 0.35f; Rectangle imageBounds = new Rectangle( bounds.Center.X - (imageDimension / 2f), bounds.Center.Y - ((imageDimension + textHeight) / 2f), imageDimension, imageDimension); drawContext.DrawImage(this._icon, imageBounds, this.AccentColor); Rectangle textBounds = new Rectangle(bounds.X, imageBounds.Bottom, bounds.Width, bounds.Bottom - imageBounds.Bottom); drawContext.DrawText(this.Text, textBounds, this.AccentColor, this._textFormat); }
protected override void DrawBackground( IDrawContext drawContext, Rectangle bounds) { base.DrawBackground(drawContext, bounds); float margin = Math.Min(bounds.Width, bounds.Height) * 0.1f; bounds = bounds.Inflate(-margin, -margin); float imageDimension = Math.Min(bounds.Width, bounds.Height) * 0.75f; float textHeight = bounds.Height * 0.25f; Rectangle imageBounds = new Rectangle( bounds.Center.X - (imageDimension / 2f), bounds.Center.Y - ((imageDimension + textHeight) / 2f), imageDimension, imageDimension); Rectangle textBounds = new Rectangle(bounds.X, imageBounds.Bottom, bounds.Width, textHeight); drawContext.DrawImage(this.MenuItem.Icon, imageBounds, this.ForegroundColor); drawContext.DrawText(this.MenuItem.Text, textBounds, this.ForegroundColor, this._textFormat); }
public int Draw(IDrawContext drawContext, Sprite sprite, Transform transform) { var source = this.definitions[sprite.SpriteName]; var finalTransform = new SpriteTransform(transform, sprite.Position, sprite.Rotation, sprite.Scale, sprite.Color) .GetSpriteFinal(); var destination = new Rectangle( finalTransform.Translation.X, finalTransform.Translation.Y, source.Rectangle.Width * finalTransform.Scale, source.Rectangle.Height * finalTransform.Scale); //var destination = new Rectangle(0, 0, source.Rectangle.Width, source.Rectangle.Height); //destination = finalTransform.ApplyFor(destination); var origin = sprite.Origin.HasValue ? sprite.Origin.Value : source.Origin; var visibilityCheckRectangle = new Rectangle( destination.X - (origin.X / source.Rectangle.Width) * destination.Width, destination.Y - (origin.Y / source.Rectangle.Height) * destination.Height, destination.Width, destination.Height); if (drawContext.Camera.Viewport.IsVisible(visibilityCheckRectangle)) { if (sprite.ShouldDrawPixelPrecision) destination = destination.Round(); drawContext.DrawImage(new DrawImageParams { Texture = this.Texture, Source = source.Rectangle, Destination = destination, Rotation = finalTransform.Rotation, Origin = origin, Color = finalTransform.Color, ImageEffect = GetImageEffect(sprite) }); return 1; } return 0; }