Пример #1
0
        /// <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);
                        }
                    }
            }
        }
Пример #2
0
        /// <summary>
        /// Creates a Direct2D brush wrapper for a Perspex brush.
        /// </summary>
        /// <param name="brush">The perspex brush.</param>
        /// <param name="destinationSize">The size of the brush's target area.</param>
        /// <returns>The Direct2D brush wrapper.</returns>
        public BrushImpl CreateBrush(Perspex.Media.Brush brush, Size destinationSize)
        {
            var solidColorBrush     = brush as Perspex.Media.SolidColorBrush;
            var linearGradientBrush = brush as Perspex.Media.LinearGradientBrush;
            var radialGradientBrush = brush as Perspex.Media.RadialGradientBrush;
            var imageBrush          = brush as ImageBrush;
            var visualBrush         = brush as VisualBrush;

            if (solidColorBrush != null)
            {
                return(new SolidColorBrushImpl(solidColorBrush, _renderTarget));
            }
            else if (linearGradientBrush != null)
            {
                return(new LinearGradientBrushImpl(linearGradientBrush, _renderTarget, destinationSize));
            }
            else if (radialGradientBrush != null)
            {
                return(new RadialGradientBrushImpl(radialGradientBrush, _renderTarget, destinationSize));
            }
            else if (imageBrush != null)
            {
                return(new TileBrushImpl(imageBrush, _renderTarget, destinationSize));
            }
            else if (visualBrush != null)
            {
                return(new TileBrushImpl(visualBrush, _renderTarget, destinationSize));
            }
            else
            {
                return(new SolidColorBrushImpl(null, _renderTarget));
            }
        }
Пример #3
0
        unsafe NativeBrushContainer CreateBrush(Brush brush, Size targetSize)
        {
            var rv = NativeBrushPool.Instance.Get();
            rv.Brush->Opacity = brush.Opacity;

            var solid = brush as SolidColorBrush;
            if (solid != null)
            {
                rv.Brush->Type = NativeBrushType.Solid;
                rv.Brush->Color = solid.Color.ToUint32();
                return rv;
            }
            var gradient = brush as GradientBrush;
            if (gradient != null)
            {
                if (gradient.GradientStops.Count > NativeBrush.MaxGradientStops)
                    throw new NotSupportedException("Maximum supported gradient stop count is " +
                                                    NativeBrush.MaxGradientStops);
                rv.Brush->GradientSpreadMethod = gradient.SpreadMethod;
                rv.Brush->GradientStopCount = gradient.GradientStops.Count;

                for (var c = 0; c < gradient.GradientStops.Count; c++)
                {
                    var st = gradient.GradientStops[c];
                    rv.Brush->GradientStops[c] = (float) st.Offset;
                    rv.Brush->GradientStopColors[c] = st.Color.ToUint32();
                }

            }

            var linearGradient = brush as LinearGradientBrush;
            if (linearGradient != null)
            {
                rv.Brush->Type = NativeBrushType.LinearGradient;
                rv.Brush->GradientStartPoint = linearGradient.StartPoint.ToPixels(targetSize);
                rv.Brush->GradientEndPoint = linearGradient.EndPoint.ToPixels(targetSize);
            }
            var radialGradient = brush as RadialGradientBrush;
            if (radialGradient != null)
            {
                rv.Brush->Type = NativeBrushType.RadialGradient;
                rv.Brush->GradientStartPoint = radialGradient.Center.ToPixels(targetSize);
                rv.Brush->GradientRadius = (float)radialGradient.Radius;
            }
            var tileBrush = brush as TileBrush;
            if (tileBrush != null)
            {
                rv.Brush->Type = NativeBrushType.Image;
                var helper = new TileBrushImplHelper(tileBrush, targetSize);
                var bitmap = new BitmapImpl((int) helper.IntermediateSize.Width, (int) helper.IntermediateSize.Height);
                rv.AddDisposable(bitmap);
                using (var ctx = bitmap.CreateDrawingContext())
                    helper.DrawIntermediate(ctx);
                rv.Brush->Bitmap = bitmap.Handle;
                rv.Brush->BitmapTileMode = tileBrush.TileMode;
                rv.Brush->BitmapTranslation = new SkiaPoint(-helper.DestinationRect.X, -helper.DestinationRect.Y);
            }

            return rv;
        }
