/// <summary> /// Draws a geometry. /// </summary> /// <param name="brush">The fill brush.</param> /// <param name="pen">The stroke pen.</param> /// <param name="geometry">The geometry.</param> public void DrawGeometry(Perspex.Media.Brush brush, Pen pen, Perspex.Media.Geometry geometry) { if (brush != null) { using (var d2dBrush = CreateBrush(brush, geometry.Bounds.Size)) { if (d2dBrush.PlatformBrush != null) { var impl = (GeometryImpl)geometry.PlatformImpl; _renderTarget.FillGeometry(impl.Geometry, d2dBrush.PlatformBrush); } } } if (pen != null) { using (var d2dBrush = CreateBrush(pen.Brush, geometry.GetRenderBounds(pen.Thickness).Size)) using (var d2dStroke = pen.ToDirect2DStrokeStyle(_renderTarget)) { if (d2dBrush.PlatformBrush != null) { var impl = (GeometryImpl)geometry.PlatformImpl; _renderTarget.DrawGeometry(impl.Geometry, d2dBrush.PlatformBrush, (float)pen.Thickness, d2dStroke); } } } }
public void DrawGeometry(Brush brush, Pen pen, Geometry geometry) { var impl = ((StreamGeometryImpl) geometry.PlatformImpl); var size = geometry.Bounds.Size; using(var fill = brush!=null?CreateBrush(brush, size):null) using (var stroke = pen?.Brush != null ? CreateBrush(pen, size) : null) { MethodTable.Instance.DrawGeometry(Handle, impl.EffectivePath, fill != null ? fill.Brush : null, stroke != null ? stroke.Brush : null, impl.FillRule == FillRule.EvenOdd); } }
public void DrawGeometry(Brush brush, Pen pen, Geometry geometry) { var impl = ((StreamGeometryImpl) geometry.PlatformImpl); var oldTransform = Transform; if (!impl.Transform.IsIdentity) Transform = impl.Transform*Transform; var size = geometry.Bounds.Size; using(var fill = brush!=null?CreateBrush(brush, size):null) using (var stroke = pen?.Brush != null ? CreateBrush(pen, size) : null) { MethodTable.Instance.DrawGeometry(Handle, impl.Path.Handle, fill != null ? fill.Brush : null, stroke != null ? stroke.Brush : null); } Transform = oldTransform; }
/// <summary> /// Draws a geometry. /// </summary> /// <param name="brush">The fill brush.</param> /// <param name="pen">The stroke pen.</param> /// <param name="geometry">The geometry.</param> public void DrawGeometry(Perspex.Media.Brush brush, Perspex.Media.Pen pen, Perspex.Media.Geometry geometry) { if (brush != null) { using (var d2dBrush = brush.ToDirect2D(this.renderTarget)) { GeometryImpl impl = (GeometryImpl)geometry.PlatformImpl; this.renderTarget.FillGeometry(impl.Geometry, d2dBrush); } } if (pen != null) { using (var d2dBrush = pen.Brush.ToDirect2D(this.renderTarget)) { GeometryImpl impl = (GeometryImpl)geometry.PlatformImpl; this.renderTarget.DrawGeometry(impl.Geometry, d2dBrush, (float)pen.Thickness); } } }
/// <summary> /// Draws a geometry. /// </summary> /// <param name="brush">The fill brush.</param> /// <param name="pen">The stroke pen.</param> /// <param name="geometry">The geometry.</param> public void DrawGeometry(Perspex.Media.Brush brush, Perspex.Media.Pen pen, Perspex.Media.Geometry geometry) { if (brush != null) { using (SharpDX.Direct2D1.SolidColorBrush d2dBrush = this.Convert(brush)) { GeometryImpl impl = (GeometryImpl)geometry.PlatformImpl; this.renderTarget.FillGeometry(impl.Geometry, d2dBrush); } } if (pen != null) { using (SharpDX.Direct2D1.SolidColorBrush d2dBrush = this.Convert(pen.Brush)) { GeometryImpl impl = (GeometryImpl)geometry.PlatformImpl; this.renderTarget.DrawGeometry(impl.Geometry, d2dBrush, (float)pen.Thickness); } } }
/// <summary> /// Draws a geometry. /// </summary> /// <param name="brush">The fill brush.</param> /// <param name="pen">The stroke pen.</param> /// <param name="geometry">The geometry.</param> public void DrawGeometry(Brush brush, Pen pen, Geometry geometry) => _impl.DrawGeometry(brush, pen, geometry);
/// <summary> /// Draws a geometry. /// </summary> /// <param name="brush">The fill brush.</param> /// <param name="pen">The stroke pen.</param> /// <param name="geometry">The geometry.</param> public void DrawGeometry(Brush brush, Pen pen, Geometry geometry) { var impl = geometry.PlatformImpl as StreamGeometryImpl; var oldMatrix = Transform; Transform = impl.Transform * Transform; if (brush != null) { _context.AppendPath(impl.Path); using (var b = SetBrush(brush, geometry.Bounds.Size)) { _context.FillRule = impl.FillRule == FillRule.EvenOdd ? Cairo.FillRule.EvenOdd : Cairo.FillRule.Winding; if (pen != null) _context.FillPreserve(); else _context.Fill(); } } Transform = oldMatrix; if (pen != null) { _context.AppendPath(impl.Path); using (var p = SetPen(pen, geometry.Bounds.Size)) { _context.Stroke(); } } }
protected override Size MeasureOverride(Size availableSize) { // This should probably use GetRenderBounds(strokeThickness) but then the calculations // will multiply the stroke thickness as well, which isn't correct. Rect shapeBounds = DefiningGeometry.Bounds; Size shapeSize = new Size(shapeBounds.Right, shapeBounds.Bottom); Matrix translate = Matrix.Identity; double width = Width; double height = Height; double desiredX = availableSize.Width; double desiredY = availableSize.Height; double sx = 0.0; double sy = 0.0; if (Stretch != Stretch.None) { shapeSize = shapeBounds.Size; translate = Matrix.CreateTranslation(-(Vector)shapeBounds.Position); } if (double.IsInfinity(availableSize.Width)) { desiredX = shapeSize.Width; } if (double.IsInfinity(availableSize.Height)) { desiredY = shapeSize.Height; } if (shapeBounds.Width > 0) { sx = desiredX / shapeSize.Width; } if (shapeBounds.Height > 0) { sy = desiredY / shapeSize.Height; } if (double.IsInfinity(availableSize.Width)) { sx = sy; } if (double.IsInfinity(availableSize.Height)) { sy = sx; } switch (Stretch) { case Stretch.Uniform: sx = sy = Math.Min(sx, sy); break; case Stretch.UniformToFill: sx = sy = Math.Max(sx, sy); break; case Stretch.Fill: if (double.IsInfinity(availableSize.Width)) { sx = 1.0; } if (double.IsInfinity(availableSize.Height)) { sy = 1.0; } break; default: sx = sy = 1; break; } var t = translate * Matrix.CreateScale(sx, sy); if (_transform != t) { _transform = t; _renderedGeometry = null; } return new Size(shapeSize.Width * sx, shapeSize.Height * sy); }
/// <summary> /// Draws a geometry. /// </summary> /// <param name="brush">The fill brush.</param> /// <param name="pen">The stroke pen.</param> /// <param name="geometry">The geometry.</param> public void DrawGeometry(Brush brush, Pen pen, Geometry geometry) { var impl = geometry.PlatformImpl as StreamGeometryImpl; using (var pop = PushTransform(impl.Transform)) { _context.AppendPath(impl.Path); if (brush != null) { using (var b = SetBrush(brush, geometry.Bounds.Size)) { if (pen != null) _context.FillPreserve(); else _context.Fill(); } } } if (pen != null) { using (var p = SetPen(pen, geometry.Bounds.Size)) { _context.Stroke(); } } }
/// <summary> /// Draws a geometry. /// </summary> /// <param name="brush">The fill brush.</param> /// <param name="pen">The stroke pen.</param> /// <param name="geometry">The geometry.</param> public void DrawGeometry(Perspex.Media.Brush brush, Perspex.Media.Pen pen, Perspex.Media.Geometry geometry) { // TODO: Implement }
protected void InvalidateGeometry() { this._renderedGeometry = null; this._definingGeometry = null; InvalidateMeasure(); }