Back to Devexpress

GradientFill Class

officefileapi-devexpress-dot-docs-dot-presentation-f7da6e93.md

latest4.4 KB
Original Source

GradientFill Class

Gradient fill.

Namespace : DevExpress.Docs.Presentation

Assembly : DevExpress.Docs.Presentation.v25.2.dll

NuGet Package : DevExpress.Docs.Presentation

Declaration

csharp
public class GradientFill :
    OutlineFill
vb
Public Class GradientFill
    Inherits OutlineFill

The following members return GradientFill objects:

Remarks

The following example applies a linear gradient fill to the presentation slide background:

csharp
using DevExpress.Docs.Presentation;
using DevExpress.Drawing;
using System.Drawing;

    Slide slide = new Slide(new SlideLayout(layoutType: SlideLayoutType.Blank, name: "slide"));
    GradientFill fill = new GradientFill(gradientType: GradientType.Linear);
    fill.GradientStops.Add(new GradientStop(Color.Cornsilk, 10));
    fill.GradientStops.Add(new GradientStop (Color.AliceBlue, 30));
    fill.GradientStops.Add(new GradientStop (Color.RoyalBlue, 90));
    slide.Background = new CustomSlideBackground(fill);
vb
Imports DevExpress.Docs.Presentation
Imports DevExpress.Drawing
Imports System.Drawing

    Dim slide As New Slide(New SlideLayout(SlideLayoutType.Blank, "slide"))
    Dim fill As New GradientFill(GradientType.Linear)
    fill.GradientStops.Add(New GradientStop(Color.Cornsilk, 10))
    fill.GradientStops.Add(New GradientStop(Color.AliceBlue, 30))
    fill.GradientStops.Add(New GradientStop(Color.RoyalBlue, 90))
    slide.Background = New CustomSlideBackground(fill)

The following example applies a gradient fill to a shape:

csharp
using DevExpress.Docs;
using DevExpress.Docs.Presentation;
using System.Drawing;

namespace PresentationApiSample;

public class Program {
    public static async Task Main(string[] _) {
        //...
        Shape shape1 = new Shape(ShapeType.Rectangle);
        shape1.Outline = new LineStyle { Fill = new SolidFill(Color.RoyalBlue), Width = 8 };
        shape1.X = 1100;
        shape1.Y = 1100;
        shape1.Width = 300;
        shape1.Height = 300;
        slide.Shapes.Add(shape1);

        GradientFill fill = new GradientFill(gradientType: GradientType.Linear);
        fill.GradientStops.Add(new GradientStop(Color.Cornsilk, 10));
        fill.GradientStops.Add(new GradientStop (Color.AliceBlue,50));
        fill.GradientStops.Add(new GradientStop (Color.RoyalBlue, 90));
        fill.Scaled = true;
        shape1.Fill = fill;
    }
}
vb
Imports DevExpress.Docs
Imports DevExpress.Docs.Presentation
Imports System.Drawing

Namespace PresentationApiSample

    Public Class Program
        Public Shared Async Function Main(__ As String()) As Task
            Dim shape1 As New Shape(ShapeType.Rectangle)
            shape1.Outline = New LineStyle With {.Fill = New SolidFill(Color.RoyalBlue), .Width = 8}
            shape1.X = 1100
            shape1.Y = 1100
            shape1.Width = 300
            shape1.Height = 300
            slide.Shapes.Add(shape1)

            Dim fill As New GradientFill(GradientType.Linear)
            fill.GradientStops.Add(New GradientStop(Color.Cornsilk, 10))
            fill.GradientStops.Add(New GradientStop(Color.AliceBlue, 50))
            fill.GradientStops.Add(New GradientStop(Color.RoyalBlue, 90))
            fill.Scaled = True
            shape1.Fill = fill
        End Function
    End Class
End Namespace

Implements

ICloneable

Inheritance

Object PresentationObject Fill OutlineFill GradientFill

See Also

GradientFill Members

DevExpress.Docs.Presentation Namespace