Пример #4
0
 /// <summary>
 /// Draws a filled rectangle.
 /// </summary>
 /// <param name="brush">The brush.</param>
 /// <param name="rect">The rectangle bounds.</param>
 /// <param name="cornerRadius">The corner radius.</param>
 public void FillRectangle(Perspex.Media.Brush brush, Rect rect, float cornerRadius)
 {
     using (var b = CreateBrush(brush, rect.Size))
     {
         if (b.PlatformBrush != null)
         {
             if (cornerRadius == 0)
             {
                 _renderTarget.FillRectangle(rect.ToDirect2D(), b.PlatformBrush);
             }
             else
             {
                 _renderTarget.FillRoundedRectangle(
                     new RoundedRectangle
                 {
                     Rect = new RectangleF(
                         (float)rect.X,
                         (float)rect.Y,
                         (float)rect.Width,
                         (float)rect.Height),
                     RadiusX = cornerRadius,
                     RadiusY = cornerRadius
                 },
                     b.PlatformBrush);
             }
         }
     }
 }
Пример #5
0
 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);
     }
 }
Пример #6
0
        /// <summary>
        /// Draws text.
        /// </summary>
        /// <param name="foreground">The foreground brush.</param>
        /// <param name="origin">The upper-left corner of the text.</param>
        /// <param name="text">The text.</param>
        public void DrawText(Perspex.Media.Brush foreground, Perspex.Point origin, FormattedText text)
        {
            if (!string.IsNullOrEmpty(text.Text))
            {
                var impl = (FormattedTextImpl)text.PlatformImpl;

                using (var renderer = new PerspexTextRenderer(this.renderTarget, foreground.ToDirect2D(this.renderTarget)))
                {
                    impl.TextLayout.Draw(renderer, (float)origin.X, (float)origin.Y);
                }
            }
        }
Пример #7
0
        /// <summary>
        /// Draws text.
        /// </summary>
        /// <param name="foreground">The foreground brush.</param>
        /// <param name="origin">The upper-left corner of the text.</param>
        /// <param name="text">The text.</param>
        public void DrawText(Perspex.Media.Brush foreground, Point origin, FormattedText text)
        {
            if (!string.IsNullOrEmpty(text.Text))
            {
                var impl = (FormattedTextImpl)text.PlatformImpl;

                using (var brush = CreateBrush(foreground, impl.Measure()))
                    using (var renderer = new PerspexTextRenderer(this, _renderTarget, brush.PlatformBrush))
                    {
                        impl.TextLayout.Draw(renderer, (float)origin.X, (float)origin.Y);
                    }
            }
        }
Пример #8
0
 /// <summary>
 /// Draws a filled rectangle.
 /// </summary>
 /// <param name="brush">The brush.</param>
 /// <param name="rect">The rectangle bounds.</param>
 public void FillRectange(Perspex.Media.Brush brush, Rect rect)
 {
     using (var b = brush.ToDirect2D(this.renderTarget))
     {
         this.renderTarget.FillRectangle(
             new RectangleF(
                 (float)rect.X,
                 (float)rect.Y,
                 (float)rect.Width,
                 (float)rect.Height),
             b);
     }
 }
Пример #9
0
 /// <summary>
 /// Draws a filled rectangle.
 /// </summary>
 /// <param name="brush">The brush.</param>
 /// <param name="rect">The rectangle bounds.</param>
 public void FillRectange(Perspex.Media.Brush brush, Rect rect)
 {
     using (SharpDX.Direct2D1.SolidColorBrush b = this.Convert(brush))
     {
         this.renderTarget.FillRectangle(
             new RectangleF(
                 (float)rect.X,
                 (float)rect.Y,
                 (float)rect.Width,
                 (float)rect.Height),
             b);
     }
 }
Пример #10
0
 /// <summary>
 /// Draws text.
 /// </summary>
 /// <param name="foreground">The foreground brush.</param>
 /// <param name="rect">The output rectangle.</param>
 /// <param name="text">The text.</param>
 public void DrawText(Perspex.Media.Brush foreground, Rect rect, FormattedText text)
 {
     if (!string.IsNullOrEmpty(text.Text))
     {
         using (SharpDX.Direct2D1.SolidColorBrush brush = this.Convert(foreground))
             using (SharpDX.DirectWrite.TextFormat format = TextService.GetTextFormat(this.directWriteFactory, text))
             {
                 this.renderTarget.DrawText(
                     text.Text,
                     format,
                     this.Convert(rect),
                     brush);
             }
     }
 }
Пример #11
0
 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;
 }
Пример #12
0
        /// <summary>
        /// Converts a brush to Direct2D.
        /// </summary>
        /// <param name="brush">The brush to convert.</param>
        /// <returns>The Direct2D brush.</returns>
        private SharpDX.Direct2D1.SolidColorBrush Convert(Perspex.Media.Brush brush)
        {
            Perspex.Media.SolidColorBrush solidColorBrush = brush as Perspex.Media.SolidColorBrush;

            if (solidColorBrush != null)
            {
                return(new SharpDX.Direct2D1.SolidColorBrush(
                           this.renderTarget,
                           this.Convert(solidColorBrush.Color)));
            }
            else
            {
                return(new SharpDX.Direct2D1.SolidColorBrush(
                           this.renderTarget,
                           new Color4()));
            }
        }
Пример #13
0
        /// <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);
                }
            }
        }
Пример #14
0
        /// <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);
                }
            }
        }
Пример #15
0
 public void FillRectangle(Brush pbrush, Rect rect, float cornerRadius = 0)
 {
     using (var brush = CreateBrush(pbrush, rect.Size))
     {
         var rc = SkRect.FromRect(rect);
         MethodTable.Instance.DrawRectangle(Handle, brush.Brush, ref rc, cornerRadius);
     }
 }
Пример #16
0
 /// <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
 }
Пример #17
0
 public void SetForegroundBrush(Brush brush, int startIndex, int count)
 {
     this.PlatformImpl.SetForegroundBrush(brush, startIndex, count);
 }
Пример #18
0
 /// <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);
Пример #19
0
 public BrushWrapper(Brush brush)
 {
     this.Brush = brush;
 }
Пример #20
0
 /// <summary>
 /// Draws a filled rectangle.
 /// </summary>
 /// <param name="brush">The brush.</param>
 /// <param name="rect">The rectangle bounds.</param>
 public void FillRectange(Perspex.Media.Brush brush, Rect rect)
 {
     this.SetBrush(brush);
     this.context.Rectangle(rect.ToCairo());
     this.context.Fill();
 }
Пример #21
0
        private void SetBrush(Brush brush, Size destinationSize)
        {
            var solid = brush as SolidColorBrush;
            var linearGradientBrush = brush as LinearGradientBrush;

            if (solid != null)
            {
                _context.SetSourceRGBA(
                    solid.Color.R / 255.0,
                    solid.Color.G / 255.0,
                    solid.Color.B / 255.0,
                    solid.Color.A / 255.0);
            }
            else if (linearGradientBrush != null)
            {
                Cairo.LinearGradient g = new Cairo.LinearGradient(linearGradientBrush.StartPoint.X * destinationSize.Width, linearGradientBrush.StartPoint.Y * destinationSize.Height, linearGradientBrush.EndPoint.X * destinationSize.Width, linearGradientBrush.EndPoint.Y * destinationSize.Height);

                foreach (var s in linearGradientBrush.GradientStops)
                    g.AddColorStopRgb(s.Offset, new Cairo.Color(s.Color.R, s.Color.G, s.Color.B, s.Color.A));

                g.Extend = Cairo.Extend.Pad;

                _context.SetSource(g);
            }
        }
Пример #22
0
 /// <summary>
 /// Init.
 /// </summary>
 public BrushAdapter(Brush brush)
 {
     _brush = brush;
 }
Пример #23
0
 public void DrawText(Brush foreground, Point origin, FormattedText text)
 {
     using (var br = CreateBrush(foreground, text.Measure()))
         MethodTable.Instance.DrawFormattedText(Handle, br.Brush, ((FormattedTextImpl) text.PlatformImpl).Handle,
             (float) origin.X, (float) origin.Y);
 }
Пример #24
0
 /// <summary>
 /// Sets the foreground brush for the specified text range.
 /// </summary>
 /// <param name="brush">The brush.</param>
 /// <param name="startIndex">The start of the text range.</param>
 /// <param name="length">The length of the text range.</param>
 public void SetForegroundBrush(Brush brush, int startIndex, int length)
 {
     PlatformImpl.SetForegroundBrush(brush, startIndex, length);
 }
Пример #25
0
        /// <summary>
        /// the dash style of the pen
        /// </summary>
        //private DashStyle _dashStyle = DashStyles.Solid;

        /// <summary>
        /// Init.
        /// </summary>
        public PenAdapter(Brush brush)
        {
            _brush = brush;
        }
Пример #26
0
        /// <summary>
        /// Draws text.
        /// </summary>
        /// <param name="foreground">The foreground brush.</param>
        /// <param name="origin">The upper-left corner of the text.</param>
        /// <param name="text">The text.</param>
        public void DrawText(Brush foreground, Point origin, FormattedText text)
        {
            var layout = ((FormattedTextImpl)text.PlatformImpl).Layout;
            _context.MoveTo(origin.X, origin.Y);

			using (var b = SetBrush(foreground, new Size(0, 0))) 
			{
				Pango.CairoHelper.ShowLayout(_context, layout);
			}
        }
Пример #27
0
        public void SetForegroundBrush(Brush brush, int startIndex, int count)
        {
            var scb = brush as SolidColorBrush;
            if (scb != null)
            {

                var color = new Pango.Color();
                color.Parse(string.Format("#{0}", scb.Color.ToString().Substring(3)));

                var brushAttr = new Pango.AttrForeground(color);
                brushAttr.StartIndex = (uint)TextIndexToPangoIndex(startIndex);
                brushAttr.EndIndex = (uint)TextIndexToPangoIndex(startIndex + count);

                Layout.Attributes.Insert(brushAttr);
            }
        }
Пример #28
0
        private IDisposable SetBrush(Brush brush, Size destinationSize)
        {
			_context.Save ();

            var solid = brush as SolidColorBrush;
            var linearGradientBrush = brush as LinearGradientBrush;
            var radialGradientBrush = brush as RadialGradientBrush;
            var imageBrush = brush as ImageBrush;
            var visualBrush = brush as VisualBrush;
			BrushImpl impl = null;

			if (solid != null) 
			{
				impl = new SolidColorBrushImpl(solid, opacityOverride);
			} 
			else if (linearGradientBrush != null) 
			{
				impl = new LinearGradientBrushImpl(linearGradientBrush, destinationSize);
			}
            else if (radialGradientBrush != null)
            {
                impl = new RadialGradientBrushImpl(radialGradientBrush, destinationSize);
            }
            else if (imageBrush != null) 
			{
				impl = new ImageBrushImpl(imageBrush, destinationSize);
			} 
			else if (visualBrush != null) 
			{
				impl = new VisualBrushImpl(visualBrush, destinationSize);
			} 
			else 
			{
				impl = new SolidColorBrushImpl(null, opacityOverride);
			}

			_context.SetSource(impl.PlatformBrush);
			return Disposable.Create(() => 
			{
			    impl.Dispose();
				_context.Restore();
			});
        }
Пример #29
0
 /// <summary>
 /// Sets the value of the attached <see cref="ForegroundProperty"/> on a control.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The property value to set.</param>
 /// <returns>The font family.</returns>
 public static void SetForeground(Control control, Brush value)
 {
     control.SetValue(ForegroundProperty, value);
 }
Пример #30
0
        /// <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();
				}
            }
        }
Пример #31
0
 public void SetForegroundBrush(Brush brush, int startIndex, int count)
 {
     TextLayout.SetDrawingEffect(
         new BrushWrapper(brush),
         new DWrite.TextRange(startIndex, count));
 }
Пример #32
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dc"></param>
        /// <param name="brush"></param>
        /// <param name="pen"></param>
        /// <param name="isStroked"></param>
        /// <param name="isFilled"></param>
        /// <param name="rect"></param>
        private static void DrawEllipseInternal(
            IDrawingContext dc,
            Brush brush,
            Pen pen,
            bool isStroked,
            bool isFilled,
            ref Rect2 rect)
        {
            if (!isFilled && !isStroked)
                return;

            var r = new Rect(rect.X, rect.Y, rect.Width, rect.Height);
            var g = new EllipseGeometry(r);

            dc.DrawGeometry(
                isFilled ? brush : null,
                isStroked ? pen : null,
                g);

            // TODO: g.Dispose();
        }
Пример #33
0
        /// <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();
                }
            }
        }
Пример #34
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dc"></param>
        /// <param name="brush"></param>
        /// <param name="pen"></param>
        /// <param name="isStroked"></param>
        /// <param name="isFilled"></param>
        /// <param name="rect"></param>
        private static void DrawRectangleInternal(
            IDrawingContext dc,
            Brush brush,
            Pen pen,
            bool isStroked,
            bool isFilled,
            ref Rect2 rect)
        {
            if (!isStroked && !isFilled)
                return;

            var r = new Rect(rect.X, rect.Y, rect.Width, rect.Height);

            if (isFilled)
            {
                dc.FillRectangle(brush, r);
            }

            if (isStroked)
            {
                dc.DrawRectangle(pen, r);
            }
        }
Пример #35
0
        /// <summary>
        /// Draws a filled rectangle.
        /// </summary>
        /// <param name="brush">The brush.</param>
        /// <param name="rect">The rectangle bounds.</param>
        public void FillRectangle(Brush brush, Rect rect, float cornerRadius)
        {
			using (var b = SetBrush(brush, rect.Size)) 
			{
				_context.Rectangle(rect.ToCairo ());
				_context.Fill();
			}
        }
Пример #36
0
 /// <summary>
 /// Sets the foreground brush for the specified text range.
 /// </summary>
 /// <param name="brush">The brush.</param>
 /// <param name="startIndex">The start of the text range.</param>
 /// <param name="length">The length of the text range.</param>
 public void SetForegroundBrush(Brush brush, int startIndex, int length)
 {
     CheckDisposed();
     PlatformImpl.SetForegroundBrush(brush, startIndex, length);
 }
Пример #37
0
 /// <summary>
 /// Draws a filled rectangle.
 /// </summary>
 /// <param name="brush">The brush.</param>
 /// <param name="rect">The rectangle bounds.</param>
 /// <param name="cornerRadius">The corner radius.</param>
 public void FillRectangle(Brush brush, Rect rect, float cornerRadius = 0.0f)
     => _impl.FillRectangle(brush, rect, cornerRadius);
Пример #38
0
 public BrushWrapper(Brush brush)
 {
     Brush = brush;
 }
Пример #39
0
 /// <summary>
 /// Draws text.
 /// </summary>
 /// <param name="foreground">The foreground brush.</param>
 /// <param name="origin">The upper-left corner of the text.</param>
 /// <param name="text">The text.</param>
 public void DrawText(Brush foreground, Point origin, FormattedText text)
     => _impl.DrawText(foreground, origin, text);
Пример #40
0
        /// <summary>
        /// Draws text.
        /// </summary>
        /// <param name="foreground">The foreground brush.</param>
        /// <param name="origin">The upper-left corner of the text.</param>
        /// <param name="text">The text.</param>
        public void DrawText(Brush foreground, Point origin, FormattedText text)
        {
            var layout = ((FormattedTextImpl)text.PlatformImpl).Layout;
            this.SetBrush(foreground);

            this.context.MoveTo(origin.X, origin.Y);
            Pango.CairoHelper.ShowLayout(this.context, layout);
        }
Пример #41
0
 public void SetForegroundBrush(Brush brush, int startIndex, int count)
 {
     // TODO: Implement.
 }
Пример #42
0
        private void SetBrush(Brush brush)
        {
            var solid = brush as SolidColorBrush;

            if (solid != null)
            {
                this.context.SetSourceRGBA(
                    solid.Color.R / 255.0,
                    solid.Color.G / 255.0,
                    solid.Color.B / 255.0,
                    solid.Color.A / 255.0);
            }
        }
 public void SetForegroundBrush(Brush brush, int startIndex, int length)
 {
 }
Пример #44
0
 public void SetForegroundBrush(Brush brush, int startIndex, int count)
 {
     this.PlatformImpl.SetForegroundBrush(brush, startIndex, count);
 }